webpack 5.93.0 → 5.94.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +33 -20
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +75 -68
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +104 -64
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +126 -69
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +12 -10
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +84 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +14 -19
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +31 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +26 -24
- package/lib/css/CssGenerator.js +9 -4
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +7 -7
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +91 -69
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +8 -10
- package/lib/library/EnableLibraryPlugin.js +15 -14
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +8 -6
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +80 -48
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +1 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +8 -11
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +31 -31
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +103 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +15 -14
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +1 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/types.d.ts +667 -347
package/lib/css/walkCssTokens.js
CHANGED
@@ -80,14 +80,11 @@ const CC_GREATER_THAN_SIGN = ">".charCodeAt(0);
|
|
80
80
|
* @param {number} cc char code
|
81
81
|
* @returns {boolean} true, if cc is a newline
|
82
82
|
*/
|
83
|
-
const _isNewLine = cc =>
|
84
|
-
|
85
|
-
cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED
|
86
|
-
);
|
87
|
-
};
|
83
|
+
const _isNewLine = cc =>
|
84
|
+
cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED;
|
88
85
|
|
89
86
|
/** @type {CharHandler} */
|
90
|
-
const consumeSpace = (input, pos,
|
87
|
+
const consumeSpace = (input, pos, _callbacks) => {
|
91
88
|
/** @type {number} */
|
92
89
|
let cc;
|
93
90
|
do {
|
@@ -101,52 +98,39 @@ const consumeSpace = (input, pos, callbacks) => {
|
|
101
98
|
* @param {number} cc char code
|
102
99
|
* @returns {boolean} true, if cc is a newline
|
103
100
|
*/
|
104
|
-
const _isNewline = cc =>
|
105
|
-
|
106
|
-
cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED
|
107
|
-
);
|
108
|
-
};
|
101
|
+
const _isNewline = cc =>
|
102
|
+
cc === CC_LINE_FEED || cc === CC_CARRIAGE_RETURN || cc === CC_FORM_FEED;
|
109
103
|
|
110
104
|
/**
|
111
105
|
* @param {number} cc char code
|
112
106
|
* @returns {boolean} true, if cc is a space (U+0009 CHARACTER TABULATION or U+0020 SPACE)
|
113
107
|
*/
|
114
|
-
const _isSpace = cc =>
|
115
|
-
return cc === CC_TAB || cc === CC_SPACE;
|
116
|
-
};
|
108
|
+
const _isSpace = cc => cc === CC_TAB || cc === CC_SPACE;
|
117
109
|
|
118
110
|
/**
|
119
111
|
* @param {number} cc char code
|
120
112
|
* @returns {boolean} true, if cc is a whitespace
|
121
113
|
*/
|
122
|
-
const _isWhiteSpace = cc =>
|
123
|
-
return _isNewline(cc) || _isSpace(cc);
|
124
|
-
};
|
114
|
+
const _isWhiteSpace = cc => _isNewline(cc) || _isSpace(cc);
|
125
115
|
|
126
116
|
/**
|
127
117
|
* ident-start code point
|
128
118
|
*
|
129
119
|
* A letter, a non-ASCII code point, or U+005F LOW LINE (_).
|
130
|
-
*
|
131
120
|
* @param {number} cc char code
|
132
121
|
* @returns {boolean} true, if cc is a start code point of an identifier
|
133
122
|
*/
|
134
|
-
const isIdentStartCodePoint = cc =>
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
cc >= 0x80
|
140
|
-
);
|
141
|
-
};
|
123
|
+
const isIdentStartCodePoint = cc =>
|
124
|
+
(cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
|
125
|
+
(cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
|
126
|
+
cc === CC_LOW_LINE ||
|
127
|
+
cc >= 0x80;
|
142
128
|
|
143
129
|
/** @type {CharHandler} */
|
144
|
-
const consumeDelimToken = (input, pos,
|
145
|
-
return pos + 1;
|
146
|
-
};
|
130
|
+
const consumeDelimToken = (input, pos, _callbacks) => pos + 1;
|
147
131
|
|
148
132
|
/** @type {CharHandler} */
|
149
|
-
const consumeComments = (input, pos,
|
133
|
+
const consumeComments = (input, pos, _callbacks) => {
|
150
134
|
// If the next two input code point are U+002F SOLIDUS (/) followed by a U+002A
|
151
135
|
// ASTERISK (*), consume them and all following code points up to and including
|
152
136
|
// the first U+002A ASTERISK (*) followed by a U+002F SOLIDUS (/), or up to an
|
@@ -174,9 +158,9 @@ const consumeComments = (input, pos, callbacks) => {
|
|
174
158
|
};
|
175
159
|
|
176
160
|
/** @type {function(number): CharHandler} */
|
177
|
-
const consumeString =
|
161
|
+
const consumeString = quoteCc => (input, pos, callbacks) => {
|
178
162
|
const start = pos;
|
179
|
-
pos = _consumeString(input, pos,
|
163
|
+
pos = _consumeString(input, pos, quoteCc);
|
180
164
|
if (callbacks.string !== undefined) {
|
181
165
|
pos = callbacks.string(input, start, pos);
|
182
166
|
}
|
@@ -186,15 +170,15 @@ const consumeString = quote_cc => (input, pos, callbacks) => {
|
|
186
170
|
/**
|
187
171
|
* @param {string} input input
|
188
172
|
* @param {number} pos position
|
189
|
-
* @param {number}
|
173
|
+
* @param {number} quoteCc quote char code
|
190
174
|
* @returns {number} new position
|
191
175
|
*/
|
192
|
-
const _consumeString = (input, pos,
|
176
|
+
const _consumeString = (input, pos, quoteCc) => {
|
193
177
|
pos++;
|
194
178
|
for (;;) {
|
195
179
|
if (pos === input.length) return pos;
|
196
180
|
const cc = input.charCodeAt(pos);
|
197
|
-
if (cc ===
|
181
|
+
if (cc === quoteCc) return pos + 1;
|
198
182
|
if (_isNewLine(cc)) {
|
199
183
|
// bad string
|
200
184
|
return pos;
|
@@ -215,14 +199,11 @@ const _consumeString = (input, pos, quote_cc) => {
|
|
215
199
|
* @param {number} cc char code
|
216
200
|
* @returns {boolean} is identifier start code
|
217
201
|
*/
|
218
|
-
const _isIdentifierStartCode = cc =>
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
cc > 0x80
|
224
|
-
);
|
225
|
-
};
|
202
|
+
const _isIdentifierStartCode = cc =>
|
203
|
+
cc === CC_LOW_LINE ||
|
204
|
+
(cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
|
205
|
+
(cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
|
206
|
+
cc > 0x80;
|
226
207
|
|
227
208
|
/**
|
228
209
|
* @param {number} first first code point
|
@@ -239,9 +220,7 @@ const _isTwoCodePointsAreValidEscape = (first, second) => {
|
|
239
220
|
* @param {number} cc char code
|
240
221
|
* @returns {boolean} is digit
|
241
222
|
*/
|
242
|
-
const _isDigit = cc =>
|
243
|
-
return cc >= CC_0 && cc <= CC_9;
|
244
|
-
};
|
223
|
+
const _isDigit = cc => cc >= CC_0 && cc <= CC_9;
|
245
224
|
|
246
225
|
/**
|
247
226
|
* @param {string} input input
|
@@ -272,7 +251,11 @@ const consumeNumberSign = (input, pos, callbacks) => {
|
|
272
251
|
const start = pos;
|
273
252
|
pos++;
|
274
253
|
if (pos === input.length) return pos;
|
275
|
-
if (
|
254
|
+
if (
|
255
|
+
callbacks.isSelector &&
|
256
|
+
callbacks.isSelector(input, pos) &&
|
257
|
+
_startsIdentifier(input, pos)
|
258
|
+
) {
|
276
259
|
pos = _consumeIdentifier(input, pos, callbacks);
|
277
260
|
if (callbacks.id !== undefined) {
|
278
261
|
return callbacks.id(input, start, pos);
|
@@ -296,11 +279,10 @@ const consumeMinus = (input, pos, callbacks) => {
|
|
296
279
|
const cc = input.charCodeAt(pos);
|
297
280
|
if (cc === CC_GREATER_THAN_SIGN) {
|
298
281
|
return pos + 1;
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
}
|
282
|
+
}
|
283
|
+
pos = _consumeIdentifier(input, pos, callbacks);
|
284
|
+
if (callbacks.identifier !== undefined) {
|
285
|
+
return callbacks.identifier(input, start, pos);
|
304
286
|
}
|
305
287
|
} else if (cc === CC_REVERSE_SOLIDUS) {
|
306
288
|
if (pos + 1 === input.length) return pos;
|
@@ -323,7 +305,10 @@ const consumeDot = (input, pos, callbacks) => {
|
|
323
305
|
if (pos === input.length) return pos;
|
324
306
|
const cc = input.charCodeAt(pos);
|
325
307
|
if (_isDigit(cc)) return consumeNumericToken(input, pos - 2, callbacks);
|
326
|
-
if (
|
308
|
+
if (
|
309
|
+
(callbacks.isSelector && !callbacks.isSelector(input, pos)) ||
|
310
|
+
!_startsIdentifier(input, pos)
|
311
|
+
)
|
327
312
|
return pos;
|
328
313
|
pos = _consumeIdentifier(input, pos, callbacks);
|
329
314
|
if (callbacks.class !== undefined) return callbacks.class(input, start, pos);
|
@@ -350,10 +335,8 @@ const consumeOtherIdentifier = (input, pos, callbacks) => {
|
|
350
335
|
if (callbacks.function !== undefined) {
|
351
336
|
return callbacks.function(input, start, pos);
|
352
337
|
}
|
353
|
-
} else {
|
354
|
-
|
355
|
-
return callbacks.identifier(input, start, pos);
|
356
|
-
}
|
338
|
+
} else if (callbacks.identifier !== undefined) {
|
339
|
+
return callbacks.identifier(input, start, pos);
|
357
340
|
}
|
358
341
|
return pos;
|
359
342
|
};
|
@@ -379,43 +362,42 @@ const consumePotentialUrl = (input, pos, callbacks) => {
|
|
379
362
|
return callbacks.function(input, start, nextPos);
|
380
363
|
}
|
381
364
|
return nextPos;
|
382
|
-
}
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
365
|
+
}
|
366
|
+
const contentStart = pos;
|
367
|
+
/** @type {number} */
|
368
|
+
let contentEnd;
|
369
|
+
for (;;) {
|
370
|
+
if (cc === CC_REVERSE_SOLIDUS) {
|
371
|
+
pos++;
|
372
|
+
if (pos === input.length) return pos;
|
373
|
+
pos++;
|
374
|
+
} else if (_isWhiteSpace(cc)) {
|
375
|
+
contentEnd = pos;
|
376
|
+
do {
|
388
377
|
pos++;
|
389
378
|
if (pos === input.length) return pos;
|
390
|
-
pos
|
391
|
-
}
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
cc = input.charCodeAt(pos);
|
397
|
-
} while (_isWhiteSpace(cc));
|
398
|
-
if (cc !== CC_RIGHT_PARENTHESIS) return pos;
|
399
|
-
pos++;
|
400
|
-
if (callbacks.url !== undefined) {
|
401
|
-
return callbacks.url(input, start, pos, contentStart, contentEnd);
|
402
|
-
}
|
403
|
-
return pos;
|
404
|
-
} else if (cc === CC_RIGHT_PARENTHESIS) {
|
405
|
-
contentEnd = pos;
|
406
|
-
pos++;
|
407
|
-
if (callbacks.url !== undefined) {
|
408
|
-
return callbacks.url(input, start, pos, contentStart, contentEnd);
|
409
|
-
}
|
410
|
-
return pos;
|
411
|
-
} else if (cc === CC_LEFT_PARENTHESIS) {
|
412
|
-
return pos;
|
413
|
-
} else {
|
414
|
-
pos++;
|
379
|
+
cc = input.charCodeAt(pos);
|
380
|
+
} while (_isWhiteSpace(cc));
|
381
|
+
if (cc !== CC_RIGHT_PARENTHESIS) return pos;
|
382
|
+
pos++;
|
383
|
+
if (callbacks.url !== undefined) {
|
384
|
+
return callbacks.url(input, start, pos, contentStart, contentEnd);
|
415
385
|
}
|
416
|
-
|
417
|
-
|
386
|
+
return pos;
|
387
|
+
} else if (cc === CC_RIGHT_PARENTHESIS) {
|
388
|
+
contentEnd = pos;
|
389
|
+
pos++;
|
390
|
+
if (callbacks.url !== undefined) {
|
391
|
+
return callbacks.url(input, start, pos, contentStart, contentEnd);
|
392
|
+
}
|
393
|
+
return pos;
|
394
|
+
} else if (cc === CC_LEFT_PARENTHESIS) {
|
395
|
+
return pos;
|
396
|
+
} else {
|
397
|
+
pos++;
|
418
398
|
}
|
399
|
+
if (pos === input.length) return pos;
|
400
|
+
cc = input.charCodeAt(pos);
|
419
401
|
}
|
420
402
|
} else {
|
421
403
|
if (callbacks.identifier !== undefined) {
|
@@ -429,10 +411,13 @@ const consumePotentialUrl = (input, pos, callbacks) => {
|
|
429
411
|
const consumePotentialPseudo = (input, pos, callbacks) => {
|
430
412
|
const start = pos;
|
431
413
|
pos++;
|
432
|
-
if (
|
414
|
+
if (
|
415
|
+
(callbacks.isSelector && !callbacks.isSelector(input, pos)) ||
|
416
|
+
!_startsIdentifier(input, pos)
|
417
|
+
)
|
433
418
|
return pos;
|
434
419
|
pos = _consumeIdentifier(input, pos, callbacks);
|
435
|
-
|
420
|
+
const cc = input.charCodeAt(pos);
|
436
421
|
if (cc === CC_LEFT_PARENTHESIS) {
|
437
422
|
pos++;
|
438
423
|
if (callbacks.pseudoFunction !== undefined) {
|
@@ -574,7 +559,7 @@ const _consumeNumber = (input, pos) => {
|
|
574
559
|
};
|
575
560
|
|
576
561
|
/** @type {CharHandler} */
|
577
|
-
const consumeLessThan = (input, pos,
|
562
|
+
const consumeLessThan = (input, pos, _callbacks) => {
|
578
563
|
if (input.slice(pos + 1, pos + 4) === "!--") return pos + 4;
|
579
564
|
return pos + 1;
|
580
565
|
};
|
@@ -724,7 +709,7 @@ module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
|
|
724
709
|
*/
|
725
710
|
module.exports.eatComments = (input, pos) => {
|
726
711
|
for (;;) {
|
727
|
-
|
712
|
+
const originalPos = pos;
|
728
713
|
pos = consumeComments(input, pos, {});
|
729
714
|
if (originalPos === pos) {
|
730
715
|
break;
|
@@ -754,7 +739,7 @@ module.exports.eatWhitespace = (input, pos) => {
|
|
754
739
|
*/
|
755
740
|
module.exports.eatWhitespaceAndComments = (input, pos) => {
|
756
741
|
for (;;) {
|
757
|
-
|
742
|
+
const originalPos = pos;
|
758
743
|
pos = consumeComments(input, pos, {});
|
759
744
|
while (_isWhiteSpace(input.charCodeAt(pos))) {
|
760
745
|
pos++;
|
@@ -36,12 +36,12 @@ const validate = createSchemaValidation(
|
|
36
36
|
);
|
37
37
|
|
38
38
|
/** @type {Inspector | undefined} */
|
39
|
-
let inspector
|
39
|
+
let inspector;
|
40
40
|
|
41
41
|
try {
|
42
42
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
43
43
|
inspector = require("inspector");
|
44
|
-
} catch (
|
44
|
+
} catch (_err) {
|
45
45
|
console.log("Unable to CPU profile in < node 8.0");
|
46
46
|
}
|
47
47
|
|
@@ -92,7 +92,7 @@ class Profiler {
|
|
92
92
|
sendCommand(method, params) {
|
93
93
|
if (this.hasSession()) {
|
94
94
|
return new Promise((res, rej) => {
|
95
|
-
|
95
|
+
this.session.post(method, params, (err, params) => {
|
96
96
|
if (err !== null) {
|
97
97
|
rej(err);
|
98
98
|
} else {
|
@@ -100,9 +100,8 @@ class Profiler {
|
|
100
100
|
}
|
101
101
|
});
|
102
102
|
});
|
103
|
-
} else {
|
104
|
-
return Promise.resolve();
|
105
103
|
}
|
104
|
+
return Promise.resolve();
|
106
105
|
}
|
107
106
|
|
108
107
|
destroy() {
|
@@ -234,19 +233,20 @@ class ProfilingPlugin {
|
|
234
233
|
tracer.profiler.startProfiling();
|
235
234
|
|
236
235
|
// Compiler Hooks
|
237
|
-
Object.keys(compiler.hooks)
|
238
|
-
const hook =
|
236
|
+
for (const hookName of Object.keys(compiler.hooks)) {
|
237
|
+
const hook =
|
238
|
+
compiler.hooks[/** @type {keyof Compiler["hooks"]} */ (hookName)];
|
239
239
|
if (hook) {
|
240
240
|
hook.intercept(makeInterceptorFor("Compiler", tracer)(hookName));
|
241
241
|
}
|
242
|
-
}
|
242
|
+
}
|
243
243
|
|
244
|
-
Object.keys(compiler.resolverFactory.hooks)
|
244
|
+
for (const hookName of Object.keys(compiler.resolverFactory.hooks)) {
|
245
245
|
const hook = compiler.resolverFactory.hooks[hookName];
|
246
246
|
if (hook) {
|
247
247
|
hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName));
|
248
248
|
}
|
249
|
-
}
|
249
|
+
}
|
250
250
|
|
251
251
|
compiler.hooks.compilation.tap(
|
252
252
|
PLUGIN_NAME,
|
@@ -291,7 +291,9 @@ class ProfilingPlugin {
|
|
291
291
|
cat: ["toplevel"],
|
292
292
|
ts: cpuStartTime,
|
293
293
|
args: {
|
294
|
+
// eslint-disable-next-line camelcase
|
294
295
|
src_file: "../../ipc/ipc_moji_bootstrap.cc",
|
296
|
+
// eslint-disable-next-line camelcase
|
295
297
|
src_func: "Accept"
|
296
298
|
}
|
297
299
|
});
|
@@ -339,12 +341,12 @@ class ProfilingPlugin {
|
|
339
341
|
*/
|
340
342
|
const interceptAllHooksFor = (instance, tracer, logLabel) => {
|
341
343
|
if (Reflect.has(instance, "hooks")) {
|
342
|
-
Object.keys(instance.hooks)
|
344
|
+
for (const hookName of Object.keys(instance.hooks)) {
|
343
345
|
const hook = instance.hooks[hookName];
|
344
346
|
if (hook && !hook._fakeHook) {
|
345
347
|
hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName));
|
346
348
|
}
|
347
|
-
}
|
349
|
+
}
|
348
350
|
}
|
349
351
|
};
|
350
352
|
|
@@ -362,13 +364,13 @@ const interceptAllParserHooks = (moduleFactory, tracer) => {
|
|
362
364
|
WEBASSEMBLY_MODULE_TYPE_SYNC
|
363
365
|
];
|
364
366
|
|
365
|
-
|
367
|
+
for (const moduleType of moduleTypes) {
|
366
368
|
moduleFactory.hooks.parser
|
367
369
|
.for(moduleType)
|
368
370
|
.tap(PLUGIN_NAME, (parser, parserOpts) => {
|
369
371
|
interceptAllHooksFor(parser, tracer, "Parser");
|
370
372
|
});
|
371
|
-
}
|
373
|
+
}
|
372
374
|
};
|
373
375
|
|
374
376
|
/**
|
@@ -400,10 +402,7 @@ const makeInterceptorFor = (instance, tracer) => hookName => ({
|
|
400
402
|
type,
|
401
403
|
fn
|
402
404
|
});
|
403
|
-
return {
|
404
|
-
...tapInfo,
|
405
|
-
fn: newFn
|
406
|
-
};
|
405
|
+
return { ...tapInfo, fn: newFn };
|
407
406
|
}
|
408
407
|
});
|
409
408
|
|
@@ -476,13 +475,13 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => {
|
|
476
475
|
let r;
|
477
476
|
try {
|
478
477
|
r = fn(...args);
|
479
|
-
} catch (
|
478
|
+
} catch (err) {
|
480
479
|
tracer.trace.end({
|
481
480
|
name,
|
482
481
|
id,
|
483
482
|
cat: defaultCategory
|
484
483
|
});
|
485
|
-
throw
|
484
|
+
throw err;
|
486
485
|
}
|
487
486
|
tracer.trace.end({
|
488
487
|
name,
|
@@ -111,7 +111,7 @@ class AMDDefineDependency extends NullDependency {
|
|
111
111
|
* @param {Range | null} arrayRange array range
|
112
112
|
* @param {Range | null} functionRange function range
|
113
113
|
* @param {Range | null} objectRange object range
|
114
|
-
* @param {
|
114
|
+
* @param {string | null} namedModule true, when define is called with a name
|
115
115
|
*/
|
116
116
|
constructor(range, arrayRange, functionRange, objectRange, namedModule) {
|
117
117
|
super();
|