Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -25,7 +25,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate {
return {
f: [
"var __WEBPACK_AMD_DEFINE_RESULT__;",
`!(__WEBPACK_AMD_DEFINE_RESULT__ = #.call(exports, __webpack_require__, exports, module),
`!(__WEBPACK_AMD_DEFINE_RESULT__ = (#).call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))`
],
o: [
@@ -42,7 +42,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate {
],
af: [
"var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;",
`!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_RESULT__ = #.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
`!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_RESULT__ = (#).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))`
],
ao: [
@@ -70,7 +70,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate {
],
laf: [
"var __WEBPACK_AMD_DEFINE_ARRAY__, XXX;",
"!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, XXX = (#.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)))"
"!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, XXX = ((#).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)))"
],
lao: [
"var XXX;",

View File

@@ -23,6 +23,18 @@ function isBoundFunctionExpression(expr) {
return true;
}
function isUnboundFunctionExpression(expr) {
if(expr.type === "FunctionExpression") return true;
if(expr.type === "ArrowFunctionExpression") return true;
return false;
}
function isCallable(expr) {
if(isUnboundFunctionExpression(expr)) return true;
if(isBoundFunctionExpression(expr)) return true;
return false;
}
class AMDDefineDependencyParserPlugin {
constructor(options) {
this.options = options;
@@ -38,7 +50,7 @@ class AMDDefineDependencyParserPlugin {
let array, fn, obj, namedModule;
switch(expr.arguments.length) {
case 1:
if(expr.arguments[0].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[0])) {
if(isCallable(expr.arguments[0])) {
// define(f() {...})
fn = expr.arguments[0];
} else if(expr.arguments[0].type === "ObjectExpression") {
@@ -54,7 +66,7 @@ class AMDDefineDependencyParserPlugin {
if(expr.arguments[0].type === "Literal") {
namedModule = expr.arguments[0].value;
// define("...", ...)
if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) {
if(isCallable(expr.arguments[1])) {
// define("...", f() {...})
fn = expr.arguments[1];
} else if(expr.arguments[1].type === "ObjectExpression") {
@@ -67,7 +79,7 @@ class AMDDefineDependencyParserPlugin {
}
} else {
array = expr.arguments[0];
if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) {
if(isCallable(expr.arguments[1])) {
// define([...], f() {})
fn = expr.arguments[1];
} else if(expr.arguments[1].type === "ObjectExpression") {
@@ -84,7 +96,7 @@ class AMDDefineDependencyParserPlugin {
// define("...", [...], f() {...})
namedModule = expr.arguments[0].value;
array = expr.arguments[1];
if(expr.arguments[2].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[2])) {
if(isCallable(expr.arguments[2])) {
// define("...", [...], f() {})
fn = expr.arguments[2];
} else if(expr.arguments[2].type === "ObjectExpression") {
@@ -102,7 +114,7 @@ class AMDDefineDependencyParserPlugin {
let fnParams = null;
let fnParamsOffset = 0;
if(fn) {
if(fn.type === "FunctionExpression") fnParams = fn.params;
if(isUnboundFunctionExpression(fn)) fnParams = fn.params;
else if(isBoundFunctionExpression(fn)) {
fnParams = fn.callee.object.params;
fnParamsOffset = fn.arguments.length - 1;
@@ -134,7 +146,7 @@ class AMDDefineDependencyParserPlugin {
});
}
let inTry;
if(fn && fn.type === "FunctionExpression") {
if(fn && isUnboundFunctionExpression(fn)) {
inTry = parser.scope.inTry;
parser.inScope(fnParams, () => {
parser.scope.renames = fnRenames;

View File

@@ -44,8 +44,8 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate {
source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock);
source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; ((");
source.insert(depBlock.functionRange[1], ").apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
source.replace(depBlock.functionRange[1], depBlock.errorCallbackRange[0] - 1, errorRangeBlock);
source.replace(depBlock.errorCallbackRange[1], depBlock.outerRange[1] - 1, endBlock);
return;
@@ -57,8 +57,8 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate {
const endBlock = `}${depBlock.functionBindThis ? ".bind(this)" : ""}${wrapper[1]}__webpack_require__.oe${wrapper[2]}`;
source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock);
source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; ((");
source.insert(depBlock.functionRange[1], ").apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, endBlock);
}
}

View File

@@ -9,7 +9,7 @@ const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency
module.exports = class HarmonyDetectionParserPlugin {
apply(parser) {
parser.plugin("program", (ast) => {
var isHarmony = ast.body.some(statement => {
const isHarmony = ast.body.some(statement => {
return /^(Import|Export).*Declaration$/.test(statement.type);
});
if(isHarmony) {
@@ -32,7 +32,7 @@ module.exports = class HarmonyDetectionParserPlugin {
module.exportsArgument = "__webpack_exports__";
}
});
var nonHarmonyIdentifiers = ["define", "exports"];
const nonHarmonyIdentifiers = ["define", "exports"];
nonHarmonyIdentifiers.forEach(identifer => {
parser.plugin(`evaluate typeof ${identifer}`, nullInHarmony);
parser.plugin(`typeof ${identifer}`, skipInHarmony);

View File

@@ -3,7 +3,7 @@
Author Tobias Koppers @sokra
*/
"use strict";
var ModuleDependency = require("./ModuleDependency");
const ModuleDependency = require("./ModuleDependency");
class HarmonyImportDependency extends ModuleDependency {
constructor(request, importedVar, range) {

View File

@@ -14,8 +14,8 @@ const lookup = (parent, mod) => {
segs = mod.split("/");
path.pop();
for(var i = 0; i < segs.length; i++) {
var seg = segs[i];
for(let i = 0; i < segs.length; i++) {
const seg = segs[i];
if(seg === "..") path.pop();
else if(seg !== ".") path.push(seg);
}
@@ -25,7 +25,7 @@ const lookup = (parent, mod) => {
LocalModulesHelpers.addLocalModule = (state, name) => {
if(!state.localModules) state.localModules = [];
var m = new LocalModule(state.module, name, state.localModules.length);
const m = new LocalModule(state.module, name, state.localModules.length);
state.localModules.push(m);
return m;
};
@@ -36,7 +36,7 @@ LocalModulesHelpers.getLocalModule = (state, name, namedModule) => {
// resolve dependency name relative to the defining named module
name = lookup(namedModule, name);
}
for(var i = 0; i < state.localModules.length; i++) {
for(let i = 0; i < state.localModules.length; i++) {
if(state.localModules[i].name === name)
return state.localModules[i];
}

View File

@@ -11,6 +11,14 @@ class RequireIncludeDependency extends ModuleDependency {
this.range = range;
}
getReference() {
if(!this.module) return null;
return {
module: this.module,
importedNames: [] // This doesn't use any export
};
}
get type() {
return "require.include";
}