webpack 5.99.9 → 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/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/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- 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 +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +6 -1
- 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 -36
- 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 +31 -44
- package/lib/NormalModuleFactory.js +29 -19
- 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 +33 -7
- 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 +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- 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/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/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- 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/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 +70 -3
- 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 +117 -76
- 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/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 +3 -2
- 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 +6 -3
- 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/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 +3 -2
- 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 +15 -9
- 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 +119 -113
- 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 +1230 -360
|
@@ -42,6 +42,8 @@ const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency
|
|
|
42
42
|
const createRequireSpecifierTag = Symbol("createRequire");
|
|
43
43
|
const createdRequireIdentifierTag = Symbol("createRequire()");
|
|
44
44
|
|
|
45
|
+
const PLUGIN_NAME = "CommonJsImportsParserPlugin";
|
|
46
|
+
|
|
45
47
|
class CommonJsImportsParserPlugin {
|
|
46
48
|
/**
|
|
47
49
|
* @param {JavascriptParserOptions} options parser options
|
|
@@ -73,16 +75,16 @@ class CommonJsImportsParserPlugin {
|
|
|
73
75
|
parser.hooks.typeof
|
|
74
76
|
.for(expression)
|
|
75
77
|
.tap(
|
|
76
|
-
|
|
78
|
+
PLUGIN_NAME,
|
|
77
79
|
toConstantDependency(parser, JSON.stringify("function"))
|
|
78
80
|
);
|
|
79
81
|
parser.hooks.evaluateTypeof
|
|
80
82
|
.for(expression)
|
|
81
|
-
.tap(
|
|
83
|
+
.tap(PLUGIN_NAME, evaluateToString("function"));
|
|
82
84
|
parser.hooks.evaluateIdentifier
|
|
83
85
|
.for(expression)
|
|
84
86
|
.tap(
|
|
85
|
-
|
|
87
|
+
PLUGIN_NAME,
|
|
86
88
|
evaluateToIdentifier(expression, "require", getMembers, true)
|
|
87
89
|
);
|
|
88
90
|
};
|
|
@@ -93,12 +95,12 @@ class CommonJsImportsParserPlugin {
|
|
|
93
95
|
parser.hooks.typeof
|
|
94
96
|
.for(tag)
|
|
95
97
|
.tap(
|
|
96
|
-
|
|
98
|
+
PLUGIN_NAME,
|
|
97
99
|
toConstantDependency(parser, JSON.stringify("function"))
|
|
98
100
|
);
|
|
99
101
|
parser.hooks.evaluateTypeof
|
|
100
102
|
.for(tag)
|
|
101
|
-
.tap(
|
|
103
|
+
.tap(PLUGIN_NAME, evaluateToString("function"));
|
|
102
104
|
};
|
|
103
105
|
tapRequireExpression("require", () => []);
|
|
104
106
|
tapRequireExpression("require.resolve", () => ["resolve"]);
|
|
@@ -106,21 +108,19 @@ class CommonJsImportsParserPlugin {
|
|
|
106
108
|
// #endregion
|
|
107
109
|
|
|
108
110
|
// Weird stuff //
|
|
109
|
-
parser.hooks.assign
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return true;
|
|
117
|
-
});
|
|
111
|
+
parser.hooks.assign.for("require").tap(PLUGIN_NAME, expr => {
|
|
112
|
+
// to not leak to global "require", we need to define a local require here.
|
|
113
|
+
const dep = new ConstDependency("var require;", 0);
|
|
114
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
115
|
+
parser.state.module.addPresentationalDependency(dep);
|
|
116
|
+
return true;
|
|
117
|
+
});
|
|
118
118
|
|
|
119
119
|
// #region Unsupported
|
|
120
120
|
parser.hooks.expression
|
|
121
121
|
.for("require.main")
|
|
122
122
|
.tap(
|
|
123
|
-
|
|
123
|
+
PLUGIN_NAME,
|
|
124
124
|
expressionIsUnsupported(
|
|
125
125
|
parser,
|
|
126
126
|
"require.main is not supported by webpack."
|
|
@@ -129,7 +129,7 @@ class CommonJsImportsParserPlugin {
|
|
|
129
129
|
parser.hooks.call
|
|
130
130
|
.for("require.main.require")
|
|
131
131
|
.tap(
|
|
132
|
-
|
|
132
|
+
PLUGIN_NAME,
|
|
133
133
|
expressionIsUnsupported(
|
|
134
134
|
parser,
|
|
135
135
|
"require.main.require is not supported by webpack."
|
|
@@ -138,7 +138,7 @@ class CommonJsImportsParserPlugin {
|
|
|
138
138
|
parser.hooks.expression
|
|
139
139
|
.for("module.parent.require")
|
|
140
140
|
.tap(
|
|
141
|
-
|
|
141
|
+
PLUGIN_NAME,
|
|
142
142
|
expressionIsUnsupported(
|
|
143
143
|
parser,
|
|
144
144
|
"module.parent.require is not supported by webpack."
|
|
@@ -147,7 +147,7 @@ class CommonJsImportsParserPlugin {
|
|
|
147
147
|
parser.hooks.call
|
|
148
148
|
.for("module.parent.require")
|
|
149
149
|
.tap(
|
|
150
|
-
|
|
150
|
+
PLUGIN_NAME,
|
|
151
151
|
expressionIsUnsupported(
|
|
152
152
|
parser,
|
|
153
153
|
"module.parent.require is not supported by webpack."
|
|
@@ -170,12 +170,8 @@ class CommonJsImportsParserPlugin {
|
|
|
170
170
|
parser.state.module.addPresentationalDependency(dep);
|
|
171
171
|
return false;
|
|
172
172
|
};
|
|
173
|
-
parser.hooks.canRename
|
|
174
|
-
|
|
175
|
-
.tap("CommonJsImportsParserPlugin", () => true);
|
|
176
|
-
parser.hooks.rename
|
|
177
|
-
.for("require")
|
|
178
|
-
.tap("CommonJsImportsParserPlugin", defineUndefined);
|
|
173
|
+
parser.hooks.canRename.for("require").tap(PLUGIN_NAME, () => true);
|
|
174
|
+
parser.hooks.rename.for("require").tap(PLUGIN_NAME, defineUndefined);
|
|
179
175
|
// #endregion
|
|
180
176
|
|
|
181
177
|
// #region Inspection
|
|
@@ -189,9 +185,7 @@ class CommonJsImportsParserPlugin {
|
|
|
189
185
|
]
|
|
190
186
|
);
|
|
191
187
|
|
|
192
|
-
parser.hooks.expression
|
|
193
|
-
.for("require.cache")
|
|
194
|
-
.tap("CommonJsImportsParserPlugin", requireCache);
|
|
188
|
+
parser.hooks.expression.for("require.cache").tap(PLUGIN_NAME, requireCache);
|
|
195
189
|
// #endregion
|
|
196
190
|
|
|
197
191
|
// #region Require as expression
|
|
@@ -222,7 +216,7 @@ class CommonJsImportsParserPlugin {
|
|
|
222
216
|
};
|
|
223
217
|
parser.hooks.expression
|
|
224
218
|
.for("require")
|
|
225
|
-
.tap(
|
|
219
|
+
.tap(PLUGIN_NAME, requireAsExpressionHandler);
|
|
226
220
|
// #endregion
|
|
227
221
|
|
|
228
222
|
// #region Require
|
|
@@ -357,16 +351,16 @@ class CommonJsImportsParserPlugin {
|
|
|
357
351
|
};
|
|
358
352
|
parser.hooks.call
|
|
359
353
|
.for("require")
|
|
360
|
-
.tap(
|
|
354
|
+
.tap(PLUGIN_NAME, createRequireHandler(false));
|
|
361
355
|
parser.hooks.new
|
|
362
356
|
.for("require")
|
|
363
|
-
.tap(
|
|
357
|
+
.tap(PLUGIN_NAME, createRequireHandler(true));
|
|
364
358
|
parser.hooks.call
|
|
365
359
|
.for("module.require")
|
|
366
|
-
.tap(
|
|
360
|
+
.tap(PLUGIN_NAME, createRequireHandler(false));
|
|
367
361
|
parser.hooks.new
|
|
368
362
|
.for("module.require")
|
|
369
|
-
.tap(
|
|
363
|
+
.tap(PLUGIN_NAME, createRequireHandler(true));
|
|
370
364
|
// #endregion
|
|
371
365
|
|
|
372
366
|
// #region Require with property access
|
|
@@ -446,16 +440,16 @@ class CommonJsImportsParserPlugin {
|
|
|
446
440
|
};
|
|
447
441
|
parser.hooks.memberChainOfCallMemberChain
|
|
448
442
|
.for("require")
|
|
449
|
-
.tap(
|
|
443
|
+
.tap(PLUGIN_NAME, chainHandler);
|
|
450
444
|
parser.hooks.memberChainOfCallMemberChain
|
|
451
445
|
.for("module.require")
|
|
452
|
-
.tap(
|
|
446
|
+
.tap(PLUGIN_NAME, chainHandler);
|
|
453
447
|
parser.hooks.callMemberChainOfCallMemberChain
|
|
454
448
|
.for("require")
|
|
455
|
-
.tap(
|
|
449
|
+
.tap(PLUGIN_NAME, callChainHandler);
|
|
456
450
|
parser.hooks.callMemberChainOfCallMemberChain
|
|
457
451
|
.for("module.require")
|
|
458
|
-
.tap(
|
|
452
|
+
.tap(PLUGIN_NAME, callChainHandler);
|
|
459
453
|
// #endregion
|
|
460
454
|
|
|
461
455
|
// #region Require.resolve
|
|
@@ -573,10 +567,10 @@ class CommonJsImportsParserPlugin {
|
|
|
573
567
|
|
|
574
568
|
parser.hooks.call
|
|
575
569
|
.for("require.resolve")
|
|
576
|
-
.tap(
|
|
570
|
+
.tap(PLUGIN_NAME, expr => processResolve(expr, false));
|
|
577
571
|
parser.hooks.call
|
|
578
572
|
.for("require.resolveWeak")
|
|
579
|
-
.tap(
|
|
573
|
+
.tap(PLUGIN_NAME, expr => processResolve(expr, true));
|
|
580
574
|
// #endregion
|
|
581
575
|
|
|
582
576
|
// #region Create require
|
|
@@ -613,7 +607,7 @@ class CommonJsImportsParserPlugin {
|
|
|
613
607
|
tapRequireExpressionTag(createRequireSpecifierTag);
|
|
614
608
|
parser.hooks.evaluateCallExpression
|
|
615
609
|
.for(createRequireSpecifierTag)
|
|
616
|
-
.tap(
|
|
610
|
+
.tap(PLUGIN_NAME, expr => {
|
|
617
611
|
const context = parseCreateRequireArguments(expr);
|
|
618
612
|
if (context === undefined) return;
|
|
619
613
|
const ident = parser.evaluatedVariable({
|
|
@@ -629,7 +623,7 @@ class CommonJsImportsParserPlugin {
|
|
|
629
623
|
});
|
|
630
624
|
parser.hooks.unhandledExpressionMemberChain
|
|
631
625
|
.for(createdRequireIdentifierTag)
|
|
632
|
-
.tap(
|
|
626
|
+
.tap(PLUGIN_NAME, (expr, members) =>
|
|
633
627
|
expressionIsUnsupported(
|
|
634
628
|
parser,
|
|
635
629
|
`createRequire().${members.join(".")} is not supported by webpack.`
|
|
@@ -637,19 +631,19 @@ class CommonJsImportsParserPlugin {
|
|
|
637
631
|
);
|
|
638
632
|
parser.hooks.canRename
|
|
639
633
|
.for(createdRequireIdentifierTag)
|
|
640
|
-
.tap(
|
|
634
|
+
.tap(PLUGIN_NAME, () => true);
|
|
641
635
|
parser.hooks.canRename
|
|
642
636
|
.for(createRequireSpecifierTag)
|
|
643
|
-
.tap(
|
|
637
|
+
.tap(PLUGIN_NAME, () => true);
|
|
644
638
|
parser.hooks.rename
|
|
645
639
|
.for(createRequireSpecifierTag)
|
|
646
|
-
.tap(
|
|
640
|
+
.tap(PLUGIN_NAME, defineUndefined);
|
|
647
641
|
parser.hooks.expression
|
|
648
642
|
.for(createdRequireIdentifierTag)
|
|
649
|
-
.tap(
|
|
643
|
+
.tap(PLUGIN_NAME, requireAsExpressionHandler);
|
|
650
644
|
parser.hooks.call
|
|
651
645
|
.for(createdRequireIdentifierTag)
|
|
652
|
-
.tap(
|
|
646
|
+
.tap(PLUGIN_NAME, createRequireHandler(false));
|
|
653
647
|
/**
|
|
654
648
|
* @param {CallExpression} expr call expression
|
|
655
649
|
* @returns {string | void} context
|
|
@@ -683,7 +677,7 @@ class CommonJsImportsParserPlugin {
|
|
|
683
677
|
|
|
684
678
|
parser.hooks.import.tap(
|
|
685
679
|
{
|
|
686
|
-
name:
|
|
680
|
+
name: PLUGIN_NAME,
|
|
687
681
|
stage: -10
|
|
688
682
|
},
|
|
689
683
|
(statement, source) => {
|
|
@@ -693,8 +687,9 @@ class CommonJsImportsParserPlugin {
|
|
|
693
687
|
statement.specifiers[0].type !== "ImportSpecifier" ||
|
|
694
688
|
statement.specifiers[0].imported.type !== "Identifier" ||
|
|
695
689
|
statement.specifiers[0].imported.name !== specifierName
|
|
696
|
-
)
|
|
690
|
+
) {
|
|
697
691
|
return;
|
|
692
|
+
}
|
|
698
693
|
// clear for 'import { createRequire as x } from "module"'
|
|
699
694
|
// if any other specifier was used import module
|
|
700
695
|
const clearDep = new ConstDependency(
|
|
@@ -711,7 +706,7 @@ class CommonJsImportsParserPlugin {
|
|
|
711
706
|
);
|
|
712
707
|
parser.hooks.importSpecifier.tap(
|
|
713
708
|
{
|
|
714
|
-
name:
|
|
709
|
+
name: PLUGIN_NAME,
|
|
715
710
|
stage: -10
|
|
716
711
|
},
|
|
717
712
|
(statement, source, id, name) => {
|
|
@@ -720,70 +715,62 @@ class CommonJsImportsParserPlugin {
|
|
|
720
715
|
return true;
|
|
721
716
|
}
|
|
722
717
|
);
|
|
723
|
-
parser.hooks.preDeclarator.tap(
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
)
|
|
732
|
-
return;
|
|
733
|
-
const variableInfo = parser.getVariableInfo(
|
|
734
|
-
declarator.init.callee.name
|
|
735
|
-
);
|
|
736
|
-
if (
|
|
737
|
-
variableInfo instanceof VariableInfo &&
|
|
738
|
-
variableInfo.tagInfo &&
|
|
739
|
-
variableInfo.tagInfo.tag === createRequireSpecifierTag
|
|
740
|
-
) {
|
|
741
|
-
const context = parseCreateRequireArguments(declarator.init);
|
|
742
|
-
if (context === undefined) return;
|
|
743
|
-
parser.tagVariable(declarator.id.name, createdRequireIdentifierTag, {
|
|
744
|
-
name: declarator.id.name,
|
|
745
|
-
context
|
|
746
|
-
});
|
|
747
|
-
return true;
|
|
748
|
-
}
|
|
718
|
+
parser.hooks.preDeclarator.tap(PLUGIN_NAME, declarator => {
|
|
719
|
+
if (
|
|
720
|
+
declarator.id.type !== "Identifier" ||
|
|
721
|
+
!declarator.init ||
|
|
722
|
+
declarator.init.type !== "CallExpression" ||
|
|
723
|
+
declarator.init.callee.type !== "Identifier"
|
|
724
|
+
) {
|
|
725
|
+
return;
|
|
749
726
|
}
|
|
750
|
-
|
|
727
|
+
const variableInfo = parser.getVariableInfo(declarator.init.callee.name);
|
|
728
|
+
if (
|
|
729
|
+
variableInfo instanceof VariableInfo &&
|
|
730
|
+
variableInfo.tagInfo &&
|
|
731
|
+
variableInfo.tagInfo.tag === createRequireSpecifierTag
|
|
732
|
+
) {
|
|
733
|
+
const context = parseCreateRequireArguments(declarator.init);
|
|
734
|
+
if (context === undefined) return;
|
|
735
|
+
parser.tagVariable(declarator.id.name, createdRequireIdentifierTag, {
|
|
736
|
+
name: declarator.id.name,
|
|
737
|
+
context
|
|
738
|
+
});
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
751
742
|
|
|
752
743
|
parser.hooks.memberChainOfCallMemberChain
|
|
753
744
|
.for(createRequireSpecifierTag)
|
|
754
|
-
.tap(
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
)
|
|
762
|
-
return;
|
|
763
|
-
// createRequire().cache
|
|
764
|
-
const context = parseCreateRequireArguments(callExpr);
|
|
765
|
-
if (context === undefined) return;
|
|
766
|
-
return requireCache(expr);
|
|
745
|
+
.tap(PLUGIN_NAME, (expr, calleeMembers, callExpr, members) => {
|
|
746
|
+
if (
|
|
747
|
+
calleeMembers.length !== 0 ||
|
|
748
|
+
members.length !== 1 ||
|
|
749
|
+
members[0] !== "cache"
|
|
750
|
+
) {
|
|
751
|
+
return;
|
|
767
752
|
}
|
|
768
|
-
|
|
753
|
+
// createRequire().cache
|
|
754
|
+
const context = parseCreateRequireArguments(callExpr);
|
|
755
|
+
if (context === undefined) return;
|
|
756
|
+
return requireCache(expr);
|
|
757
|
+
});
|
|
769
758
|
parser.hooks.callMemberChainOfCallMemberChain
|
|
770
759
|
.for(createRequireSpecifierTag)
|
|
771
|
-
.tap(
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
)
|
|
779
|
-
return;
|
|
780
|
-
// createRequire().resolve()
|
|
781
|
-
return processResolve(expr, false);
|
|
760
|
+
.tap(PLUGIN_NAME, (expr, calleeMembers, innerCallExpression, members) => {
|
|
761
|
+
if (
|
|
762
|
+
calleeMembers.length !== 0 ||
|
|
763
|
+
members.length !== 1 ||
|
|
764
|
+
members[0] !== "resolve"
|
|
765
|
+
) {
|
|
766
|
+
return;
|
|
782
767
|
}
|
|
783
|
-
|
|
768
|
+
// createRequire().resolve()
|
|
769
|
+
return processResolve(expr, false);
|
|
770
|
+
});
|
|
784
771
|
parser.hooks.expressionMemberChain
|
|
785
772
|
.for(createdRequireIdentifierTag)
|
|
786
|
-
.tap(
|
|
773
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
787
774
|
// require.cache
|
|
788
775
|
if (members.length === 1 && members[0] === "cache") {
|
|
789
776
|
return requireCache(expr);
|
|
@@ -791,24 +778,23 @@ class CommonJsImportsParserPlugin {
|
|
|
791
778
|
});
|
|
792
779
|
parser.hooks.callMemberChain
|
|
793
780
|
.for(createdRequireIdentifierTag)
|
|
794
|
-
.tap(
|
|
781
|
+
.tap(PLUGIN_NAME, (expr, members) => {
|
|
795
782
|
// require.resolve()
|
|
796
783
|
if (members.length === 1 && members[0] === "resolve") {
|
|
797
784
|
return processResolve(expr, false);
|
|
798
785
|
}
|
|
799
786
|
});
|
|
800
|
-
parser.hooks.call
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
return true;
|
|
810
|
-
});
|
|
787
|
+
parser.hooks.call.for(createRequireSpecifierTag).tap(PLUGIN_NAME, expr => {
|
|
788
|
+
const clearDep = new ConstDependency(
|
|
789
|
+
"/* createRequire() */ undefined",
|
|
790
|
+
/** @type {Range} */ (expr.range)
|
|
791
|
+
);
|
|
792
|
+
clearDep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
793
|
+
parser.state.module.addPresentationalDependency(clearDep);
|
|
794
|
+
return true;
|
|
795
|
+
});
|
|
811
796
|
// #endregion
|
|
812
797
|
}
|
|
813
798
|
}
|
|
799
|
+
|
|
814
800
|
module.exports = CommonJsImportsParserPlugin;
|
|
@@ -5,12 +5,23 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const {
|
|
9
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
10
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
|
11
|
+
} = require("../ModuleTypeConstants");
|
|
8
12
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
13
|
const RuntimeModule = require("../RuntimeModule");
|
|
10
14
|
const SelfModuleFactory = require("../SelfModuleFactory");
|
|
11
15
|
const Template = require("../Template");
|
|
16
|
+
const {
|
|
17
|
+
evaluateToIdentifier,
|
|
18
|
+
toConstantDependency
|
|
19
|
+
} = require("../javascript/JavascriptParserHelpers");
|
|
20
|
+
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
|
12
21
|
const CommonJsExportsDependency = require("./CommonJsExportsDependency");
|
|
22
|
+
const CommonJsExportsParserPlugin = require("./CommonJsExportsParserPlugin");
|
|
13
23
|
const CommonJsFullRequireDependency = require("./CommonJsFullRequireDependency");
|
|
24
|
+
const CommonJsImportsParserPlugin = require("./CommonJsImportsParserPlugin");
|
|
14
25
|
const CommonJsRequireContextDependency = require("./CommonJsRequireContextDependency");
|
|
15
26
|
const CommonJsRequireDependency = require("./CommonJsRequireDependency");
|
|
16
27
|
const CommonJsSelfReferenceDependency = require("./CommonJsSelfReferenceDependency");
|
|
@@ -21,19 +32,6 @@ const RequireResolveDependency = require("./RequireResolveDependency");
|
|
|
21
32
|
const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");
|
|
22
33
|
const RuntimeRequirementsDependency = require("./RuntimeRequirementsDependency");
|
|
23
34
|
|
|
24
|
-
const CommonJsExportsParserPlugin = require("./CommonJsExportsParserPlugin");
|
|
25
|
-
const CommonJsImportsParserPlugin = require("./CommonJsImportsParserPlugin");
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
29
|
-
JAVASCRIPT_MODULE_TYPE_DYNAMIC
|
|
30
|
-
} = require("../ModuleTypeConstants");
|
|
31
|
-
const {
|
|
32
|
-
evaluateToIdentifier,
|
|
33
|
-
toConstantDependency
|
|
34
|
-
} = require("../javascript/JavascriptParserHelpers");
|
|
35
|
-
const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
|
|
36
|
-
|
|
37
35
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
38
36
|
/** @typedef {import("../Compilation")} Compilation */
|
|
39
37
|
/** @typedef {import("../Compiler")} Compiler */
|
|
@@ -158,7 +156,7 @@ class CommonJsPlugin {
|
|
|
158
156
|
|
|
159
157
|
compilation.hooks.runtimeRequirementInTree
|
|
160
158
|
.for(RuntimeGlobals.harmonyModuleDecorator)
|
|
161
|
-
.tap(PLUGIN_NAME, (chunk,
|
|
159
|
+
.tap(PLUGIN_NAME, (chunk, _set) => {
|
|
162
160
|
compilation.addRuntimeModule(
|
|
163
161
|
chunk,
|
|
164
162
|
new HarmonyModuleDecoratorRuntimeModule()
|
|
@@ -167,7 +165,7 @@ class CommonJsPlugin {
|
|
|
167
165
|
|
|
168
166
|
compilation.hooks.runtimeRequirementInTree
|
|
169
167
|
.for(RuntimeGlobals.nodeModuleDecorator)
|
|
170
|
-
.tap(PLUGIN_NAME, (chunk,
|
|
168
|
+
.tap(PLUGIN_NAME, (chunk, _set) => {
|
|
171
169
|
compilation.addRuntimeModule(
|
|
172
170
|
chunk,
|
|
173
171
|
new NodeModuleDecoratorRuntimeModule()
|
|
@@ -180,8 +178,9 @@ class CommonJsPlugin {
|
|
|
180
178
|
* @returns {void}
|
|
181
179
|
*/
|
|
182
180
|
const handler = (parser, parserOptions) => {
|
|
183
|
-
if (parserOptions.commonjs !== undefined && !parserOptions.commonjs)
|
|
181
|
+
if (parserOptions.commonjs !== undefined && !parserOptions.commonjs) {
|
|
184
182
|
return;
|
|
183
|
+
}
|
|
185
184
|
parser.hooks.typeof
|
|
186
185
|
.for("module")
|
|
187
186
|
.tap(
|
|
@@ -236,11 +236,12 @@ module.exports.create = (
|
|
|
236
236
|
|
|
237
237
|
if (parser && param.wrappedInnerExpressions) {
|
|
238
238
|
for (const part of param.wrappedInnerExpressions) {
|
|
239
|
-
if (part.expression)
|
|
239
|
+
if (part.expression) {
|
|
240
240
|
parser.walkExpression(
|
|
241
241
|
/** @type {Expression} */
|
|
242
242
|
(part.expression)
|
|
243
243
|
);
|
|
244
|
+
}
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
247
|
|
|
@@ -145,7 +145,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
|
|
145
145
|
.filter(Boolean)
|
|
146
146
|
);
|
|
147
147
|
|
|
148
|
-
for (const used of usedNames
|
|
148
|
+
for (const used of [...usedNames, ...names]) {
|
|
149
149
|
cssData.exports.set(used, dep.value);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -222,7 +222,7 @@ CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTempla
|
|
|
222
222
|
(generator.convention)
|
|
223
223
|
);
|
|
224
224
|
const usedNames =
|
|
225
|
-
/** @type {
|
|
225
|
+
/** @type {string[]} */
|
|
226
226
|
(
|
|
227
227
|
names
|
|
228
228
|
.map(name =>
|
|
@@ -239,7 +239,7 @@ CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTempla
|
|
|
239
239
|
|
|
240
240
|
source.replace(dep.range[0], dep.range[1] - 1, identifier);
|
|
241
241
|
|
|
242
|
-
for (const used of usedNames
|
|
242
|
+
for (const used of [...usedNames, ...names]) {
|
|
243
243
|
cssData.exports.set(used, getCssParser().unescapeIdentifier(identifier));
|
|
244
244
|
}
|
|
245
245
|
}
|
|
@@ -63,8 +63,9 @@ class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
|
|
63
63
|
* @returns {(string[] | ReferencedExport)[]} referenced exports
|
|
64
64
|
*/
|
|
65
65
|
getReferencedExports(moduleGraph, runtime) {
|
|
66
|
-
if (this.declaredSet && !this.declaredSet.has(this.name))
|
|
66
|
+
if (this.declaredSet && !this.declaredSet.has(this.name)) {
|
|
67
67
|
return Dependency.NO_EXPORTS_REFERENCED;
|
|
68
|
+
}
|
|
68
69
|
return [[this.name]];
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -42,14 +42,11 @@ module.exports.enable = parserState => {
|
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* @param {ParserState} parserState parser state
|
|
45
|
-
* @returns {
|
|
45
|
+
* @returns {boolean} true, when enabled
|
|
46
46
|
*/
|
|
47
|
-
module.exports.
|
|
47
|
+
module.exports.isEnabled = parserState => {
|
|
48
48
|
const value = parserStateExportsState.get(parserState);
|
|
49
|
-
|
|
50
|
-
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
|
51
|
-
if (buildMeta.exportsType === "dynamic") return;
|
|
52
|
-
buildMeta.exportsType = "flagged";
|
|
49
|
+
return value === true;
|
|
53
50
|
};
|
|
54
51
|
|
|
55
52
|
/**
|
|
@@ -65,9 +62,12 @@ module.exports.setDynamic = parserState => {
|
|
|
65
62
|
|
|
66
63
|
/**
|
|
67
64
|
* @param {ParserState} parserState parser state
|
|
68
|
-
* @returns {
|
|
65
|
+
* @returns {void}
|
|
69
66
|
*/
|
|
70
|
-
module.exports.
|
|
67
|
+
module.exports.setFlagged = parserState => {
|
|
71
68
|
const value = parserStateExportsState.get(parserState);
|
|
72
|
-
|
|
69
|
+
if (value !== true) return;
|
|
70
|
+
const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
|
|
71
|
+
if (buildMeta.exportsType === "dynamic") return;
|
|
72
|
+
buildMeta.exportsType = "flagged";
|
|
73
73
|
};
|