webpack 5.100.1 → 5.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/bin/webpack.js +7 -7
- package/lib/APIPlugin.js +12 -14
- package/lib/AutomaticPrefetchPlugin.js +2 -2
- package/lib/BannerPlugin.js +4 -4
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +7 -7
- package/lib/CaseSensitiveModulesWarning.js +2 -2
- package/lib/Chunk.js +3 -3
- package/lib/ChunkGraph.js +21 -18
- package/lib/ChunkGroup.js +4 -4
- package/lib/CleanPlugin.js +19 -53
- package/lib/CodeGenerationResults.js +3 -3
- package/lib/CompatibilityPlugin.js +6 -6
- package/lib/Compilation.js +127 -114
- package/lib/Compiler.js +37 -37
- package/lib/ConcatenationScope.js +39 -1
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +12 -11
- package/lib/ContextModuleFactory.js +11 -11
- package/lib/ContextReplacementPlugin.js +5 -5
- package/lib/DefinePlugin.js +24 -22
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/DllEntryPlugin.js +1 -1
- package/lib/DllReferencePlugin.js +1 -1
- package/lib/DynamicEntryPlugin.js +3 -3
- package/lib/EntryPlugin.js +1 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +2 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -5
- package/lib/ExportsInfo.js +9 -9
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +163 -48
- package/lib/ExternalModuleFactoryPlugin.js +2 -2
- package/lib/ExternalsPlugin.js +45 -0
- package/lib/FileSystemInfo.js +64 -61
- package/lib/FlagAllModulesAsUsedPlugin.js +2 -2
- package/lib/FlagDependencyExportsPlugin.js +7 -7
- package/lib/FlagDependencyUsagePlugin.js +4 -4
- package/lib/FlagEntryExportAsUsedPlugin.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +27 -27
- package/lib/IgnorePlugin.js +3 -3
- package/lib/IgnoreWarningsPlugin.js +4 -4
- package/lib/InitFragment.js +6 -0
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +1 -1
- package/lib/LibManifestPlugin.js +2 -2
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/LoaderTargetPlugin.js +2 -2
- package/lib/MainTemplate.js +1 -1
- package/lib/Module.js +1 -1
- package/lib/ModuleFilenameHelpers.js +3 -3
- package/lib/ModuleGraph.js +86 -5
- package/lib/ModuleInfoHeaderPlugin.js +3 -3
- package/lib/ModuleParseError.js +5 -3
- package/lib/MultiCompiler.js +29 -24
- package/lib/MultiStats.js +18 -13
- package/lib/MultiWatching.js +1 -1
- package/lib/NoEmitOnErrorsPlugin.js +2 -2
- package/lib/NodeStuffPlugin.js +27 -15
- package/lib/NormalModule.js +28 -24
- package/lib/NormalModuleFactory.js +23 -21
- package/lib/NormalModuleReplacementPlugin.js +3 -3
- package/lib/PrefetchPlugin.js +1 -1
- package/lib/ProgressPlugin.js +11 -11
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/ResolverFactory.js +3 -3
- package/lib/RuntimeGlobals.js +20 -0
- package/lib/RuntimePlugin.js +16 -16
- package/lib/RuntimeTemplate.js +42 -44
- package/lib/SizeFormatHelpers.js +1 -1
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +4 -4
- package/lib/SourceMapDevToolPlugin.js +9 -9
- package/lib/Stats.js +2 -2
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +2 -2
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WarnCaseSensitiveModulesPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +1 -1
- package/lib/WatchIgnorePlugin.js +2 -2
- package/lib/Watching.js +12 -12
- package/lib/WebpackIsIncludedPlugin.js +2 -2
- package/lib/WebpackOptionsApply.js +10 -3
- package/lib/asset/AssetGenerator.js +3 -3
- package/lib/asset/AssetModulesPlugin.js +6 -6
- package/lib/async-modules/AsyncModuleHelpers.js +50 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +36 -24
- package/lib/async-modules/InferAsyncModulesPlugin.js +3 -3
- package/lib/buildChunkGraph.js +5 -5
- package/lib/cache/AddBuildDependenciesPlugin.js +1 -1
- package/lib/cache/IdleFileCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +20 -20
- package/lib/cache/ResolverCachePlugin.js +4 -4
- package/lib/cli.js +196 -14
- package/lib/config/browserslistTargetHandler.js +6 -6
- package/lib/config/defaults.js +23 -14
- package/lib/config/normalization.js +41 -38
- package/lib/config/target.js +4 -4
- package/lib/container/ContainerEntryModule.js +3 -3
- package/lib/container/ContainerPlugin.js +3 -3
- package/lib/container/ContainerReferencePlugin.js +3 -3
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/HoistContainerReferencesPlugin.js +7 -7
- package/lib/container/options.js +4 -4
- package/lib/css/CssGenerator.js +5 -3
- package/lib/css/CssLoadingRuntimeModule.js +1 -1
- package/lib/css/CssModulesPlugin.js +25 -22
- package/lib/css/CssParser.js +5 -5
- package/lib/css/walkCssTokens.js +9 -9
- package/lib/debug/ProfilingPlugin.js +5 -5
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +4 -4
- package/lib/dependencies/AMDPlugin.js +3 -3
- package/lib/dependencies/AMDRequireArrayDependency.js +1 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +3 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +2 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +21 -19
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CssIcssExportDependency.js +2 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +4 -4
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/HarmonyAcceptDependency.js +39 -5
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +2 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +17 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +7 -8
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyExports.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +28 -9
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +59 -75
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -5
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +3 -4
- package/lib/dependencies/HarmonyModulesPlugin.js +2 -8
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -4
- package/lib/dependencies/ImportMetaPlugin.js +7 -7
- package/lib/dependencies/ImportParserPlugin.js +4 -4
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +4 -4
- package/lib/dependencies/ProvidedDependency.js +2 -2
- package/lib/dependencies/PureExpressionDependency.js +1 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -3
- package/lib/dependencies/SystemPlugin.js +3 -3
- package/lib/dependencies/WorkerPlugin.js +5 -5
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -5
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -2
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +15 -11
- package/lib/formatLocation.js +2 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +39 -27
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +43 -32
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +1 -1
- package/lib/hmr/LazyCompilationPlugin.js +6 -6
- package/lib/hmr/lazyCompilationBackend.js +6 -6
- package/lib/ids/ChunkModuleIdRangePlugin.js +4 -4
- package/lib/ids/DeterministicChunkIdsPlugin.js +5 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +2 -2
- package/lib/ids/HashedModuleIdsPlugin.js +1 -1
- package/lib/ids/IdHelpers.js +9 -9
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +2 -2
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -2
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +2 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -4
- package/lib/ids/SyncModuleIdsPlugin.js +4 -4
- package/lib/index.js +10 -6
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
- package/lib/javascript/BasicEvaluatedExpression.js +3 -3
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +1 -1
- package/lib/javascript/JavascriptModulesPlugin.js +16 -16
- package/lib/javascript/JavascriptParser.js +90 -83
- package/lib/javascript/JavascriptParserHelpers.js +3 -3
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +2 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/library/AbstractLibraryPlugin.js +3 -3
- package/lib/library/AmdLibraryPlugin.js +3 -3
- package/lib/library/AssignLibraryPlugin.js +2 -2
- package/lib/library/EnableLibraryPlugin.js +2 -2
- package/lib/library/ModuleLibraryPlugin.js +7 -2
- package/lib/library/SystemLibraryPlugin.js +6 -4
- package/lib/library/UmdLibraryPlugin.js +14 -14
- package/lib/logging/createConsoleLogger.js +4 -4
- package/lib/logging/runtime.js +3 -3
- package/lib/logging/truncateArgs.js +4 -4
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -2
- package/lib/node/NodeEnvironmentPlugin.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +16 -14
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +7 -7
- package/lib/node/ReadFileCompileWasmPlugin.js +7 -7
- package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -4
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveMergingPlugin.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +10 -10
- package/lib/optimize/ConcatenatedModule.js +161 -52
- package/lib/optimize/EnsureChunkConditionsPlugin.js +2 -2
- package/lib/optimize/FlagIncludedChunksPlugin.js +2 -2
- package/lib/optimize/InnerGraph.js +5 -5
- package/lib/optimize/InnerGraphPlugin.js +14 -12
- package/lib/optimize/LimitChunkCountPlugin.js +5 -5
- package/lib/optimize/MangleExportsPlugin.js +5 -5
- package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
- package/lib/optimize/MinChunkSizePlugin.js +3 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +45 -38
- package/lib/optimize/RealContentHashPlugin.js +23 -23
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -2
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/RuntimeChunkPlugin.js +2 -2
- package/lib/optimize/SideEffectsFlagPlugin.js +22 -6
- package/lib/optimize/SplitChunksPlugin.js +20 -20
- package/lib/performance/AssetsOverSizeLimitWarning.js +1 -1
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/SizeLimitsPlugin.js +4 -4
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +3 -3
- package/lib/rules/BasicMatcherRulePlugin.js +1 -1
- package/lib/rules/RuleSetCompiler.js +10 -10
- package/lib/rules/UseEffectRulePlugin.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +15 -15
- package/lib/runtime/GetMainFilenameRuntimeModule.js +1 -1
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/StartupChunkDependenciesPlugin.js +2 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -3
- package/lib/schemes/DataUriPlugin.js +3 -3
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +40 -36
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +11 -11
- package/lib/serialization/FileMiddleware.js +17 -17
- package/lib/serialization/ObjectMiddleware.js +8 -8
- package/lib/serialization/Serializer.js +2 -2
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -4
- package/lib/sharing/ProvideSharedPlugin.js +4 -4
- package/lib/sharing/SharePlugin.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +86 -80
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -15
- package/lib/stats/DefaultStatsPrinterPlugin.js +87 -87
- package/lib/stats/StatsFactory.js +7 -7
- package/lib/stats/StatsPrinter.js +9 -9
- package/lib/url/URLParserPlugin.js +5 -5
- package/lib/util/AsyncQueue.js +4 -4
- package/lib/util/IterableHelpers.js +2 -2
- package/lib/util/LazyBucketSortedSet.js +3 -3
- package/lib/util/SetHelpers.js +2 -2
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/StackedMap.js +1 -1
- package/lib/util/TupleSet.js +1 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/cleverMerge.js +8 -8
- package/lib/util/comparators.js +107 -8
- package/lib/util/compileBooleanMatcher.js +20 -20
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +4 -4
- package/lib/util/create-schema-validation.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/deprecation.js +4 -4
- package/lib/util/deterministicGrouping.js +7 -7
- package/lib/util/findGraphRoots.js +1 -1
- package/lib/util/fs.js +3 -3
- package/lib/util/identifier.js +14 -14
- package/lib/util/magicComment.js +5 -1
- package/lib/util/memoize.js +1 -1
- package/lib/util/processAsyncTree.js +2 -2
- package/lib/util/propertyName.js +1 -1
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +6 -6
- package/lib/util/semver.js +16 -16
- package/lib/util/serialization.js +5 -5
- package/lib/util/smartGrouping.js +1 -1
- package/lib/validateSchema.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +1 -1
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +1 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +4 -4
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +13 -9
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -14
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +4 -2
- package/lib/wasm-sync/WebAssemblyParser.js +2 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +4 -4
- package/lib/web/FetchCompileWasmPlugin.js +4 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/webpack.js +17 -12
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -2
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +4 -0
- package/types.d.ts +186 -54
|
@@ -62,7 +62,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
|
62
62
|
apply(parser) {
|
|
63
63
|
parser.hooks.evaluateIdentifier
|
|
64
64
|
.for("import.meta.webpackContext")
|
|
65
|
-
.tap(PLUGIN_NAME, expr =>
|
|
65
|
+
.tap(PLUGIN_NAME, (expr) =>
|
|
66
66
|
evaluateToIdentifier(
|
|
67
67
|
"import.meta.webpackContext",
|
|
68
68
|
"import.meta",
|
|
@@ -72,7 +72,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
|
72
72
|
);
|
|
73
73
|
parser.hooks.call
|
|
74
74
|
.for("import.meta.webpackContext")
|
|
75
|
-
.tap(PLUGIN_NAME, expr => {
|
|
75
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
76
76
|
if (expr.arguments.length < 1 || expr.arguments.length > 2) return;
|
|
77
77
|
const [directoryNode, optionsNode] = expr.arguments;
|
|
78
78
|
if (optionsNode && optionsNode.type !== "ObjectExpression") return;
|
|
@@ -178,11 +178,11 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|
|
178
178
|
/** @type {BasicEvaluatedExpression[]} */
|
|
179
179
|
(expr.items);
|
|
180
180
|
if (
|
|
181
|
-
items.every(i => {
|
|
181
|
+
items.every((i) => {
|
|
182
182
|
if (!i.isArray()) return false;
|
|
183
183
|
const innerItems =
|
|
184
184
|
/** @type {BasicEvaluatedExpression[]} */ (i.items);
|
|
185
|
-
return innerItems.every(i => i.isString());
|
|
185
|
+
return innerItems.every((i) => i.isString());
|
|
186
186
|
})
|
|
187
187
|
) {
|
|
188
188
|
exports = [];
|
|
@@ -49,7 +49,7 @@ class ImportMetaPlugin {
|
|
|
49
49
|
* @param {NormalModule} module module
|
|
50
50
|
* @returns {string} file url
|
|
51
51
|
*/
|
|
52
|
-
const getUrl = module => pathToFileURL(module.resource).toString();
|
|
52
|
+
const getUrl = (module) => pathToFileURL(module.resource).toString();
|
|
53
53
|
/**
|
|
54
54
|
* @param {Parser} parser parser parser
|
|
55
55
|
* @param {JavascriptParserOptions} parserOptions parserOptions
|
|
@@ -62,7 +62,7 @@ class ImportMetaPlugin {
|
|
|
62
62
|
|
|
63
63
|
parser.hooks.expression
|
|
64
64
|
.for("import.meta")
|
|
65
|
-
.tap(PLUGIN_NAME, metaProperty => {
|
|
65
|
+
.tap(PLUGIN_NAME, (metaProperty) => {
|
|
66
66
|
const dep = new ConstDependency(
|
|
67
67
|
/** @type {string} */ (importMetaName),
|
|
68
68
|
/** @type {Range} */ (metaProperty.range)
|
|
@@ -86,7 +86,7 @@ class ImportMetaPlugin {
|
|
|
86
86
|
* @param {string[]} members members
|
|
87
87
|
* @returns {string} error message
|
|
88
88
|
*/
|
|
89
|
-
const importMetaUnknownProperty = members =>
|
|
89
|
+
const importMetaUnknownProperty = (members) =>
|
|
90
90
|
`${Template.toNormalComment(
|
|
91
91
|
`unsupported import.meta.${members.join(".")}`
|
|
92
92
|
)} undefined${propertyAccess(members, 1)}`;
|
|
@@ -98,7 +98,7 @@ class ImportMetaPlugin {
|
|
|
98
98
|
);
|
|
99
99
|
parser.hooks.expression
|
|
100
100
|
.for("import.meta")
|
|
101
|
-
.tap(PLUGIN_NAME, metaProperty => {
|
|
101
|
+
.tap(PLUGIN_NAME, (metaProperty) => {
|
|
102
102
|
const referencedPropertiesInDestructuring =
|
|
103
103
|
parser.destructuringAssignmentPropertiesFor(metaProperty);
|
|
104
104
|
if (!referencedPropertiesInDestructuring) {
|
|
@@ -169,7 +169,7 @@ class ImportMetaPlugin {
|
|
|
169
169
|
);
|
|
170
170
|
parser.hooks.expression
|
|
171
171
|
.for("import.meta.url")
|
|
172
|
-
.tap(PLUGIN_NAME, expr => {
|
|
172
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
173
173
|
const dep = new ConstDependency(
|
|
174
174
|
importMetaUrl(),
|
|
175
175
|
/** @type {Range} */ (expr.range)
|
|
@@ -183,7 +183,7 @@ class ImportMetaPlugin {
|
|
|
183
183
|
.tap(PLUGIN_NAME, evaluateToString("string"));
|
|
184
184
|
parser.hooks.evaluateIdentifier
|
|
185
185
|
.for("import.meta.url")
|
|
186
|
-
.tap(PLUGIN_NAME, expr =>
|
|
186
|
+
.tap(PLUGIN_NAME, (expr) =>
|
|
187
187
|
new BasicEvaluatedExpression()
|
|
188
188
|
.setString(getUrl(parser.state.module))
|
|
189
189
|
.setRange(/** @type {Range} */ (expr.range))
|
|
@@ -223,7 +223,7 @@ class ImportMetaPlugin {
|
|
|
223
223
|
});
|
|
224
224
|
parser.hooks.evaluate
|
|
225
225
|
.for("MemberExpression")
|
|
226
|
-
.tap(PLUGIN_NAME, expression => {
|
|
226
|
+
.tap(PLUGIN_NAME, (expression) => {
|
|
227
227
|
const expr = /** @type {MemberExpression} */ (expression);
|
|
228
228
|
if (
|
|
229
229
|
expr.object.type === "MetaProperty" &&
|
|
@@ -44,9 +44,9 @@ class ImportParserPlugin {
|
|
|
44
44
|
* @param {Iterable<T>} enumerable enumerable
|
|
45
45
|
* @returns {T[][]} array of array
|
|
46
46
|
*/
|
|
47
|
-
const exportsFromEnumerable = enumerable =>
|
|
48
|
-
Array.from(enumerable, e => [e]);
|
|
49
|
-
parser.hooks.importCall.tap(PLUGIN_NAME, expr => {
|
|
47
|
+
const exportsFromEnumerable = (enumerable) =>
|
|
48
|
+
Array.from(enumerable, (e) => [e]);
|
|
49
|
+
parser.hooks.importCall.tap(PLUGIN_NAME, (expr) => {
|
|
50
50
|
const param = parser.evaluateExpression(expr.source);
|
|
51
51
|
|
|
52
52
|
let chunkName = null;
|
|
@@ -240,7 +240,7 @@ class ImportParserPlugin {
|
|
|
240
240
|
typeof importOptions.webpackExports === "string" ||
|
|
241
241
|
(Array.isArray(importOptions.webpackExports) &&
|
|
242
242
|
/** @type {string[]} */ (importOptions.webpackExports).every(
|
|
243
|
-
item => typeof item === "string"
|
|
243
|
+
(item) => typeof item === "string"
|
|
244
244
|
))
|
|
245
245
|
)
|
|
246
246
|
) {
|
|
@@ -30,7 +30,7 @@ const NullDependency = require("./NullDependency");
|
|
|
30
30
|
* @param {number} exportsDepth exportsDepth
|
|
31
31
|
* @returns {GetExportsFromDataFn} value
|
|
32
32
|
*/
|
|
33
|
-
const getExportsWithDepth = exportsDepth =>
|
|
33
|
+
const getExportsWithDepth = (exportsDepth) =>
|
|
34
34
|
/** @type {GetExportsFromDataFn} */
|
|
35
35
|
function getExportsFromData(data, curDepth = 1) {
|
|
36
36
|
if (curDepth > exportsDepth) {
|
|
@@ -54,11 +54,11 @@ class LoaderPlugin {
|
|
|
54
54
|
}
|
|
55
55
|
);
|
|
56
56
|
|
|
57
|
-
compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
|
|
57
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
58
58
|
const moduleGraph = compilation.moduleGraph;
|
|
59
59
|
NormalModule.getCompilationHooks(compilation).loader.tap(
|
|
60
60
|
PLUGIN_NAME,
|
|
61
|
-
loaderContext => {
|
|
61
|
+
(loaderContext) => {
|
|
62
62
|
loaderContext.loadModule = (request, callback) => {
|
|
63
63
|
const dep = new LoaderDependency(request);
|
|
64
64
|
dep.loc = {
|
|
@@ -91,7 +91,7 @@ class LoaderPlugin {
|
|
|
91
91
|
context: loaderContext.context,
|
|
92
92
|
recursive: false
|
|
93
93
|
},
|
|
94
|
-
err => {
|
|
94
|
+
(err) => {
|
|
95
95
|
compilation.factorizeQueue.setContext(oldFactorizeQueueContext);
|
|
96
96
|
compilation.addModuleQueue.setContext(oldAddModuleQueueContext);
|
|
97
97
|
compilation.buildQueue.decreaseParallelism();
|
|
@@ -196,7 +196,7 @@ class LoaderPlugin {
|
|
|
196
196
|
connectOrigin: false,
|
|
197
197
|
checkCycle: true
|
|
198
198
|
},
|
|
199
|
-
err => {
|
|
199
|
+
(err) => {
|
|
200
200
|
compilation.factorizeQueue.setContext(oldFactorizeQueueContext);
|
|
201
201
|
compilation.addModuleQueue.setContext(oldAddModuleQueueContext);
|
|
202
202
|
compilation.buildQueue.decreaseParallelism();
|
|
@@ -29,9 +29,9 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
29
29
|
* @param {string[]|null} path the property path array
|
|
30
30
|
* @returns {string} the converted path
|
|
31
31
|
*/
|
|
32
|
-
const pathToString = path =>
|
|
32
|
+
const pathToString = (path) =>
|
|
33
33
|
path !== null && path.length > 0
|
|
34
|
-
? path.map(part => `[${JSON.stringify(part)}]`).join("")
|
|
34
|
+
? path.map((part) => `[${JSON.stringify(part)}]`).join("")
|
|
35
35
|
: "";
|
|
36
36
|
|
|
37
37
|
class ProvidedDependency extends ModuleDependency {
|
|
@@ -47,7 +47,7 @@ class PureExpressionDependency extends NullDependency {
|
|
|
47
47
|
/** @type {Module} */
|
|
48
48
|
(moduleGraph.getParentModule(this));
|
|
49
49
|
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
|
50
|
-
const runtimeCondition = filterRuntime(runtime, runtime => {
|
|
50
|
+
const runtimeCondition = filterRuntime(runtime, (runtime) => {
|
|
51
51
|
for (const exportName of usedByExports) {
|
|
52
52
|
if (exportsInfo.getUsed(exportName, runtime) !== UsageState.Unused) {
|
|
53
53
|
return true;
|
|
@@ -20,7 +20,7 @@ module.exports = class RequireContextDependencyParserPlugin {
|
|
|
20
20
|
* @returns {void}
|
|
21
21
|
*/
|
|
22
22
|
apply(parser) {
|
|
23
|
-
parser.hooks.call.for("require.context").tap(PLUGIN_NAME, expr => {
|
|
23
|
+
parser.hooks.call.for("require.context").tap(PLUGIN_NAME, (expr) => {
|
|
24
24
|
let regExp = /^\.\/.*$/;
|
|
25
25
|
let recursive = true;
|
|
26
26
|
/** @type {ContextMode} */
|
|
@@ -25,7 +25,7 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|
|
25
25
|
* @returns {void}
|
|
26
26
|
*/
|
|
27
27
|
apply(parser) {
|
|
28
|
-
parser.hooks.call.for("require.ensure").tap(PLUGIN_NAME, expr => {
|
|
28
|
+
parser.hooks.call.for("require.ensure").tap(PLUGIN_NAME, (expr) => {
|
|
29
29
|
/** @type {string | GroupOptions | null} */
|
|
30
30
|
let chunkName = null;
|
|
31
31
|
let errorExpressionArg = null;
|
|
@@ -33,7 +33,7 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
|
|
33
33
|
*/
|
|
34
34
|
apply(parser) {
|
|
35
35
|
const { warn } = this;
|
|
36
|
-
parser.hooks.call.for("require.include").tap(PLUGIN_NAME, expr => {
|
|
36
|
+
parser.hooks.call.for("require.include").tap(PLUGIN_NAME, (expr) => {
|
|
37
37
|
if (expr.arguments.length !== 1) return;
|
|
38
38
|
const param = parser.evaluateExpression(expr.arguments[0]);
|
|
39
39
|
if (!param.isString()) return;
|
|
@@ -57,7 +57,7 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
|
|
57
57
|
});
|
|
58
58
|
parser.hooks.evaluateTypeof
|
|
59
59
|
.for("require.include")
|
|
60
|
-
.tap(PLUGIN_NAME, expr => {
|
|
60
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
61
61
|
if (warn) {
|
|
62
62
|
parser.state.module.addWarning(
|
|
63
63
|
new RequireIncludeDeprecationWarning(
|
|
@@ -67,7 +67,7 @@ module.exports = class RequireIncludeDependencyParserPlugin {
|
|
|
67
67
|
}
|
|
68
68
|
return evaluateToString("function")(expr);
|
|
69
69
|
});
|
|
70
|
-
parser.hooks.typeof.for("require.include").tap(PLUGIN_NAME, expr => {
|
|
70
|
+
parser.hooks.typeof.for("require.include").tap(PLUGIN_NAME, (expr) => {
|
|
71
71
|
if (warn) {
|
|
72
72
|
parser.state.module.addWarning(
|
|
73
73
|
new RequireIncludeDeprecationWarning(
|
|
@@ -63,7 +63,7 @@ class SystemPlugin {
|
|
|
63
63
|
/**
|
|
64
64
|
* @param {string} name name
|
|
65
65
|
*/
|
|
66
|
-
const setNotSupported = name => {
|
|
66
|
+
const setNotSupported = (name) => {
|
|
67
67
|
parser.hooks.evaluateTypeof
|
|
68
68
|
.for(name)
|
|
69
69
|
.tap(PLUGIN_NAME, evaluateToString("undefined"));
|
|
@@ -101,7 +101,7 @@ class SystemPlugin {
|
|
|
101
101
|
setNotSupported("System.get");
|
|
102
102
|
setNotSupported("System.register");
|
|
103
103
|
|
|
104
|
-
parser.hooks.expression.for("System").tap(PLUGIN_NAME, expr => {
|
|
104
|
+
parser.hooks.expression.for("System").tap(PLUGIN_NAME, (expr) => {
|
|
105
105
|
const dep = new ConstDependency(
|
|
106
106
|
RuntimeGlobals.system,
|
|
107
107
|
/** @type {Range} */ (expr.range),
|
|
@@ -112,7 +112,7 @@ class SystemPlugin {
|
|
|
112
112
|
return true;
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, expr => {
|
|
115
|
+
parser.hooks.call.for("System.import").tap(PLUGIN_NAME, (expr) => {
|
|
116
116
|
parser.state.module.addWarning(
|
|
117
117
|
new SystemImportDeprecationWarning(
|
|
118
118
|
/** @type {DependencyLocation} */ (expr.loc)
|
|
@@ -54,7 +54,7 @@ const WorkerDependency = require("./WorkerDependency");
|
|
|
54
54
|
* @param {NormalModule} module module
|
|
55
55
|
* @returns {string} url
|
|
56
56
|
*/
|
|
57
|
-
const getUrl = module => pathToFileURL(module.resource).toString();
|
|
57
|
+
const getUrl = (module) => pathToFileURL(module.resource).toString();
|
|
58
58
|
|
|
59
59
|
const WorkerSpecifierTag = Symbol("worker specifier tag");
|
|
60
60
|
|
|
@@ -253,7 +253,7 @@ class WorkerPlugin {
|
|
|
253
253
|
* @param {CallExpression} expr expression
|
|
254
254
|
* @returns {boolean | void} true when handled
|
|
255
255
|
*/
|
|
256
|
-
const handleNewWorker = expr => {
|
|
256
|
+
const handleNewWorker = (expr) => {
|
|
257
257
|
if (expr.arguments.length === 0 || expr.arguments.length > 2) {
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
@@ -483,7 +483,7 @@ class WorkerPlugin {
|
|
|
483
483
|
/**
|
|
484
484
|
* @param {string} item item
|
|
485
485
|
*/
|
|
486
|
-
const processItem = item => {
|
|
486
|
+
const processItem = (item) => {
|
|
487
487
|
if (
|
|
488
488
|
item.startsWith("*") &&
|
|
489
489
|
item.includes(".") &&
|
|
@@ -505,7 +505,7 @@ class WorkerPlugin {
|
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
);
|
|
508
|
-
parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, pattern => {
|
|
508
|
+
parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, (pattern) => {
|
|
509
509
|
parser.tagVariable(pattern.name, WorkerSpecifierTag);
|
|
510
510
|
return true;
|
|
511
511
|
});
|
|
@@ -530,7 +530,7 @@ class WorkerPlugin {
|
|
|
530
530
|
const source = match[3];
|
|
531
531
|
(call ? parser.hooks.call : parser.hooks.new)
|
|
532
532
|
.for(harmonySpecifierTag)
|
|
533
|
-
.tap(PLUGIN_NAME, expr => {
|
|
533
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
534
534
|
const settings = /** @type {HarmonySettings} */ (
|
|
535
535
|
parser.currentTagData
|
|
536
536
|
);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @param {Expression | SpreadElement} expr expressions
|
|
15
15
|
* @returns {{fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
|
16
16
|
*/
|
|
17
|
-
module.exports = expr => {
|
|
17
|
+
module.exports = (expr) => {
|
|
18
18
|
// <FunctionExpression>
|
|
19
19
|
if (
|
|
20
20
|
expr.type === "FunctionExpression" ||
|
|
@@ -119,7 +119,7 @@ class ModuleChunkFormatPlugin {
|
|
|
119
119
|
* @returns {void}
|
|
120
120
|
*/
|
|
121
121
|
apply(compiler) {
|
|
122
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
122
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
123
123
|
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
124
124
|
PLUGIN_NAME,
|
|
125
125
|
(chunk, set) => {
|
|
@@ -196,17 +196,17 @@ class ModuleChunkFormatPlugin {
|
|
|
196
196
|
const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null;
|
|
197
197
|
const source = new ConcatSource();
|
|
198
198
|
source.add(
|
|
199
|
-
`export const
|
|
199
|
+
`export const ${RuntimeGlobals.esmId} = ${JSON.stringify(chunk.id)};\n`
|
|
200
200
|
);
|
|
201
201
|
source.add(
|
|
202
|
-
`export const
|
|
202
|
+
`export const ${RuntimeGlobals.esmIds} = ${JSON.stringify(chunk.ids)};\n`
|
|
203
203
|
);
|
|
204
|
-
source.add(
|
|
204
|
+
source.add(`export const ${RuntimeGlobals.esmModules} = `);
|
|
205
205
|
source.add(modules);
|
|
206
206
|
source.add(";\n");
|
|
207
207
|
const runtimeModules = chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
|
208
208
|
if (runtimeModules.length > 0) {
|
|
209
|
-
source.add(
|
|
209
|
+
source.add(`export const ${RuntimeGlobals.esmRuntime} =\n`);
|
|
210
210
|
source.add(
|
|
211
211
|
Template.renderChunkRuntimeModules(runtimeModules, renderContext)
|
|
212
212
|
);
|
|
@@ -21,13 +21,13 @@ class ModuleChunkLoadingPlugin {
|
|
|
21
21
|
* @returns {void}
|
|
22
22
|
*/
|
|
23
23
|
apply(compiler) {
|
|
24
|
-
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
24
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
25
25
|
const globalChunkLoading = compilation.outputOptions.chunkLoading;
|
|
26
26
|
/**
|
|
27
27
|
* @param {Chunk} chunk chunk to check
|
|
28
28
|
* @returns {boolean} true, when the plugin is enabled for the chunk
|
|
29
29
|
*/
|
|
30
|
-
const isEnabledForChunk = chunk => {
|
|
30
|
+
const isEnabledForChunk = (chunk) => {
|
|
31
31
|
const options = chunk.getEntryOptions();
|
|
32
32
|
const chunkLoading =
|
|
33
33
|
options && options.chunkLoading !== undefined
|
|
@@ -159,7 +159,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
159
159
|
stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
|
|
160
160
|
}{`,
|
|
161
161
|
Template.indent(
|
|
162
|
-
Array.from(initialChunkIds, id => `${JSON.stringify(id)}: 0`).join(
|
|
162
|
+
Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(
|
|
163
163
|
",\n"
|
|
164
164
|
)
|
|
165
165
|
),
|
|
@@ -168,29 +168,33 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
168
168
|
withLoading || withExternalInstallChunk
|
|
169
169
|
? `var installChunk = ${runtimeTemplate.basicFunction("data", [
|
|
170
170
|
runtimeTemplate.destructureObject(
|
|
171
|
-
[
|
|
171
|
+
[
|
|
172
|
+
RuntimeGlobals.esmIds,
|
|
173
|
+
RuntimeGlobals.esmModules,
|
|
174
|
+
RuntimeGlobals.esmRuntime
|
|
175
|
+
],
|
|
172
176
|
"data"
|
|
173
177
|
),
|
|
174
178
|
'// add "modules" to the modules object,',
|
|
175
179
|
'// then flag all "ids" as loaded and fire callback',
|
|
176
180
|
"var moduleId, chunkId, i = 0;",
|
|
177
|
-
|
|
181
|
+
`for(moduleId in ${RuntimeGlobals.esmModules}) {`,
|
|
178
182
|
Template.indent([
|
|
179
|
-
`if(${RuntimeGlobals.hasOwnProperty}(
|
|
183
|
+
`if(${RuntimeGlobals.hasOwnProperty}(${RuntimeGlobals.esmModules}, moduleId)) {`,
|
|
180
184
|
Template.indent(
|
|
181
|
-
`${RuntimeGlobals.moduleFactories}[moduleId] =
|
|
185
|
+
`${RuntimeGlobals.moduleFactories}[moduleId] = ${RuntimeGlobals.esmModules}[moduleId];`
|
|
182
186
|
),
|
|
183
187
|
"}"
|
|
184
188
|
]),
|
|
185
189
|
"}",
|
|
186
|
-
`if(
|
|
187
|
-
|
|
190
|
+
`if(${RuntimeGlobals.esmRuntime}) ${RuntimeGlobals.esmRuntime}(${RuntimeGlobals.require});`,
|
|
191
|
+
`for(;i < ${RuntimeGlobals.esmIds}.length; i++) {`,
|
|
188
192
|
Template.indent([
|
|
189
|
-
|
|
193
|
+
`chunkId = ${RuntimeGlobals.esmIds}[i];`,
|
|
190
194
|
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId]) {`,
|
|
191
195
|
Template.indent("installedChunks[chunkId][0]();"),
|
|
192
196
|
"}",
|
|
193
|
-
|
|
197
|
+
`installedChunks[${RuntimeGlobals.esmIds}[i]] = 0;`
|
|
194
198
|
]),
|
|
195
199
|
"}",
|
|
196
200
|
withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : ""
|
|
@@ -365,8 +369,8 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
|
365
369
|
"// start update chunk loading",
|
|
366
370
|
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId);`,
|
|
367
371
|
`var onResolve = ${runtimeTemplate.basicFunction("obj", [
|
|
368
|
-
|
|
369
|
-
|
|
372
|
+
`var updatedModules = obj.${RuntimeGlobals.esmModules};`,
|
|
373
|
+
`var updatedRuntime = obj.${RuntimeGlobals.esmRuntime};`,
|
|
370
374
|
"if(updatedRuntime) currentUpdateRuntime.push(updatedRuntime);",
|
|
371
375
|
"for(var moduleId in updatedModules) {",
|
|
372
376
|
Template.indent([
|
package/lib/formatLocation.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @param {SourcePosition} pos position
|
|
13
13
|
* @returns {string} formatted position
|
|
14
14
|
*/
|
|
15
|
-
const formatPosition = pos => {
|
|
15
|
+
const formatPosition = (pos) => {
|
|
16
16
|
if (pos && typeof pos === "object") {
|
|
17
17
|
if ("line" in pos && "column" in pos) {
|
|
18
18
|
return `${pos.line}:${pos.column}`;
|
|
@@ -27,7 +27,7 @@ const formatPosition = pos => {
|
|
|
27
27
|
* @param {DependencyLocation} loc location
|
|
28
28
|
* @returns {string} formatted location
|
|
29
29
|
*/
|
|
30
|
-
const formatLocation = loc => {
|
|
30
|
+
const formatLocation = (loc) => {
|
|
31
31
|
if (loc && typeof loc === "object") {
|
|
32
32
|
if ("start" in loc && loc.start && "end" in loc && loc.end) {
|
|
33
33
|
if (
|
|
@@ -354,38 +354,50 @@ module.exports = function () {
|
|
|
354
354
|
};
|
|
355
355
|
|
|
356
356
|
var outdatedModules = [];
|
|
357
|
-
results.forEach(function (result) {
|
|
358
|
-
if (result.apply) {
|
|
359
|
-
var modules = result.apply(reportError);
|
|
360
|
-
if (modules) {
|
|
361
|
-
for (var i = 0; i < modules.length; i++) {
|
|
362
|
-
outdatedModules.push(modules[i]);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
357
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
358
|
+
var onAccepted = function () {
|
|
359
|
+
return Promise.all([disposePromise, applyPromise]).then(function () {
|
|
360
|
+
// handle errors in accept handlers and self accepted module load
|
|
361
|
+
if (error) {
|
|
362
|
+
return setStatus("fail").then(function () {
|
|
363
|
+
throw error;
|
|
364
|
+
});
|
|
365
|
+
}
|
|
375
366
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
367
|
+
if (queuedInvalidatedModules) {
|
|
368
|
+
return internalApply(options).then(function (list) {
|
|
369
|
+
outdatedModules.forEach(function (moduleId) {
|
|
370
|
+
if (list.indexOf(moduleId) < 0) list.push(moduleId);
|
|
371
|
+
});
|
|
372
|
+
return list;
|
|
380
373
|
});
|
|
381
|
-
|
|
382
|
-
});
|
|
383
|
-
}
|
|
374
|
+
}
|
|
384
375
|
|
|
385
|
-
|
|
386
|
-
|
|
376
|
+
return setStatus("idle").then(function () {
|
|
377
|
+
return outdatedModules;
|
|
378
|
+
});
|
|
387
379
|
});
|
|
388
|
-
}
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
return Promise.all(
|
|
383
|
+
results
|
|
384
|
+
.filter(function (result) {
|
|
385
|
+
return result.apply;
|
|
386
|
+
})
|
|
387
|
+
.map(function (result) {
|
|
388
|
+
return result.apply(reportError);
|
|
389
|
+
})
|
|
390
|
+
)
|
|
391
|
+
.then(function (applyResults) {
|
|
392
|
+
applyResults.forEach(function (modules) {
|
|
393
|
+
if (modules) {
|
|
394
|
+
for (var i = 0; i < modules.length; i++) {
|
|
395
|
+
outdatedModules.push(modules[i]);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
})
|
|
400
|
+
.then(onAccepted);
|
|
389
401
|
}
|
|
390
402
|
|
|
391
403
|
function applyInvalidatedModules() {
|
|
@@ -281,6 +281,7 @@ module.exports = function () {
|
|
|
281
281
|
}
|
|
282
282
|
},
|
|
283
283
|
apply: function (reportError) {
|
|
284
|
+
var acceptPromises = [];
|
|
284
285
|
// insert new code
|
|
285
286
|
for (var updateModuleId in appliedUpdate) {
|
|
286
287
|
if ($hasOwnProperty$(appliedUpdate, updateModuleId)) {
|
|
@@ -317,8 +318,9 @@ module.exports = function () {
|
|
|
317
318
|
}
|
|
318
319
|
}
|
|
319
320
|
for (var k = 0; k < callbacks.length; k++) {
|
|
321
|
+
var result;
|
|
320
322
|
try {
|
|
321
|
-
callbacks[k].call(null, moduleOutdatedDependencies);
|
|
323
|
+
result = callbacks[k].call(null, moduleOutdatedDependencies);
|
|
322
324
|
} catch (err) {
|
|
323
325
|
if (typeof errorHandlers[k] === "function") {
|
|
324
326
|
try {
|
|
@@ -355,54 +357,63 @@ module.exports = function () {
|
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
359
|
}
|
|
360
|
+
if (result && typeof result.then === "function") {
|
|
361
|
+
acceptPromises.push(result);
|
|
362
|
+
}
|
|
358
363
|
}
|
|
359
364
|
}
|
|
360
365
|
}
|
|
361
366
|
}
|
|
362
367
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
368
|
+
var onAccepted = function () {
|
|
369
|
+
// Load self accepted modules
|
|
370
|
+
for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) {
|
|
371
|
+
var item = outdatedSelfAcceptedModules[o];
|
|
372
|
+
var moduleId = item.module;
|
|
373
|
+
try {
|
|
374
|
+
item.require(moduleId);
|
|
375
|
+
} catch (err) {
|
|
376
|
+
if (typeof item.errorHandler === "function") {
|
|
377
|
+
try {
|
|
378
|
+
item.errorHandler(err, {
|
|
379
|
+
moduleId: moduleId,
|
|
380
|
+
module: $moduleCache$[moduleId]
|
|
381
|
+
});
|
|
382
|
+
} catch (err1) {
|
|
383
|
+
if (options.onErrored) {
|
|
384
|
+
options.onErrored({
|
|
385
|
+
type: "self-accept-error-handler-errored",
|
|
386
|
+
moduleId: moduleId,
|
|
387
|
+
error: err1,
|
|
388
|
+
originalError: err
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
if (!options.ignoreErrored) {
|
|
392
|
+
reportError(err1);
|
|
393
|
+
reportError(err);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
} else {
|
|
377
397
|
if (options.onErrored) {
|
|
378
398
|
options.onErrored({
|
|
379
|
-
type: "self-accept-
|
|
399
|
+
type: "self-accept-errored",
|
|
380
400
|
moduleId: moduleId,
|
|
381
|
-
error:
|
|
382
|
-
originalError: err
|
|
401
|
+
error: err
|
|
383
402
|
});
|
|
384
403
|
}
|
|
385
404
|
if (!options.ignoreErrored) {
|
|
386
|
-
reportError(err1);
|
|
387
405
|
reportError(err);
|
|
388
406
|
}
|
|
389
407
|
}
|
|
390
|
-
} else {
|
|
391
|
-
if (options.onErrored) {
|
|
392
|
-
options.onErrored({
|
|
393
|
-
type: "self-accept-errored",
|
|
394
|
-
moduleId: moduleId,
|
|
395
|
-
error: err
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
if (!options.ignoreErrored) {
|
|
399
|
-
reportError(err);
|
|
400
|
-
}
|
|
401
408
|
}
|
|
402
409
|
}
|
|
403
|
-
}
|
|
410
|
+
};
|
|
404
411
|
|
|
405
|
-
return
|
|
412
|
+
return Promise.all(acceptPromises)
|
|
413
|
+
.then(onAccepted)
|
|
414
|
+
.then(function () {
|
|
415
|
+
return outdatedModules;
|
|
416
|
+
});
|
|
406
417
|
}
|
|
407
418
|
};
|
|
408
419
|
}
|
|
@@ -13,7 +13,7 @@ const Template = require("../Template");
|
|
|
13
13
|
* @param {string} type unique identifier used for HMR runtime properties
|
|
14
14
|
* @returns {string} HMR runtime code
|
|
15
15
|
*/
|
|
16
|
-
const generateJavascriptHMR = type =>
|
|
16
|
+
const generateJavascriptHMR = (type) =>
|
|
17
17
|
Template.getFunctionContent(
|
|
18
18
|
require("../hmr/JavascriptHotModuleReplacement.runtime")
|
|
19
19
|
)
|