webpack 5.99.8 → 5.100.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 +0 -3
- package/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CacheFacade.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -32
- package/lib/ChunkGroup.js +17 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +77 -71
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +65 -45
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -3
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +16 -12
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -38
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +1 -1
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +61 -56
- package/lib/NormalModuleFactory.js +52 -37
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +34 -8
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +26 -21
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +11 -9
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +1 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLDependency.js +1 -1
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +73 -6
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +136 -81
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/ModuleLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +7 -4
- package/lib/rules/UseEffectRulePlugin.js +3 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/DataUriPlugin.js +3 -1
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +6 -3
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +28 -22
- package/lib/stats/StatsFactory.js +4 -2
- package/lib/stats/StatsPrinter.js +3 -2
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +12 -8
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +121 -114
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1261 -366
|
@@ -16,6 +16,9 @@ const {
|
|
|
16
16
|
} = require("./StartupHelpers");
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("../Compiler")} Compiler */
|
|
19
|
+
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
|
20
|
+
|
|
21
|
+
const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin";
|
|
19
22
|
|
|
20
23
|
class ArrayPushCallbackChunkFormatPlugin {
|
|
21
24
|
/**
|
|
@@ -24,132 +27,123 @@ class ArrayPushCallbackChunkFormatPlugin {
|
|
|
24
27
|
* @returns {void}
|
|
25
28
|
*/
|
|
26
29
|
apply(compiler) {
|
|
27
|
-
compiler.hooks.thisCompilation.tap(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(chunk
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
set.add(RuntimeGlobals.exports);
|
|
37
|
-
set.add(RuntimeGlobals.require);
|
|
38
|
-
}
|
|
39
|
-
set.add(RuntimeGlobals.chunkCallback);
|
|
30
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
31
|
+
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
32
|
+
PLUGIN_NAME,
|
|
33
|
+
(chunk, set, { chunkGraph }) => {
|
|
34
|
+
if (chunk.hasRuntime()) return;
|
|
35
|
+
if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
|
|
36
|
+
set.add(RuntimeGlobals.onChunksLoaded);
|
|
37
|
+
set.add(RuntimeGlobals.exports);
|
|
38
|
+
set.add(RuntimeGlobals.require);
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
40
|
+
set.add(RuntimeGlobals.chunkCallback);
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
const hooks = getCompilationHooks(compilation);
|
|
44
|
+
hooks.renderChunk.tap(PLUGIN_NAME, (modules, renderContext) => {
|
|
45
|
+
const { chunk, chunkGraph, runtimeTemplate } = renderContext;
|
|
46
|
+
const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null;
|
|
47
|
+
const globalObject = runtimeTemplate.globalObject;
|
|
48
|
+
const source = new ConcatSource();
|
|
49
|
+
const runtimeModules = chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
|
50
|
+
if (hotUpdateChunk) {
|
|
51
|
+
const hotUpdateGlobal = runtimeTemplate.outputOptions.hotUpdateGlobal;
|
|
52
|
+
source.add(`${globalObject}[${JSON.stringify(hotUpdateGlobal)}](`);
|
|
53
|
+
source.add(`${JSON.stringify(chunk.id)},`);
|
|
54
|
+
source.add(modules);
|
|
55
|
+
if (runtimeModules.length > 0) {
|
|
56
|
+
source.add(",\n");
|
|
57
|
+
const runtimePart = Template.renderChunkRuntimeModules(
|
|
58
|
+
runtimeModules,
|
|
59
|
+
renderContext
|
|
60
|
+
);
|
|
61
|
+
source.add(runtimePart);
|
|
62
|
+
}
|
|
63
|
+
source.add(")");
|
|
64
|
+
} else {
|
|
65
|
+
const chunkLoadingGlobal =
|
|
66
|
+
runtimeTemplate.outputOptions.chunkLoadingGlobal;
|
|
67
|
+
source.add(
|
|
68
|
+
`(${globalObject}[${JSON.stringify(
|
|
69
|
+
chunkLoadingGlobal
|
|
70
|
+
)}] = ${globalObject}[${JSON.stringify(
|
|
71
|
+
chunkLoadingGlobal
|
|
72
|
+
)}] || []).push([`
|
|
73
|
+
);
|
|
74
|
+
source.add(`${JSON.stringify(chunk.ids)},`);
|
|
75
|
+
source.add(modules);
|
|
76
|
+
/** @type {EntryModuleWithChunkGroup[]} */
|
|
77
|
+
const entries = [
|
|
78
|
+
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
|
79
|
+
];
|
|
80
|
+
if (runtimeModules.length > 0 || entries.length > 0) {
|
|
81
|
+
const runtime = new ConcatSource(
|
|
82
|
+
`${
|
|
83
|
+
runtimeTemplate.supportsArrowFunction()
|
|
84
|
+
? `${RuntimeGlobals.require} =>`
|
|
85
|
+
: `function(${RuntimeGlobals.require})`
|
|
86
|
+
} { // webpackRuntimeModules\n`
|
|
87
|
+
);
|
|
88
|
+
if (runtimeModules.length > 0) {
|
|
89
|
+
runtime.add(
|
|
90
|
+
Template.renderRuntimeModules(runtimeModules, {
|
|
91
|
+
...renderContext,
|
|
92
|
+
codeGenerationResults: compilation.codeGenerationResults
|
|
93
|
+
})
|
|
79
94
|
);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
95
|
+
}
|
|
96
|
+
if (entries.length > 0) {
|
|
97
|
+
const startupSource = new RawSource(
|
|
98
|
+
generateEntryStartup(
|
|
99
|
+
chunkGraph,
|
|
100
|
+
runtimeTemplate,
|
|
101
|
+
entries,
|
|
102
|
+
chunk,
|
|
103
|
+
true
|
|
104
|
+
)
|
|
84
105
|
);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
if (runtimeModules.length > 0) {
|
|
94
|
-
runtime.add(
|
|
95
|
-
Template.renderRuntimeModules(runtimeModules, {
|
|
96
|
-
...renderContext,
|
|
97
|
-
codeGenerationResults: compilation.codeGenerationResults
|
|
98
|
-
})
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
if (entries.length > 0) {
|
|
102
|
-
const startupSource = new RawSource(
|
|
103
|
-
generateEntryStartup(
|
|
104
|
-
chunkGraph,
|
|
105
|
-
runtimeTemplate,
|
|
106
|
-
entries,
|
|
107
|
-
chunk,
|
|
108
|
-
true
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
runtime.add(
|
|
112
|
-
hooks.renderStartup.call(
|
|
113
|
-
startupSource,
|
|
114
|
-
entries[entries.length - 1][0],
|
|
115
|
-
{
|
|
116
|
-
...renderContext,
|
|
117
|
-
inlined: false
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
);
|
|
121
|
-
if (
|
|
122
|
-
chunkGraph
|
|
123
|
-
.getChunkRuntimeRequirements(chunk)
|
|
124
|
-
.has(RuntimeGlobals.returnExportsFromRuntime)
|
|
125
|
-
) {
|
|
126
|
-
runtime.add(`return ${RuntimeGlobals.exports};\n`);
|
|
106
|
+
runtime.add(
|
|
107
|
+
hooks.renderStartup.call(
|
|
108
|
+
startupSource,
|
|
109
|
+
entries[entries.length - 1][0],
|
|
110
|
+
{
|
|
111
|
+
...renderContext,
|
|
112
|
+
inlined: false
|
|
127
113
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
if (
|
|
117
|
+
chunkGraph
|
|
118
|
+
.getChunkRuntimeRequirements(chunk)
|
|
119
|
+
.has(RuntimeGlobals.returnExportsFromRuntime)
|
|
120
|
+
) {
|
|
121
|
+
runtime.add(`return ${RuntimeGlobals.exports};\n`);
|
|
132
122
|
}
|
|
133
|
-
source.add("])");
|
|
134
123
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
hooks.chunkHash.tap(
|
|
139
|
-
"ArrayPushCallbackChunkFormatPlugin",
|
|
140
|
-
(chunk, hash, { chunkGraph, runtimeTemplate }) => {
|
|
141
|
-
if (chunk.hasRuntime()) return;
|
|
142
|
-
hash.update(
|
|
143
|
-
`ArrayPushCallbackChunkFormatPlugin1${runtimeTemplate.outputOptions.chunkLoadingGlobal}${runtimeTemplate.outputOptions.hotUpdateGlobal}${runtimeTemplate.globalObject}`
|
|
144
|
-
);
|
|
145
|
-
const entries = Array.from(
|
|
146
|
-
chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
|
147
|
-
);
|
|
148
|
-
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
|
124
|
+
runtime.add("}\n");
|
|
125
|
+
source.add(",\n");
|
|
126
|
+
source.add(new PrefixSource("/******/ ", runtime));
|
|
149
127
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
128
|
+
source.add("])");
|
|
129
|
+
}
|
|
130
|
+
return source;
|
|
131
|
+
});
|
|
132
|
+
hooks.chunkHash.tap(
|
|
133
|
+
PLUGIN_NAME,
|
|
134
|
+
(chunk, hash, { chunkGraph, runtimeTemplate }) => {
|
|
135
|
+
if (chunk.hasRuntime()) return;
|
|
136
|
+
hash.update(
|
|
137
|
+
`${PLUGIN_NAME}1${runtimeTemplate.outputOptions.chunkLoadingGlobal}${runtimeTemplate.outputOptions.hotUpdateGlobal}${runtimeTemplate.globalObject}`
|
|
138
|
+
);
|
|
139
|
+
/** @type {EntryModuleWithChunkGroup[]} */
|
|
140
|
+
const entries = [
|
|
141
|
+
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
|
142
|
+
];
|
|
143
|
+
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
});
|
|
153
147
|
}
|
|
154
148
|
}
|
|
155
149
|
|
|
@@ -566,7 +566,7 @@ BasicEvaluatedExpression.isValidRegExpFlags = flags => {
|
|
|
566
566
|
// cspell:word gimy
|
|
567
567
|
let remaining = 0b0000; // bit per RegExp flag: gimy
|
|
568
568
|
|
|
569
|
-
for (let i = 0; i < len; i++)
|
|
569
|
+
for (let i = 0; i < len; i++) {
|
|
570
570
|
switch (flags.charCodeAt(i)) {
|
|
571
571
|
case 103 /* g */:
|
|
572
572
|
if (remaining & 0b1000) return false;
|
|
@@ -587,6 +587,7 @@ BasicEvaluatedExpression.isValidRegExpFlags = flags => {
|
|
|
587
587
|
default:
|
|
588
588
|
return false;
|
|
589
589
|
}
|
|
590
|
+
}
|
|
590
591
|
|
|
591
592
|
return true;
|
|
592
593
|
};
|
|
@@ -22,6 +22,8 @@ const {
|
|
|
22
22
|
/** @typedef {import("../Compiler")} Compiler */
|
|
23
23
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
24
24
|
|
|
25
|
+
const PLUGIN_NAME = "CommonJsChunkFormatPlugin";
|
|
26
|
+
|
|
25
27
|
class CommonJsChunkFormatPlugin {
|
|
26
28
|
/**
|
|
27
29
|
* Apply the plugin
|
|
@@ -29,146 +31,129 @@ class CommonJsChunkFormatPlugin {
|
|
|
29
31
|
* @returns {void}
|
|
30
32
|
*/
|
|
31
33
|
apply(compiler) {
|
|
32
|
-
compiler.hooks.thisCompilation.tap(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
(chunk
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
set.add(RuntimeGlobals.startupEntrypoint);
|
|
42
|
-
set.add(RuntimeGlobals.externalInstallChunk);
|
|
43
|
-
}
|
|
34
|
+
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
|
|
35
|
+
compilation.hooks.additionalChunkRuntimeRequirements.tap(
|
|
36
|
+
PLUGIN_NAME,
|
|
37
|
+
(chunk, set, { chunkGraph }) => {
|
|
38
|
+
if (chunk.hasRuntime()) return;
|
|
39
|
+
if (chunkGraph.getNumberOfEntryModules(chunk) > 0) {
|
|
40
|
+
set.add(RuntimeGlobals.require);
|
|
41
|
+
set.add(RuntimeGlobals.startupEntrypoint);
|
|
42
|
+
set.add(RuntimeGlobals.externalInstallChunk);
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
compilation.outputOptions
|
|
91
|
-
),
|
|
92
|
-
{
|
|
93
|
-
chunk: /** @type {Chunk} */ (runtimeChunk),
|
|
94
|
-
contentHashType: "javascript"
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
.replace(/^\/+/g, "")
|
|
98
|
-
.split("/");
|
|
99
|
-
|
|
100
|
-
// remove common parts
|
|
101
|
-
while (
|
|
102
|
-
currentOutputName.length > 1 &&
|
|
103
|
-
runtimeOutputName.length > 1 &&
|
|
104
|
-
currentOutputName[0] === runtimeOutputName[0]
|
|
105
|
-
) {
|
|
106
|
-
currentOutputName.shift();
|
|
107
|
-
runtimeOutputName.shift();
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
const hooks = getCompilationHooks(compilation);
|
|
47
|
+
hooks.renderChunk.tap(PLUGIN_NAME, (modules, renderContext) => {
|
|
48
|
+
const { chunk, chunkGraph, runtimeTemplate } = renderContext;
|
|
49
|
+
const source = new ConcatSource();
|
|
50
|
+
source.add(`exports.id = ${JSON.stringify(chunk.id)};\n`);
|
|
51
|
+
source.add(`exports.ids = ${JSON.stringify(chunk.ids)};\n`);
|
|
52
|
+
source.add("exports.modules = ");
|
|
53
|
+
source.add(modules);
|
|
54
|
+
source.add(";\n");
|
|
55
|
+
const runtimeModules = chunkGraph.getChunkRuntimeModulesInOrder(chunk);
|
|
56
|
+
if (runtimeModules.length > 0) {
|
|
57
|
+
source.add("exports.runtime =\n");
|
|
58
|
+
source.add(
|
|
59
|
+
Template.renderChunkRuntimeModules(runtimeModules, renderContext)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
const entries = [
|
|
63
|
+
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
|
64
|
+
];
|
|
65
|
+
if (entries.length > 0) {
|
|
66
|
+
const runtimeChunk =
|
|
67
|
+
/** @type {Entrypoint} */
|
|
68
|
+
(entries[0][1]).getRuntimeChunk();
|
|
69
|
+
const currentOutputName = compilation
|
|
70
|
+
.getPath(
|
|
71
|
+
getChunkFilenameTemplate(chunk, compilation.outputOptions),
|
|
72
|
+
{
|
|
73
|
+
chunk,
|
|
74
|
+
contentHashType: "javascript"
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
.replace(/^\/+/g, "")
|
|
78
|
+
.split("/");
|
|
79
|
+
const runtimeOutputName = compilation
|
|
80
|
+
.getPath(
|
|
81
|
+
getChunkFilenameTemplate(
|
|
82
|
+
/** @type {Chunk} */
|
|
83
|
+
(runtimeChunk),
|
|
84
|
+
compilation.outputOptions
|
|
85
|
+
),
|
|
86
|
+
{
|
|
87
|
+
chunk: /** @type {Chunk} */ (runtimeChunk),
|
|
88
|
+
contentHashType: "javascript"
|
|
108
89
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
getUndoPath(currentOutputName.join("/"), last, true) + last;
|
|
90
|
+
)
|
|
91
|
+
.replace(/^\/+/g, "")
|
|
92
|
+
.split("/");
|
|
113
93
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
entrySource.add("var exports = {};\n");
|
|
123
|
-
entrySource.add(source);
|
|
124
|
-
entrySource.add(";\n\n// load runtime\n");
|
|
125
|
-
entrySource.add(
|
|
126
|
-
`var ${RuntimeGlobals.require} = require(${JSON.stringify(
|
|
127
|
-
runtimePath
|
|
128
|
-
)});\n`
|
|
129
|
-
);
|
|
130
|
-
entrySource.add(
|
|
131
|
-
`${RuntimeGlobals.externalInstallChunk}(exports);\n`
|
|
132
|
-
);
|
|
133
|
-
const startupSource = new RawSource(
|
|
134
|
-
generateEntryStartup(
|
|
135
|
-
chunkGraph,
|
|
136
|
-
runtimeTemplate,
|
|
137
|
-
entries,
|
|
138
|
-
chunk,
|
|
139
|
-
false
|
|
140
|
-
)
|
|
141
|
-
);
|
|
142
|
-
entrySource.add(
|
|
143
|
-
hooks.renderStartup.call(
|
|
144
|
-
startupSource,
|
|
145
|
-
entries[entries.length - 1][0],
|
|
146
|
-
{
|
|
147
|
-
...renderContext,
|
|
148
|
-
inlined: false
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
);
|
|
152
|
-
entrySource.add("\n})()");
|
|
153
|
-
return entrySource;
|
|
154
|
-
}
|
|
155
|
-
return source;
|
|
94
|
+
// remove common parts
|
|
95
|
+
while (
|
|
96
|
+
currentOutputName.length > 1 &&
|
|
97
|
+
runtimeOutputName.length > 1 &&
|
|
98
|
+
currentOutputName[0] === runtimeOutputName[0]
|
|
99
|
+
) {
|
|
100
|
+
currentOutputName.shift();
|
|
101
|
+
runtimeOutputName.shift();
|
|
156
102
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
103
|
+
const last = runtimeOutputName.join("/");
|
|
104
|
+
// create final path
|
|
105
|
+
const runtimePath =
|
|
106
|
+
getUndoPath(currentOutputName.join("/"), last, true) + last;
|
|
107
|
+
|
|
108
|
+
const entrySource = new ConcatSource();
|
|
109
|
+
entrySource.add(
|
|
110
|
+
`(${
|
|
111
|
+
runtimeTemplate.supportsArrowFunction() ? "() => " : "function() "
|
|
112
|
+
}{\n`
|
|
113
|
+
);
|
|
114
|
+
entrySource.add("var exports = {};\n");
|
|
115
|
+
entrySource.add(source);
|
|
116
|
+
entrySource.add(";\n\n// load runtime\n");
|
|
117
|
+
entrySource.add(
|
|
118
|
+
`var ${RuntimeGlobals.require} = require(${JSON.stringify(
|
|
119
|
+
runtimePath
|
|
120
|
+
)});\n`
|
|
121
|
+
);
|
|
122
|
+
entrySource.add(`${RuntimeGlobals.externalInstallChunk}(exports);\n`);
|
|
123
|
+
const startupSource = new RawSource(
|
|
124
|
+
generateEntryStartup(
|
|
125
|
+
chunkGraph,
|
|
126
|
+
runtimeTemplate,
|
|
127
|
+
entries,
|
|
128
|
+
chunk,
|
|
129
|
+
false
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
entrySource.add(
|
|
133
|
+
hooks.renderStartup.call(
|
|
134
|
+
startupSource,
|
|
135
|
+
entries[entries.length - 1][0],
|
|
136
|
+
{
|
|
137
|
+
...renderContext,
|
|
138
|
+
inlined: false
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
entrySource.add("\n})()");
|
|
143
|
+
return entrySource;
|
|
144
|
+
}
|
|
145
|
+
return source;
|
|
146
|
+
});
|
|
147
|
+
hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash, { chunkGraph }) => {
|
|
148
|
+
if (chunk.hasRuntime()) return;
|
|
149
|
+
hash.update(PLUGIN_NAME);
|
|
150
|
+
hash.update("1");
|
|
151
|
+
const entries = [
|
|
152
|
+
...chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)
|
|
153
|
+
];
|
|
154
|
+
updateHashForEntryStartup(hash, chunkGraph, entries, chunk);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
172
157
|
}
|
|
173
158
|
}
|
|
174
159
|
|
|
@@ -53,9 +53,7 @@ class EnableChunkLoadingPlugin {
|
|
|
53
53
|
"EnableChunkLoadingPlugin need to be used to enable this type of chunk loading. " +
|
|
54
54
|
'This usually happens through the "output.enabledChunkLoadingTypes" option. ' +
|
|
55
55
|
'If you are using a function as entry which sets "chunkLoading", you need to add all potential chunk loading types to "output.enabledChunkLoadingTypes". ' +
|
|
56
|
-
`These types are enabled: ${
|
|
57
|
-
getEnabledTypes(compiler)
|
|
58
|
-
).join(", ")}`
|
|
56
|
+
`These types are enabled: ${[...getEnabledTypes(compiler)].join(", ")}`
|
|
59
57
|
);
|
|
60
58
|
}
|
|
61
59
|
}
|
|
@@ -77,17 +75,20 @@ class EnableChunkLoadingPlugin {
|
|
|
77
75
|
switch (type) {
|
|
78
76
|
case "jsonp": {
|
|
79
77
|
const JsonpChunkLoadingPlugin = require("../web/JsonpChunkLoadingPlugin");
|
|
78
|
+
|
|
80
79
|
new JsonpChunkLoadingPlugin().apply(compiler);
|
|
81
80
|
break;
|
|
82
81
|
}
|
|
83
82
|
case "import-scripts": {
|
|
84
83
|
const ImportScriptsChunkLoadingPlugin = require("../webworker/ImportScriptsChunkLoadingPlugin");
|
|
84
|
+
|
|
85
85
|
new ImportScriptsChunkLoadingPlugin().apply(compiler);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
88
88
|
case "require": {
|
|
89
89
|
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
|
|
90
90
|
const CommonJsChunkLoadingPlugin = require("../node/CommonJsChunkLoadingPlugin");
|
|
91
|
+
|
|
91
92
|
new CommonJsChunkLoadingPlugin({
|
|
92
93
|
asyncChunkLoading: false
|
|
93
94
|
}).apply(compiler);
|
|
@@ -96,6 +97,7 @@ class EnableChunkLoadingPlugin {
|
|
|
96
97
|
case "async-node": {
|
|
97
98
|
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697
|
|
98
99
|
const CommonJsChunkLoadingPlugin = require("../node/CommonJsChunkLoadingPlugin");
|
|
100
|
+
|
|
99
101
|
new CommonJsChunkLoadingPlugin({
|
|
100
102
|
asyncChunkLoading: true
|
|
101
103
|
}).apply(compiler);
|
|
@@ -104,6 +106,7 @@ class EnableChunkLoadingPlugin {
|
|
|
104
106
|
case "import":
|
|
105
107
|
case "universal": {
|
|
106
108
|
const ModuleChunkLoadingPlugin = require("../esm/ModuleChunkLoadingPlugin");
|
|
109
|
+
|
|
107
110
|
new ModuleChunkLoadingPlugin().apply(compiler);
|
|
108
111
|
break;
|
|
109
112
|
}
|
|
@@ -25,6 +25,18 @@ const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibi
|
|
|
25
25
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
26
26
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
27
27
|
|
|
28
|
+
const DEFAULT_SOURCE = {
|
|
29
|
+
source() {
|
|
30
|
+
return new RawSource("throw new Error('No source available');");
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* @returns {number} size of the DEFAULT_SOURCE.source()
|
|
34
|
+
*/
|
|
35
|
+
size() {
|
|
36
|
+
return 39;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
28
40
|
// TODO: clean up this file
|
|
29
41
|
// replace with newer constructs
|
|
30
42
|
|
|
@@ -59,7 +71,7 @@ class JavascriptGenerator extends Generator {
|
|
|
59
71
|
getSize(module, type) {
|
|
60
72
|
const originalSource = module.originalSource();
|
|
61
73
|
if (!originalSource) {
|
|
62
|
-
return
|
|
74
|
+
return DEFAULT_SOURCE.size();
|
|
63
75
|
}
|
|
64
76
|
return originalSource.size();
|
|
65
77
|
}
|
|
@@ -98,7 +110,7 @@ class JavascriptGenerator extends Generator {
|
|
|
98
110
|
generate(module, generateContext) {
|
|
99
111
|
const originalSource = module.originalSource();
|
|
100
112
|
if (!originalSource) {
|
|
101
|
-
return
|
|
113
|
+
return DEFAULT_SOURCE.source();
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
const source = new ReplaceSource(originalSource);
|