mirror of https://github.com/webpack/webpack.git
refactor meta -> buildMeta, add factoryMeta
add compat layer to Module.meta
This commit is contained in:
parent
2bb95a3b93
commit
ffb977fed4
|
@ -1426,11 +1426,11 @@ class Compilation extends Tapable {
|
||||||
for(let indexModule = 0; indexModule < modules.length; indexModule++) {
|
for(let indexModule = 0; indexModule < modules.length; indexModule++) {
|
||||||
const module = modules[indexModule];
|
const module = modules[indexModule];
|
||||||
|
|
||||||
if(module.fileDependencies) {
|
if(module.buildInfo.fileDependencies) {
|
||||||
addAllToSet(this.fileDependencies, module.fileDependencies);
|
addAllToSet(this.fileDependencies, module.buildInfo.fileDependencies);
|
||||||
}
|
}
|
||||||
if(module.contextDependencies) {
|
if(module.buildInfo.contextDependencies) {
|
||||||
addAllToSet(this.contextDependencies, module.contextDependencies);
|
addAllToSet(this.contextDependencies, module.buildInfo.contextDependencies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.errors.forEach(error => {
|
this.errors.forEach(error => {
|
||||||
|
@ -1514,10 +1514,11 @@ class Compilation extends Tapable {
|
||||||
createModuleAssets() {
|
createModuleAssets() {
|
||||||
for(let i = 0; i < this.modules.length; i++) {
|
for(let i = 0; i < this.modules.length; i++) {
|
||||||
const module = this.modules[i];
|
const module = this.modules[i];
|
||||||
if(module.assets) {
|
if(!module.buildInfo) console.log(module);
|
||||||
Object.keys(module.assets).forEach((assetName) => {
|
if(module.buildInfo.assets) {
|
||||||
|
Object.keys(module.buildInfo.assets).forEach((assetName) => {
|
||||||
const fileName = this.getPath(assetName);
|
const fileName = this.getPath(assetName);
|
||||||
this.assets[fileName] = module.assets[assetName];
|
this.assets[fileName] = module.buildInfo.assets[assetName];
|
||||||
this.hooks.moduleAsset.call(module, fileName);
|
this.hooks.moduleAsset.call(module, fileName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,7 @@ class ContextModule extends Module {
|
||||||
this.resolveOptions = options.resolveOptions;
|
this.resolveOptions = options.resolveOptions;
|
||||||
|
|
||||||
// Info from Build
|
// Info from Build
|
||||||
this.builtTime = undefined;
|
this._contextDependencies = new Set([this.context]);
|
||||||
this.contextDependencies = new Set([this.context]);
|
|
||||||
|
|
||||||
if(typeof options.mode !== "string")
|
if(typeof options.mode !== "string")
|
||||||
throw new Error("options.mode is a required option");
|
throw new Error("options.mode is a required option");
|
||||||
|
@ -136,12 +135,16 @@ class ContextModule extends Module {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ts >= this.builtTime;
|
return ts >= this.buildInfo.builtTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
build(options, compilation, resolver, fs, callback) {
|
build(options, compilation, resolver, fs, callback) {
|
||||||
this.built = true;
|
this.built = true;
|
||||||
this.builtTime = Date.now();
|
this.buildMeta = {};
|
||||||
|
this.buildInfo = {
|
||||||
|
builtTime: Date.now(),
|
||||||
|
contextDependencies: this._contextDependencies
|
||||||
|
};
|
||||||
this.resolveDependencies(fs, this.options, (err, dependencies) => {
|
this.resolveDependencies(fs, this.options, (err, dependencies) => {
|
||||||
if(err) return callback(err);
|
if(err) return callback(err);
|
||||||
|
|
||||||
|
@ -238,7 +241,7 @@ class ContextModule extends Module {
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return b.module.id - a.module.id;
|
return b.module.id - a.module.id;
|
||||||
}).reduce((map, dep) => {
|
}).reduce((map, dep) => {
|
||||||
const harmonyModule = dep.module.meta && dep.module.meta.harmonyModule;
|
const harmonyModule = dep.module.buildMeta && dep.module.buildMeta.harmonyModule;
|
||||||
if(!harmonyModule) hasNonHarmony = true;
|
if(!harmonyModule) hasNonHarmony = true;
|
||||||
if(harmonyModule) hasHarmony = true;
|
if(harmonyModule) hasHarmony = true;
|
||||||
map[dep.module.id] = harmonyModule ? 1 : 0;
|
map[dep.module.id] = harmonyModule ? 1 : 0;
|
||||||
|
|
|
@ -18,7 +18,6 @@ class DelegatedModule extends Module {
|
||||||
// Info from Factory
|
// Info from Factory
|
||||||
this.sourceRequest = sourceRequest;
|
this.sourceRequest = sourceRequest;
|
||||||
this.request = data.id;
|
this.request = data.id;
|
||||||
this.meta = data.meta;
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.userRequest = userRequest;
|
this.userRequest = userRequest;
|
||||||
this.originalRequest = originalRequest;
|
this.originalRequest = originalRequest;
|
||||||
|
@ -43,6 +42,8 @@ class DelegatedModule extends Module {
|
||||||
|
|
||||||
build(options, compilation, resolver, fs, callback) {
|
build(options, compilation, resolver, fs, callback) {
|
||||||
this.built = true;
|
this.built = true;
|
||||||
|
this.buildMeta = Object.assign({}, this.delegateData.buildMeta);
|
||||||
|
this.buildInfo = {};
|
||||||
this.dependencies.length = 0;
|
this.dependencies.length = 0;
|
||||||
this.addDependency(new DelegatedSourceDependency(this.sourceRequest));
|
this.addDependency(new DelegatedSourceDependency(this.sourceRequest));
|
||||||
this.addDependency(new DelegatedExportsDependency(this, this.delegateData.exports || true));
|
this.addDependency(new DelegatedExportsDependency(this, this.delegateData.exports || true));
|
||||||
|
|
|
@ -28,6 +28,8 @@ class DllModule extends Module {
|
||||||
|
|
||||||
build(options, compilation, resolver, fs, callback) {
|
build(options, compilation, resolver, fs, callback) {
|
||||||
this.built = true;
|
this.built = true;
|
||||||
|
this.buildMeta = {};
|
||||||
|
this.buildInfo = {};
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,8 @@ class ExternalModule extends Module {
|
||||||
|
|
||||||
build(options, compilation, resolver, fs, callback) {
|
build(options, compilation, resolver, fs, callback) {
|
||||||
this.built = true;
|
this.built = true;
|
||||||
|
this.buildMeta = {};
|
||||||
|
this.buildInfo = {};
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ class FlagDependencyExportsPlugin {
|
||||||
module = queue.dequeue();
|
module = queue.dequeue();
|
||||||
|
|
||||||
if(module.providedExports !== true) {
|
if(module.providedExports !== true) {
|
||||||
moduleWithExports = module.meta && module.meta.harmonyModule;
|
moduleWithExports = module.buildMeta && module.buildMeta.harmonyModule;
|
||||||
moduleProvidedExports = Array.isArray(module.providedExports) ? new Set(module.providedExports) : new Set();
|
moduleProvidedExports = Array.isArray(module.providedExports) ? new Set(module.providedExports) : new Set();
|
||||||
processDependenciesBlock(module);
|
processDependenciesBlock(module);
|
||||||
if(!moduleWithExports) {
|
if(!moduleWithExports) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ class FlagDependencyUsagePlugin {
|
||||||
|
|
||||||
// for a module without side effects we stop tracking usage here when no export is used
|
// for a module without side effects we stop tracking usage here when no export is used
|
||||||
// This module won't be evaluated in this case
|
// This module won't be evaluated in this case
|
||||||
if(module.sideEffectFree) {
|
if(module.factoryMeta.sideEffectFree) {
|
||||||
if(module.usedExports === false) return;
|
if(module.usedExports === false) return;
|
||||||
if(Array.isArray(module.usedExports) && module.usedExports.length === 0) return;
|
if(Array.isArray(module.usedExports) && module.usedExports.length === 0) return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ class FunctionModuleTemplatePlugin {
|
||||||
args.push(module.exportsArgument, "__webpack_require__");
|
args.push(module.exportsArgument, "__webpack_require__");
|
||||||
}
|
}
|
||||||
source.add("/***/ (function(" + args.join(", ") + ") {\n\n");
|
source.add("/***/ (function(" + args.join(", ") + ") {\n\n");
|
||||||
if(module.strict) source.add("\"use strict\";\n");
|
if(module.buildInfo.strict) source.add("\"use strict\";\n");
|
||||||
source.add(moduleSource);
|
source.add(moduleSource);
|
||||||
source.add("\n\n/***/ })");
|
source.add("\n\n/***/ })");
|
||||||
return source;
|
return source;
|
||||||
|
|
|
@ -40,7 +40,7 @@ class LibManifestPlugin {
|
||||||
ident,
|
ident,
|
||||||
data: {
|
data: {
|
||||||
id: module.id,
|
id: module.id,
|
||||||
meta: module.meta,
|
buildMeta: module.buildMeta,
|
||||||
exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
|
exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,18 +59,13 @@ class Module extends DependenciesBlock {
|
||||||
// TODO refactor: pass as constructor argument
|
// TODO refactor: pass as constructor argument
|
||||||
this.context = null;
|
this.context = null;
|
||||||
this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
|
this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
|
||||||
|
this.factoryMeta = {};
|
||||||
|
|
||||||
// Info from Build
|
// Info from Build
|
||||||
this.sideEffectFree = false;
|
|
||||||
this.warnings = [];
|
this.warnings = [];
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
this.strict = false;
|
this.buildMeta = undefined;
|
||||||
this.meta = {};
|
this.buildInfo = undefined;
|
||||||
this.exportsArgument = "exports";
|
|
||||||
this.moduleArgument = "module";
|
|
||||||
this.assets = null;
|
|
||||||
this.fileDependencies = undefined;
|
|
||||||
this.contextDependencies = undefined;
|
|
||||||
|
|
||||||
// Graph (per Compilation)
|
// Graph (per Compilation)
|
||||||
this.reasons = [];
|
this.reasons = [];
|
||||||
|
@ -96,6 +91,14 @@ class Module extends DependenciesBlock {
|
||||||
this._rewriteChunkInReasons = undefined;
|
this._rewriteChunkInReasons = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get exportsArgument() {
|
||||||
|
return this.buildInfo && this.buildInfo.exportsArgument || "exports";
|
||||||
|
}
|
||||||
|
|
||||||
|
get moduleArgument() {
|
||||||
|
return this.buildInfo && this.buildInfo.moduleArgument || "module";
|
||||||
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
this.hash = undefined;
|
this.hash = undefined;
|
||||||
this.renderedHash = undefined;
|
this.renderedHash = undefined;
|
||||||
|
@ -288,6 +291,8 @@ class Module extends DependenciesBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
unbuild() {
|
unbuild() {
|
||||||
|
this.buildMeta = undefined;
|
||||||
|
this.buildInfo = undefined;
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,6 +325,16 @@ Object.defineProperty(Module.prototype, "chunks", {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(Module.prototype, "meta", {
|
||||||
|
configurable: false,
|
||||||
|
get: util.deprecate(function() {
|
||||||
|
return this.buildMeta;
|
||||||
|
}, "Module.meta was renamed to Module.buildMeta"),
|
||||||
|
set: util.deprecate(function(value) {
|
||||||
|
this.buildMeta = value;
|
||||||
|
}, "Module.meta was renamed to Module.buildMeta"),
|
||||||
|
});
|
||||||
|
|
||||||
Module.prototype.identifier = null;
|
Module.prototype.identifier = null;
|
||||||
Module.prototype.readableIdentifier = null;
|
Module.prototype.readableIdentifier = null;
|
||||||
Module.prototype.build = null;
|
Module.prototype.build = null;
|
||||||
|
|
|
@ -29,6 +29,8 @@ class MultiModule extends Module {
|
||||||
|
|
||||||
build(options, compilation, resolver, fs, callback) {
|
build(options, compilation, resolver, fs, callback) {
|
||||||
this.built = true;
|
this.built = true;
|
||||||
|
this.buildMeta = {};
|
||||||
|
this.buildInfo = {};
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,14 +75,14 @@ class NodeStuffPlugin {
|
||||||
parser.plugin("expression module.id", ParserHelpers.toConstantDependency("module.i"));
|
parser.plugin("expression module.id", ParserHelpers.toConstantDependency("module.i"));
|
||||||
parser.plugin("expression module.exports", () => {
|
parser.plugin("expression module.exports", () => {
|
||||||
const module = parser.state.module;
|
const module = parser.state.module;
|
||||||
const isHarmony = module.meta && module.meta.harmonyModule;
|
const isHarmony = module.buildMeta && module.buildMeta.harmonyModule;
|
||||||
if(!isHarmony)
|
if(!isHarmony)
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToIdentifier("module.hot", false));
|
parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToIdentifier("module.hot", false));
|
||||||
parser.plugin("expression module", () => {
|
parser.plugin("expression module", () => {
|
||||||
const module = parser.state.module;
|
const module = parser.state.module;
|
||||||
const isHarmony = module.meta && module.meta.harmonyModule;
|
const isHarmony = module.buildMeta && module.buildMeta.harmonyModule;
|
||||||
let moduleJsPath = path.join(__dirname, "..", "buildin", isHarmony ? "harmony-module.js" : "module.js");
|
let moduleJsPath = path.join(__dirname, "..", "buildin", isHarmony ? "harmony-module.js" : "module.js");
|
||||||
if(module.context) {
|
if(module.context) {
|
||||||
moduleJsPath = path.relative(parser.state.module.context, moduleJsPath);
|
moduleJsPath = path.relative(parser.state.module.context, moduleJsPath);
|
||||||
|
|
|
@ -81,12 +81,9 @@ class NormalModule extends Module {
|
||||||
this.resolveOptions = resolveOptions;
|
this.resolveOptions = resolveOptions;
|
||||||
|
|
||||||
// Info from Build
|
// Info from Build
|
||||||
this.fileDependencies = new Set();
|
|
||||||
this.contextDependencies = new Set();
|
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this._source = null;
|
this._source = null;
|
||||||
this.buildTimestamp = undefined;
|
this.buildTimestamp = undefined;
|
||||||
this.cacheable = false;
|
|
||||||
this._cachedSource = undefined;
|
this._cachedSource = undefined;
|
||||||
this._cachedSourceHash = undefined;
|
this._cachedSourceHash = undefined;
|
||||||
|
|
||||||
|
@ -150,8 +147,8 @@ class NormalModule extends Module {
|
||||||
resolver.resolve({}, context, request, callback);
|
resolver.resolve({}, context, request, callback);
|
||||||
},
|
},
|
||||||
emitFile: (name, content, sourceMap) => {
|
emitFile: (name, content, sourceMap) => {
|
||||||
if(!this.assets) this.assets = Object.create(null);
|
if(!this.buildInfo.assets) this.buildInfo.assets = Object.create(null);
|
||||||
this.assets[name] = this.createSourceForAsset(name, content, sourceMap);
|
this.buildInfo.assets[name] = this.createSourceForAsset(name, content, sourceMap);
|
||||||
},
|
},
|
||||||
rootContext: options.context,
|
rootContext: options.context,
|
||||||
webpack: true,
|
webpack: true,
|
||||||
|
@ -195,7 +192,6 @@ class NormalModule extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
doBuild(options, compilation, resolver, fs, callback) {
|
doBuild(options, compilation, resolver, fs, callback) {
|
||||||
this.cacheable = false;
|
|
||||||
const loaderContext = this.createLoaderContext(resolver, options, compilation, fs);
|
const loaderContext = this.createLoaderContext(resolver, options, compilation, fs);
|
||||||
|
|
||||||
runLoaders({
|
runLoaders({
|
||||||
|
@ -205,9 +201,9 @@ class NormalModule extends Module {
|
||||||
readResource: fs.readFile.bind(fs)
|
readResource: fs.readFile.bind(fs)
|
||||||
}, (err, result) => {
|
}, (err, result) => {
|
||||||
if(result) {
|
if(result) {
|
||||||
this.cacheable = result.cacheable;
|
this.buildInfo.cacheable = result.cacheable;
|
||||||
this.fileDependencies = new Set(result.fileDependencies);
|
this.buildInfo.fileDependencies = new Set(result.fileDependencies);
|
||||||
this.contextDependencies = new Set(result.contextDependencies);
|
this.buildInfo.contextDependencies = new Set(result.contextDependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(err) {
|
if(err) {
|
||||||
|
@ -232,7 +228,6 @@ class NormalModule extends Module {
|
||||||
}
|
}
|
||||||
|
|
||||||
markModuleAsErrored(error) {
|
markModuleAsErrored(error) {
|
||||||
this.meta = null;
|
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.errors.push(this.error);
|
this.errors.push(this.error);
|
||||||
this._source = new RawSource("throw new Error(" + JSON.stringify(this.error.message) + ");");
|
this._source = new RawSource("throw new Error(" + JSON.stringify(this.error.message) + ");");
|
||||||
|
@ -288,7 +283,12 @@ class NormalModule extends Module {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.errors.length = 0;
|
this.errors.length = 0;
|
||||||
this.warnings.length = 0;
|
this.warnings.length = 0;
|
||||||
this.meta = {};
|
this.buildMeta = {};
|
||||||
|
this.buildInfo = {
|
||||||
|
cacheable: false,
|
||||||
|
fileDependencies: new Set(),
|
||||||
|
contextDependencies: new Set(),
|
||||||
|
};
|
||||||
|
|
||||||
return this.doBuild(options, compilation, resolver, fs, (err) => {
|
return this.doBuild(options, compilation, resolver, fs, (err) => {
|
||||||
this.dependencies.length = 0;
|
this.dependencies.length = 0;
|
||||||
|
@ -516,17 +516,17 @@ class NormalModule extends Module {
|
||||||
if(this.error) return true;
|
if(this.error) return true;
|
||||||
|
|
||||||
// always rebuild when module is not cacheable
|
// always rebuild when module is not cacheable
|
||||||
if(!this.cacheable) return true;
|
if(!this.buildInfo.cacheable) return true;
|
||||||
|
|
||||||
// Check timestamps of all dependencies
|
// Check timestamps of all dependencies
|
||||||
// Missing timestamp -> need rebuild
|
// Missing timestamp -> need rebuild
|
||||||
// Timestamp bigger than buildTimestamp -> need rebuild
|
// Timestamp bigger than buildTimestamp -> need rebuild
|
||||||
for(const file of this.fileDependencies) {
|
for(const file of this.buildInfo.fileDependencies) {
|
||||||
const timestamp = fileTimestamps[file];
|
const timestamp = fileTimestamps[file];
|
||||||
if(!timestamp) return true;
|
if(!timestamp) return true;
|
||||||
if(timestamp >= this.buildTimestamp) return true;
|
if(timestamp >= this.buildTimestamp) return true;
|
||||||
}
|
}
|
||||||
for(const file of this.contextDependencies) {
|
for(const file of this.buildInfo.contextDependencies) {
|
||||||
const timestamp = contextTimestamps[file];
|
const timestamp = contextTimestamps[file];
|
||||||
if(!timestamp) return true;
|
if(!timestamp) return true;
|
||||||
if(timestamp >= this.buildTimestamp) return true;
|
if(timestamp >= this.buildTimestamp) return true;
|
||||||
|
@ -550,7 +550,7 @@ class NormalModule extends Module {
|
||||||
|
|
||||||
updateHashWithMeta(hash) {
|
updateHashWithMeta(hash) {
|
||||||
hash.update("meta");
|
hash.update("meta");
|
||||||
hash.update(JSON.stringify(this.meta));
|
hash.update(JSON.stringify(this.buildMeta));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateHash(hash) {
|
updateHash(hash) {
|
||||||
|
|
|
@ -15,7 +15,6 @@ module.exports = class RawModule extends Module {
|
||||||
this.sourceStr = source;
|
this.sourceStr = source;
|
||||||
this.identifierStr = identifier || this.sourceStr;
|
this.identifierStr = identifier || this.sourceStr;
|
||||||
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
||||||
this.cacheable = true;
|
|
||||||
this.built = false;
|
this.built = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +36,10 @@ module.exports = class RawModule extends Module {
|
||||||
|
|
||||||
build(options, compilations, resolver, fs, callback) {
|
build(options, compilations, resolver, fs, callback) {
|
||||||
this.built = true;
|
this.built = true;
|
||||||
|
this.buildMeta = {};
|
||||||
|
this.buildInfo = {
|
||||||
|
cacheable: true
|
||||||
|
};
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,7 @@ class Stats {
|
||||||
index: module.index,
|
index: module.index,
|
||||||
index2: module.index2,
|
index2: module.index2,
|
||||||
size: module.size(),
|
size: module.size(),
|
||||||
cacheable: module.cacheable,
|
cacheable: module.buildInfo.cacheable,
|
||||||
built: !!module.built,
|
built: !!module.built,
|
||||||
optional: module.optional,
|
optional: module.optional,
|
||||||
prefetched: module.prefetched,
|
prefetched: module.prefetched,
|
||||||
|
|
|
@ -25,7 +25,7 @@ class UseStrictPlugin {
|
||||||
const dep = new ConstDependency("", firstNode.range);
|
const dep = new ConstDependency("", firstNode.range);
|
||||||
dep.loc = firstNode.loc;
|
dep.loc = firstNode.loc;
|
||||||
parserInstance.state.current.addDependency(dep);
|
parserInstance.state.current.addDependency(dep);
|
||||||
parserInstance.state.module.strict = true;
|
parserInstance.state.module.buildInfo.strict = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -96,9 +96,9 @@ class AMDRequireDependenciesBlockParserPlugin {
|
||||||
if(param.string === "require") {
|
if(param.string === "require") {
|
||||||
dep = new ConstDependency("__webpack_require__", param.string);
|
dep = new ConstDependency("__webpack_require__", param.string);
|
||||||
} else if(param.string === "module") {
|
} else if(param.string === "module") {
|
||||||
dep = new ConstDependency(parser.state.module.moduleArgument, param.range);
|
dep = new ConstDependency(parser.state.module.buildInfo.moduleArgument, param.range);
|
||||||
} else if(param.string === "exports") {
|
} else if(param.string === "exports") {
|
||||||
dep = new ConstDependency(parser.state.module.exportsArgument, param.range);
|
dep = new ConstDependency(parser.state.module.buildInfo.exportsArgument, param.range);
|
||||||
} else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string)) { // eslint-disable-line no-cond-assign
|
} else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string)) { // eslint-disable-line no-cond-assign
|
||||||
dep = new LocalModuleDependency(localModule, param.range);
|
dep = new LocalModuleDependency(localModule, param.range);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -43,25 +43,25 @@ module.exports = class HarmonyDetectionParserPlugin {
|
||||||
};
|
};
|
||||||
module.addDependency(initDep);
|
module.addDependency(initDep);
|
||||||
parser.state.harmonyParserScope = parser.state.harmonyParserScope || {};
|
parser.state.harmonyParserScope = parser.state.harmonyParserScope || {};
|
||||||
module.meta.harmonyModule = true;
|
module.buildMeta.harmonyModule = true;
|
||||||
module.strict = true;
|
module.buildInfo.strict = true;
|
||||||
module.exportsArgument = "__webpack_exports__";
|
module.buildInfo.exportsArgument = "__webpack_exports__";
|
||||||
if(isStrictHarmony) {
|
if(isStrictHarmony) {
|
||||||
module.meta.strictHarmonyModule = true;
|
module.buildMeta.strictHarmonyModule = true;
|
||||||
module.moduleArgument = "__webpack_module__";
|
module.buildInfo.moduleArgument = "__webpack_module__";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const skipInHarmony = () => {
|
const skipInHarmony = () => {
|
||||||
const module = parser.state.module;
|
const module = parser.state.module;
|
||||||
if(module && module.meta && module.meta.harmonyModule)
|
if(module && module.buildMeta && module.buildMeta.harmonyModule)
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const nullInHarmony = () => {
|
const nullInHarmony = () => {
|
||||||
const module = parser.state.module;
|
const module = parser.state.module;
|
||||||
if(module && module.meta && module.meta.harmonyModule)
|
if(module && module.buildMeta && module.buildMeta.harmonyModule)
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const isNotAHarmonyModule = importedModule.meta && !importedModule.meta.harmonyModule;
|
const isNotAHarmonyModule = importedModule.buildMeta && !importedModule.buildMeta.harmonyModule;
|
||||||
const strictHarmonyModule = this.originModule.meta.strictHarmonyModule;
|
const strictHarmonyModule = this.originModule.buildMeta.strictHarmonyModule;
|
||||||
if(name && id === "default" && isNotAHarmonyModule) {
|
if(name && id === "default" && isNotAHarmonyModule) {
|
||||||
if(strictHarmonyModule) {
|
if(strictHarmonyModule) {
|
||||||
return {
|
return {
|
||||||
|
@ -269,14 +269,14 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||||
}
|
}
|
||||||
|
|
||||||
getWarnings() {
|
getWarnings() {
|
||||||
if(this.strictExportPresence || this.originModule.meta.strictHarmonyModule) {
|
if(this.strictExportPresence || this.originModule.buildMeta.strictHarmonyModule) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return this._getErrors();
|
return this._getErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
getErrors() {
|
getErrors() {
|
||||||
if(this.strictExportPresence || this.originModule.meta.strictHarmonyModule) {
|
if(this.strictExportPresence || this.originModule.buildMeta.strictHarmonyModule) {
|
||||||
return this._getErrors();
|
return this._getErrors();
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
@ -288,9 +288,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!importedModule.meta || !importedModule.meta.harmonyModule) {
|
if(!importedModule.buildMeta || !importedModule.buildMeta.harmonyModule) {
|
||||||
// It's not an harmony module
|
// It's not an harmony module
|
||||||
if(this.originModule.meta.strictHarmonyModule && this.id !== "default") {
|
if(this.originModule.buildMeta.strictHarmonyModule && this.id !== "default") {
|
||||||
// In strict harmony modules we only support the default export
|
// In strict harmony modules we only support the default export
|
||||||
const exportName = this.id ? `the named export '${this.id}'` : "the namespace object";
|
const exportName = this.id ? `the named export '${this.id}'` : "the namespace object";
|
||||||
const err = new Error(`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`);
|
const err = new Error(`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`);
|
||||||
|
|
|
@ -48,9 +48,9 @@ class HarmonyImportDependency extends ModuleDependency {
|
||||||
const importVar = this.getImportVar();
|
const importVar = this.getImportVar();
|
||||||
|
|
||||||
if(importVar) {
|
if(importVar) {
|
||||||
const isHarmonyModule = module.meta && module.meta.harmonyModule;
|
const isHarmonyModule = module.buildMeta && module.buildMeta.harmonyModule;
|
||||||
const content = `/* harmony import */ ${optDeclaration}${importVar} = __webpack_require__(${comment}${JSON.stringify(module.id)});${optNewline}`;
|
const content = `/* harmony import */ ${optDeclaration}${importVar} = __webpack_require__(${comment}${JSON.stringify(module.id)});${optNewline}`;
|
||||||
if(isHarmonyModule || this.originModule.meta.strictHarmonyModule) {
|
if(isHarmonyModule || this.originModule.buildMeta.strictHarmonyModule) {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
return `${content}/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/__webpack_require__.n(${importVar});${optNewline}`;
|
return `${content}/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/__webpack_require__.n(${importVar});${optNewline}`;
|
||||||
|
@ -62,7 +62,7 @@ class HarmonyImportDependency extends ModuleDependency {
|
||||||
updateHash(hash) {
|
updateHash(hash) {
|
||||||
super.updateHash(hash);
|
super.updateHash(hash);
|
||||||
const importedModule = this.module;
|
const importedModule = this.module;
|
||||||
hash.update((importedModule && (!importedModule.meta || importedModule.meta.harmonyModule)) + "");
|
hash.update((importedModule && (!importedModule.buildMeta || importedModule.buildMeta.harmonyModule)) + "");
|
||||||
hash.update((importedModule && importedModule.id) + "");
|
hash.update((importedModule && importedModule.id) + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
|
||||||
}
|
}
|
||||||
|
|
||||||
getReference() {
|
getReference() {
|
||||||
if(this.module && this.module.sideEffectFree) return null;
|
if(this.module && this.module.factoryMeta.sideEffectFree) return null;
|
||||||
|
|
||||||
return super.getReference();
|
return super.getReference();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class HarmonyImportSideEffectDependency extends HarmonyImportDependency {
|
||||||
|
|
||||||
HarmonyImportSideEffectDependency.Template = class HarmonyImportSideEffectDependencyTemplate extends HarmonyImportDependency.Template {
|
HarmonyImportSideEffectDependency.Template = class HarmonyImportSideEffectDependencyTemplate extends HarmonyImportDependency.Template {
|
||||||
getHarmonyInitOrder(dep) {
|
getHarmonyInitOrder(dep) {
|
||||||
if(dep.module && dep.module.sideEffectFree) return NaN;
|
if(dep.module && dep.module.factoryMeta.sideEffectFree) return NaN;
|
||||||
return super.getHarmonyInitOrder(dep);
|
return super.getHarmonyInitOrder(dep);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,14 +31,14 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
||||||
}
|
}
|
||||||
|
|
||||||
getWarnings() {
|
getWarnings() {
|
||||||
if(this.strictExportPresence || this.originModule.meta.strictHarmonyModule) {
|
if(this.strictExportPresence || this.originModule.buildMeta.strictHarmonyModule) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return this._getErrors();
|
return this._getErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
getErrors() {
|
getErrors() {
|
||||||
if(this.strictExportPresence || this.originModule.meta.strictHarmonyModule) {
|
if(this.strictExportPresence || this.originModule.buildMeta.strictHarmonyModule) {
|
||||||
return this._getErrors();
|
return this._getErrors();
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
@ -50,9 +50,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!importedModule.meta || !importedModule.meta.harmonyModule) {
|
if(!importedModule.buildMeta || !importedModule.buildMeta.harmonyModule) {
|
||||||
// It's not an harmony module
|
// It's not an harmony module
|
||||||
if(this.originModule.meta.strictHarmonyModule && this.id !== "default") {
|
if(this.originModule.buildMeta.strictHarmonyModule && this.id !== "default") {
|
||||||
// In strict harmony modules we only support the default export
|
// In strict harmony modules we only support the default export
|
||||||
const exportName = this.id ? `the named export '${this.id}'` : "the namespace object";
|
const exportName = this.id ? `the named export '${this.id}'` : "the namespace object";
|
||||||
const err = new Error(`Can't import ${exportName} from non EcmaScript module (only default export is available)`);
|
const err = new Error(`Can't import ${exportName} from non EcmaScript module (only default export is available)`);
|
||||||
|
@ -89,7 +89,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
||||||
const importedModule = this.module;
|
const importedModule = this.module;
|
||||||
hash.update((importedModule && this.id) + "");
|
hash.update((importedModule && this.id) + "");
|
||||||
hash.update((importedModule && this.id && importedModule.isUsed(this.id)) + "");
|
hash.update((importedModule && this.id && importedModule.isUsed(this.id)) + "");
|
||||||
hash.update((importedModule && (!importedModule.meta || importedModule.meta.harmonyModule)) + "");
|
hash.update((importedModule && (!importedModule.buildMeta || importedModule.buildMeta.harmonyModule)) + "");
|
||||||
hash.update((importedModule && (importedModule.used + JSON.stringify(importedModule.usedExports))) + "");
|
hash.update((importedModule && (importedModule.used + JSON.stringify(importedModule.usedExports))) + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
||||||
|
|
||||||
getContent(dep, importedVar) {
|
getContent(dep, importedVar) {
|
||||||
const importedModule = dep.module;
|
const importedModule = dep.module;
|
||||||
const nonHarmonyImport = !(importedModule && (!importedModule.meta || importedModule.meta.harmonyModule));
|
const nonHarmonyImport = !(importedModule && (!importedModule.buildMeta || importedModule.buildMeta.harmonyModule));
|
||||||
const importedVarSuffix = this.getImportVarSuffix(dep.id, importedModule);
|
const importedVarSuffix = this.getImportVarSuffix(dep.id, importedModule);
|
||||||
const shortHandPrefix = dep.shorthand ? `${dep.name}: ` : "";
|
const shortHandPrefix = dep.shorthand ? `${dep.name}: ` : "";
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
||||||
|
|
||||||
if(nonHarmonyImport) {
|
if(nonHarmonyImport) {
|
||||||
const defaultExport = dep.id === "default";
|
const defaultExport = dep.id === "default";
|
||||||
if(dep.originModule.meta.strictHarmonyModule) {
|
if(dep.originModule.buildMeta.strictHarmonyModule) {
|
||||||
if(defaultExport) {
|
if(defaultExport) {
|
||||||
return `${shortHandPrefix}${importedVar}`;
|
return `${shortHandPrefix}${importedVar}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ ImportDependency.Template = class ImportDependencyTemplate {
|
||||||
|
|
||||||
if(dep.module) {
|
if(dep.module) {
|
||||||
const stringifiedId = JSON.stringify(dep.module.id);
|
const stringifiedId = JSON.stringify(dep.module.id);
|
||||||
if(dep.module.meta && dep.module.meta.harmonyModule) {
|
if(dep.module.buildMeta && dep.module.buildMeta.harmonyModule) {
|
||||||
getModuleFunction = `__webpack_require__.bind(null, ${comment}${stringifiedId})`;
|
getModuleFunction = `__webpack_require__.bind(null, ${comment}${stringifiedId})`;
|
||||||
} else if(dep.originModule.meta.strictHarmonyModule) {
|
} else if(dep.originModule.buildMeta.strictHarmonyModule) {
|
||||||
getModuleFunction = `function() { return /* fake namespace object */ { "default": __webpack_require__(${comment}${stringifiedId}) }; }`;
|
getModuleFunction = `function() { return /* fake namespace object */ { "default": __webpack_require__(${comment}${stringifiedId}) }; }`;
|
||||||
} else {
|
} else {
|
||||||
getModuleFunction = `function() { var module = __webpack_require__(${comment}${stringifiedId}); return typeof module === "object" && module && module.__esModule ? module : /* fake namespace object */ { "default": module }; }`;
|
getModuleFunction = `function() { var module = __webpack_require__(${comment}${stringifiedId}); return typeof module === "object" && module && module.__esModule ? module : /* fake namespace object */ { "default": module }; }`;
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ImportParserPlugin {
|
||||||
include,
|
include,
|
||||||
exclude,
|
exclude,
|
||||||
mode,
|
mode,
|
||||||
namespaceObject: parser.state.module.meta.strictHarmonyModule ? "strict" : true
|
namespaceObject: parser.state.module.buildMeta.strictHarmonyModule ? "strict" : true
|
||||||
});
|
});
|
||||||
if(!dep) return;
|
if(!dep) return;
|
||||||
dep.loc = expr.loc;
|
dep.loc = expr.loc;
|
||||||
|
|
|
@ -190,12 +190,17 @@ class ConcatenatedModule extends Module {
|
||||||
this.optimizationBailout = rootModule.optimizationBailout;
|
this.optimizationBailout = rootModule.optimizationBailout;
|
||||||
|
|
||||||
// Info from Build
|
// Info from Build
|
||||||
|
this.buildInfo = {
|
||||||
|
strict: true,
|
||||||
|
cacheable: modules.every(m => m.buildInfo.cacheable),
|
||||||
|
moduleArgument: rootModule.buildInfo.moduleArgument,
|
||||||
|
exportsArgument: rootModule.buildInfo.exportsArgument,
|
||||||
|
fileDependencies: new Set(),
|
||||||
|
contextDependencies: new Set(),
|
||||||
|
assets: undefined
|
||||||
|
};
|
||||||
this.built = modules.some(m => m.built);
|
this.built = modules.some(m => m.built);
|
||||||
this.cacheable = modules.every(m => m.cacheable);
|
this.buildMeta = rootModule.buildMeta;
|
||||||
this.meta = rootModule.meta;
|
|
||||||
this.moduleArgument = rootModule.moduleArgument;
|
|
||||||
this.exportsArgument = rootModule.exportsArgument;
|
|
||||||
this.strict = true;
|
|
||||||
|
|
||||||
// Caching
|
// Caching
|
||||||
this._numberOfConcatenatedModules = modules.length;
|
this._numberOfConcatenatedModules = modules.length;
|
||||||
|
@ -205,11 +210,9 @@ class ConcatenatedModule extends Module {
|
||||||
this.reasons = rootModule.reasons.filter(reason => !(reason.dependency instanceof HarmonyImportDependency) || !modulesSet.has(reason.module));
|
this.reasons = rootModule.reasons.filter(reason => !(reason.dependency instanceof HarmonyImportDependency) || !modulesSet.has(reason.module));
|
||||||
|
|
||||||
this.dependencies = [];
|
this.dependencies = [];
|
||||||
this.fileDependencies = new Set();
|
|
||||||
this.contextDependencies = new Set();
|
|
||||||
this.warnings = [];
|
this.warnings = [];
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
this.assets = undefined;
|
|
||||||
this._orderedConcatenationList = this._createOrderedConcatenationList(rootModule, modulesSet);
|
this._orderedConcatenationList = this._createOrderedConcatenationList(rootModule, modulesSet);
|
||||||
for(const info of this._orderedConcatenationList) {
|
for(const info of this._orderedConcatenationList) {
|
||||||
if(info.type === "concatenated") {
|
if(info.type === "concatenated") {
|
||||||
|
@ -219,18 +222,18 @@ class ConcatenatedModule extends Module {
|
||||||
m.dependencies.filter(dep => !(dep instanceof HarmonyImportDependency) || !modulesSet.has(dep.module))
|
m.dependencies.filter(dep => !(dep instanceof HarmonyImportDependency) || !modulesSet.has(dep.module))
|
||||||
.forEach(d => this.dependencies.push(d));
|
.forEach(d => this.dependencies.push(d));
|
||||||
// populate file dependencies
|
// populate file dependencies
|
||||||
if(m.fileDependencies) m.fileDependencies.forEach(file => this.fileDependencies.add(file));
|
if(m.buildInfo.fileDependencies) m.buildInfo.fileDependencies.forEach(file => this.buildInfo.fileDependencies.add(file));
|
||||||
// populate context dependencies
|
// populate context dependencies
|
||||||
if(m.contextDependencies) m.contextDependencies.forEach(context => this.contextDependencies.add(context));
|
if(m.buildInfo.contextDependencies) m.buildInfo.contextDependencies.forEach(context => this.buildInfo.contextDependencies.add(context));
|
||||||
// populate warnings
|
// populate warnings
|
||||||
m.warnings.forEach(warning => this.warnings.push(warning));
|
m.warnings.forEach(warning => this.warnings.push(warning));
|
||||||
// populate errors
|
// populate errors
|
||||||
m.errors.forEach(error => this.errors.push(error));
|
m.errors.forEach(error => this.errors.push(error));
|
||||||
|
|
||||||
if(m.assets) {
|
if(m.buildInfo.assets) {
|
||||||
if(this.assets === undefined)
|
if(this.buildInfo.assets === undefined)
|
||||||
this.assets = Object.create(null);
|
this.buildInfo.assets = Object.create(null);
|
||||||
Object.assign(this.assets, m.assets);
|
Object.assign(this.buildInfo.assets, m.buildInfo.assets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +581,7 @@ class ConcatenatedModule extends Module {
|
||||||
}
|
}
|
||||||
case "external":
|
case "external":
|
||||||
{
|
{
|
||||||
info.interop = info.module.meta && !info.module.meta.harmonyModule;
|
info.interop = info.module.buildMeta && !info.module.buildMeta.harmonyModule;
|
||||||
const externalName = this.findNewName("", allUsedNames, null, info.module.readableIdentifier(requestShortener));
|
const externalName = this.findNewName("", allUsedNames, null, info.module.readableIdentifier(requestShortener));
|
||||||
allUsedNames.add(externalName);
|
allUsedNames.add(externalName);
|
||||||
info.name = externalName;
|
info.name = externalName;
|
||||||
|
@ -729,7 +732,7 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate {
|
||||||
}
|
}
|
||||||
let content;
|
let content;
|
||||||
const callFlag = dep.call ? "_call" : "";
|
const callFlag = dep.call ? "_call" : "";
|
||||||
const strictFlag = dep.originModule.meta.strictHarmonyModule ? "_strict" : "";
|
const strictFlag = dep.originModule.buildMeta.strictHarmonyModule ? "_strict" : "";
|
||||||
if(dep.id === null) {
|
if(dep.id === null) {
|
||||||
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
||||||
} else if(dep.namespaceObjectAsContext) {
|
} else if(dep.namespaceObjectAsContext) {
|
||||||
|
@ -894,7 +897,7 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
|
||||||
source.insert(-1, `/* unused concated harmony import ${dep.name} */\n`);
|
source.insert(-1, `/* unused concated harmony import ${dep.name} */\n`);
|
||||||
}
|
}
|
||||||
let finalName;
|
let finalName;
|
||||||
const strictFlag = dep.originModule.meta.strictHarmonyModule ? "_strict" : "";
|
const strictFlag = dep.originModule.buildMeta.strictHarmonyModule ? "_strict" : "";
|
||||||
if(def.id === true) {
|
if(def.id === true) {
|
||||||
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ModuleConcatenationPlugin {
|
||||||
}) => {
|
}) => {
|
||||||
normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => {
|
normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => {
|
||||||
parser.plugin("call eval", () => {
|
parser.plugin("call eval", () => {
|
||||||
parser.state.module.meta.hasEval = true;
|
parser.state.module.buildMeta.hasEval = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const bailoutReasonMap = new Map();
|
const bailoutReasonMap = new Map();
|
||||||
|
@ -48,13 +48,13 @@ class ModuleConcatenationPlugin {
|
||||||
const possibleInners = new Set();
|
const possibleInners = new Set();
|
||||||
for(const module of modules) {
|
for(const module of modules) {
|
||||||
// Only harmony modules are valid for optimization
|
// Only harmony modules are valid for optimization
|
||||||
if(!module.meta || !module.meta.harmonyModule || !module.dependencies.some(d => d instanceof HarmonyCompatibilityDependency)) {
|
if(!module.buildMeta || !module.buildMeta.harmonyModule || !module.dependencies.some(d => d instanceof HarmonyCompatibilityDependency)) {
|
||||||
setBailoutReason(module, "Module is not an ECMAScript module");
|
setBailoutReason(module, "Module is not an ECMAScript module");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because of variable renaming we can't use modules with eval
|
// Because of variable renaming we can't use modules with eval
|
||||||
if(module.meta && module.meta.hasEval) {
|
if(module.buildMeta && module.buildMeta.hasEval) {
|
||||||
setBailoutReason(module, "Module uses eval()");
|
setBailoutReason(module, "Module uses eval()");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ class ModuleConcatenationPlugin {
|
||||||
for(const reason of module.reasons) {
|
for(const reason of module.reasons) {
|
||||||
|
|
||||||
// Modules that are not used can be ignored
|
// Modules that are not used can be ignored
|
||||||
if(reason.module.sideEffectFree && reason.module.used === false) continue;
|
if(reason.module.factoryMeta.sideEffectFree && reason.module.used === false) continue;
|
||||||
|
|
||||||
const problem = this.tryToAdd(testConfig, reason.module, possibleModules, failureCache);
|
const problem = this.tryToAdd(testConfig, reason.module, possibleModules, failureCache);
|
||||||
if(problem) {
|
if(problem) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ class SideEffectsFlagPlugin {
|
||||||
const sideEffects = resolveData.descriptionFileData.sideEffects;
|
const sideEffects = resolveData.descriptionFileData.sideEffects;
|
||||||
const isSideEffectFree = sideEffects === false; // TODO allow more complex expressions
|
const isSideEffectFree = sideEffects === false; // TODO allow more complex expressions
|
||||||
if(isSideEffectFree) {
|
if(isSideEffectFree) {
|
||||||
module.sideEffectFree = true;
|
module.factoryMeta.sideEffectFree = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ class SideEffectsFlagPlugin {
|
||||||
const removeDependencies = [];
|
const removeDependencies = [];
|
||||||
for(const dep of module.dependencies) {
|
for(const dep of module.dependencies) {
|
||||||
if(dep instanceof HarmonyImportSideEffectDependency) {
|
if(dep instanceof HarmonyImportSideEffectDependency) {
|
||||||
if(dep.module && dep.module.sideEffectFree) {
|
if(dep.module && dep.module.factoryMeta.sideEffectFree) {
|
||||||
removeDependencies.push(dep);
|
removeDependencies.push(dep);
|
||||||
}
|
}
|
||||||
} else if(dep instanceof HarmonyExportImportedSpecifierDependency) {
|
} else if(dep instanceof HarmonyExportImportedSpecifierDependency) {
|
||||||
if(module.sideEffectFree) {
|
if(module.factoryMeta.sideEffectFree) {
|
||||||
const mode = dep.getMode(true);
|
const mode = dep.getMode(true);
|
||||||
if(mode.type === "safe-reexport") {
|
if(mode.type === "safe-reexport") {
|
||||||
let map = reexportMaps.get(module);
|
let map = reexportMaps.get(module);
|
||||||
|
|
|
@ -7,7 +7,7 @@ module.exports = {
|
||||||
content: {
|
content: {
|
||||||
"./module": {
|
"./module": {
|
||||||
id: 1,
|
id: 1,
|
||||||
meta: {
|
buildMeta: {
|
||||||
harmonyModule: true
|
harmonyModule: true
|
||||||
},
|
},
|
||||||
exports: ["default"]
|
exports: ["default"]
|
||||||
|
|
|
@ -7,7 +7,7 @@ module.exports = {
|
||||||
content: {
|
content: {
|
||||||
"./module": {
|
"./module": {
|
||||||
id: 1,
|
id: 1,
|
||||||
meta: {
|
buildMeta: {
|
||||||
harmonyModule: true
|
harmonyModule: true
|
||||||
},
|
},
|
||||||
exports: ["default"]
|
exports: ["default"]
|
||||||
|
|
Loading…
Reference in New Issue