webpack 5.93.0 → 5.95.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.
Files changed (344) hide show
  1. package/README.md +8 -5
  2. package/bin/webpack.js +6 -7
  3. package/hot/log.js +1 -2
  4. package/hot/only-dev-server.js +1 -1
  5. package/hot/poll.js +1 -1
  6. package/hot/signal.js +1 -1
  7. package/lib/APIPlugin.js +4 -3
  8. package/lib/AbstractMethodError.js +10 -5
  9. package/lib/AutomaticPrefetchPlugin.js +1 -1
  10. package/lib/BannerPlugin.js +12 -6
  11. package/lib/Cache.js +8 -10
  12. package/lib/CacheFacade.js +3 -3
  13. package/lib/CaseSensitiveModulesWarning.js +5 -7
  14. package/lib/Chunk.js +14 -11
  15. package/lib/ChunkGraph.js +58 -36
  16. package/lib/ChunkGroup.js +2 -3
  17. package/lib/ChunkTemplate.js +43 -0
  18. package/lib/CleanPlugin.js +10 -11
  19. package/lib/CodeGenerationResults.js +6 -5
  20. package/lib/CommentCompilationWarning.js +0 -1
  21. package/lib/Compilation.js +223 -191
  22. package/lib/Compiler.js +81 -82
  23. package/lib/ConcatenationScope.js +3 -6
  24. package/lib/ConditionalInitFragment.js +6 -7
  25. package/lib/ConstPlugin.js +7 -15
  26. package/lib/ContextExclusionPlugin.js +3 -3
  27. package/lib/ContextModule.js +33 -20
  28. package/lib/ContextModuleFactory.js +89 -44
  29. package/lib/ContextReplacementPlugin.js +10 -9
  30. package/lib/DefinePlugin.js +75 -68
  31. package/lib/DelegatedModule.js +7 -3
  32. package/lib/DelegatedModuleFactoryPlugin.js +36 -22
  33. package/lib/DelegatedPlugin.js +4 -0
  34. package/lib/DependenciesBlock.js +0 -1
  35. package/lib/Dependency.js +10 -14
  36. package/lib/DllEntryPlugin.js +4 -2
  37. package/lib/DllModuleFactory.js +1 -0
  38. package/lib/DllPlugin.js +9 -7
  39. package/lib/DllReferencePlugin.js +30 -15
  40. package/lib/EntryPlugin.js +1 -3
  41. package/lib/EnvironmentPlugin.js +6 -2
  42. package/lib/ErrorHelpers.js +11 -12
  43. package/lib/EvalDevToolModulePlugin.js +10 -12
  44. package/lib/EvalSourceMapDevToolPlugin.js +15 -13
  45. package/lib/ExportsInfo.js +185 -120
  46. package/lib/ExternalModule.js +41 -15
  47. package/lib/ExternalModuleFactoryPlugin.js +23 -10
  48. package/lib/FileSystemInfo.js +791 -422
  49. package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
  50. package/lib/FlagDependencyExportsPlugin.js +12 -11
  51. package/lib/FlagDependencyUsagePlugin.js +1 -1
  52. package/lib/Generator.js +2 -5
  53. package/lib/GraphHelpers.js +3 -2
  54. package/lib/HookWebpackError.js +8 -10
  55. package/lib/HotModuleReplacementPlugin.js +78 -64
  56. package/lib/IgnoreErrorModuleFactory.js +3 -3
  57. package/lib/IgnorePlugin.js +1 -3
  58. package/lib/IgnoreWarningsPlugin.js +6 -9
  59. package/lib/InitFragment.js +2 -3
  60. package/lib/LibManifestPlugin.js +4 -3
  61. package/lib/MainTemplate.js +72 -19
  62. package/lib/Module.js +25 -9
  63. package/lib/ModuleBuildError.js +4 -11
  64. package/lib/ModuleDependencyError.js +5 -5
  65. package/lib/ModuleDependencyWarning.js +5 -5
  66. package/lib/ModuleError.js +1 -5
  67. package/lib/ModuleFilenameHelpers.js +29 -46
  68. package/lib/ModuleGraph.js +7 -6
  69. package/lib/ModuleGraphConnection.js +6 -6
  70. package/lib/ModuleInfoHeaderPlugin.js +82 -30
  71. package/lib/ModuleParseError.js +8 -9
  72. package/lib/ModuleRestoreError.js +1 -1
  73. package/lib/ModuleStoreError.js +1 -1
  74. package/lib/ModuleTemplate.js +33 -1
  75. package/lib/ModuleTypeConstants.js +21 -22
  76. package/lib/ModuleWarning.js +1 -5
  77. package/lib/MultiCompiler.js +24 -26
  78. package/lib/MultiStats.js +73 -31
  79. package/lib/MultiWatching.js +1 -1
  80. package/lib/NormalModule.js +130 -69
  81. package/lib/NormalModuleFactory.js +53 -49
  82. package/lib/OptimizationStages.js +3 -3
  83. package/lib/ProgressPlugin.js +9 -9
  84. package/lib/ProvidePlugin.js +4 -4
  85. package/lib/RuntimeGlobals.js +71 -70
  86. package/lib/RuntimeModule.js +1 -1
  87. package/lib/RuntimePlugin.js +24 -12
  88. package/lib/RuntimeTemplate.js +40 -44
  89. package/lib/SizeFormatHelpers.js +2 -4
  90. package/lib/SourceMapDevToolPlugin.js +42 -34
  91. package/lib/Stats.js +5 -11
  92. package/lib/Template.js +18 -24
  93. package/lib/TemplatedPathPlugin.js +21 -13
  94. package/lib/WarnDeprecatedOptionPlugin.js +0 -1
  95. package/lib/WatchIgnorePlugin.js +26 -9
  96. package/lib/Watching.js +10 -5
  97. package/lib/WebpackOptionsApply.js +84 -62
  98. package/lib/asset/AssetGenerator.js +107 -42
  99. package/lib/asset/AssetModulesPlugin.js +29 -23
  100. package/lib/asset/AssetSourceGenerator.js +2 -7
  101. package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
  102. package/lib/buildChunkGraph.js +93 -81
  103. package/lib/cache/IdleFileCachePlugin.js +4 -4
  104. package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
  105. package/lib/cache/PackFileCacheStrategy.js +51 -50
  106. package/lib/cache/ResolverCachePlugin.js +6 -6
  107. package/lib/cache/mergeEtags.js +16 -21
  108. package/lib/cli.js +148 -104
  109. package/lib/config/browserslistTargetHandler.js +16 -13
  110. package/lib/config/defaults.js +32 -28
  111. package/lib/config/normalization.js +335 -344
  112. package/lib/config/target.js +42 -52
  113. package/lib/container/ContainerEntryModule.js +2 -2
  114. package/lib/container/ContainerPlugin.js +1 -1
  115. package/lib/container/RemoteRuntimeModule.js +11 -8
  116. package/lib/container/options.js +18 -4
  117. package/lib/css/CssExportsGenerator.js +26 -24
  118. package/lib/css/CssGenerator.js +9 -4
  119. package/lib/css/CssLoadingRuntimeModule.js +10 -10
  120. package/lib/css/CssModulesPlugin.js +127 -47
  121. package/lib/css/CssParser.js +20 -18
  122. package/lib/css/walkCssTokens.js +80 -95
  123. package/lib/debug/ProfilingPlugin.js +19 -20
  124. package/lib/dependencies/AMDDefineDependency.js +1 -1
  125. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
  126. package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
  127. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
  128. package/lib/dependencies/AMDRuntimeModules.js +2 -2
  129. package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
  130. package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
  131. package/lib/dependencies/CommonJsExportsDependency.js +0 -1
  132. package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
  133. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  134. package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
  135. package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
  136. package/lib/dependencies/ConstDependency.js +1 -1
  137. package/lib/dependencies/ContextDependency.js +7 -2
  138. package/lib/dependencies/ContextDependencyHelpers.js +31 -34
  139. package/lib/dependencies/ContextElementDependency.js +35 -8
  140. package/lib/dependencies/CriticalDependencyWarning.js +1 -1
  141. package/lib/dependencies/CssExportDependency.js +7 -7
  142. package/lib/dependencies/CssImportDependency.js +0 -2
  143. package/lib/dependencies/CssLocalIdentifierDependency.js +3 -3
  144. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  145. package/lib/dependencies/CssUrlDependency.js +4 -5
  146. package/lib/dependencies/DynamicExports.js +5 -5
  147. package/lib/dependencies/ExportsInfoDependency.js +1 -2
  148. package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
  149. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
  150. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
  151. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  152. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
  153. package/lib/dependencies/HarmonyExports.js +2 -2
  154. package/lib/dependencies/HarmonyImportDependency.js +2 -4
  155. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
  156. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -15
  157. package/lib/dependencies/ImportDependency.js +1 -1
  158. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
  159. package/lib/dependencies/ImportMetaPlugin.js +11 -13
  160. package/lib/dependencies/ImportParserPlugin.js +39 -44
  161. package/lib/dependencies/JsonExportsDependency.js +22 -18
  162. package/lib/dependencies/LoaderPlugin.js +47 -36
  163. package/lib/dependencies/LocalModule.js +1 -1
  164. package/lib/dependencies/LocalModulesHelpers.js +4 -4
  165. package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
  166. package/lib/dependencies/ProvidedDependency.js +1 -1
  167. package/lib/dependencies/PureExpressionDependency.js +6 -6
  168. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  169. package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
  170. package/lib/dependencies/SystemPlugin.js +1 -1
  171. package/lib/dependencies/URLDependency.js +3 -3
  172. package/lib/dependencies/URLPlugin.js +66 -12
  173. package/lib/dependencies/WorkerPlugin.js +25 -24
  174. package/lib/dependencies/processExportInfo.js +3 -1
  175. package/lib/electron/ElectronTargetPlugin.js +1 -0
  176. package/lib/esm/ModuleChunkFormatPlugin.js +3 -3
  177. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
  178. package/lib/formatLocation.js +1 -2
  179. package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
  180. package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
  181. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
  182. package/lib/hmr/LazyCompilationPlugin.js +27 -12
  183. package/lib/hmr/lazyCompilationBackend.js +64 -40
  184. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
  185. package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
  186. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  187. package/lib/ids/HashedModuleIdsPlugin.js +5 -1
  188. package/lib/ids/IdHelpers.js +29 -39
  189. package/lib/ids/SyncModuleIdsPlugin.js +7 -2
  190. package/lib/index.js +1 -5
  191. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +5 -4
  192. package/lib/javascript/BasicEvaluatedExpression.js +4 -19
  193. package/lib/javascript/ChunkHelpers.js +1 -1
  194. package/lib/javascript/CommonJsChunkFormatPlugin.js +3 -2
  195. package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
  196. package/lib/javascript/JavascriptGenerator.js +23 -7
  197. package/lib/javascript/JavascriptModulesPlugin.js +133 -86
  198. package/lib/javascript/JavascriptParser.js +179 -200
  199. package/lib/javascript/JavascriptParserHelpers.js +20 -21
  200. package/lib/javascript/StartupHelpers.js +41 -13
  201. package/lib/json/JsonGenerator.js +7 -13
  202. package/lib/json/JsonModulesPlugin.js +1 -4
  203. package/lib/json/JsonParser.js +5 -3
  204. package/lib/library/AmdLibraryPlugin.js +12 -16
  205. package/lib/library/AssignLibraryPlugin.js +8 -10
  206. package/lib/library/EnableLibraryPlugin.js +15 -14
  207. package/lib/library/JsonpLibraryPlugin.js +2 -1
  208. package/lib/library/ModernModuleLibraryPlugin.js +8 -6
  209. package/lib/library/ModuleLibraryPlugin.js +2 -1
  210. package/lib/library/SystemLibraryPlugin.js +2 -1
  211. package/lib/library/UmdLibraryPlugin.js +66 -92
  212. package/lib/logging/Logger.js +32 -4
  213. package/lib/logging/createConsoleLogger.js +12 -13
  214. package/lib/logging/runtime.js +7 -8
  215. package/lib/logging/truncateArgs.js +5 -8
  216. package/lib/node/NodeWatchFileSystem.js +3 -18
  217. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  218. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
  219. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  220. package/lib/node/nodeConsole.js +22 -22
  221. package/lib/optimize/AggressiveMergingPlugin.js +2 -4
  222. package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
  223. package/lib/optimize/ConcatenatedModule.js +81 -51
  224. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  225. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
  226. package/lib/optimize/InnerGraph.js +17 -17
  227. package/lib/optimize/InnerGraphPlugin.js +8 -7
  228. package/lib/optimize/LimitChunkCountPlugin.js +2 -3
  229. package/lib/optimize/MangleExportsPlugin.js +1 -0
  230. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  231. package/lib/optimize/MinMaxSizeWarning.js +1 -1
  232. package/lib/optimize/ModuleConcatenationPlugin.js +54 -78
  233. package/lib/optimize/RealContentHashPlugin.js +7 -10
  234. package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
  235. package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
  236. package/lib/optimize/SplitChunksPlugin.js +34 -30
  237. package/lib/performance/SizeLimitsPlugin.js +2 -2
  238. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
  239. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
  240. package/lib/rules/BasicEffectRulePlugin.js +3 -1
  241. package/lib/rules/BasicMatcherRulePlugin.js +3 -1
  242. package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
  243. package/lib/rules/RuleSetCompiler.js +41 -22
  244. package/lib/rules/UseEffectRulePlugin.js +36 -32
  245. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
  246. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  247. package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
  248. package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
  249. package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
  250. package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
  251. package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
  252. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
  253. package/lib/schemes/DataUriPlugin.js +1 -1
  254. package/lib/schemes/HttpUriPlugin.js +241 -126
  255. package/lib/serialization/BinaryMiddleware.js +44 -28
  256. package/lib/serialization/DateObjectSerializer.js +1 -0
  257. package/lib/serialization/ErrorObjectSerializer.js +2 -0
  258. package/lib/serialization/FileMiddleware.js +154 -106
  259. package/lib/serialization/MapObjectSerializer.js +2 -1
  260. package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
  261. package/lib/serialization/ObjectMiddleware.js +52 -56
  262. package/lib/serialization/PlainObjectSerializer.js +32 -6
  263. package/lib/serialization/RegExpObjectSerializer.js +1 -0
  264. package/lib/serialization/Serializer.js +4 -5
  265. package/lib/serialization/SerializerMiddleware.js +6 -6
  266. package/lib/serialization/SetObjectSerializer.js +2 -1
  267. package/lib/sharing/ConsumeSharedPlugin.js +116 -97
  268. package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
  269. package/lib/sharing/ProvideForSharedDependency.js +0 -1
  270. package/lib/sharing/ProvideSharedPlugin.js +2 -2
  271. package/lib/sharing/resolveMatchedConfigs.js +2 -1
  272. package/lib/sharing/utils.js +15 -27
  273. package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
  274. package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
  275. package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
  276. package/lib/stats/StatsFactory.js +127 -56
  277. package/lib/stats/StatsPrinter.js +75 -44
  278. package/lib/util/ArrayHelpers.js +8 -4
  279. package/lib/util/ArrayQueue.js +1 -1
  280. package/lib/util/AsyncQueue.js +31 -12
  281. package/lib/util/IterableHelpers.js +3 -4
  282. package/lib/util/LazyBucketSortedSet.js +60 -44
  283. package/lib/util/LazySet.js +13 -0
  284. package/lib/util/MapHelpers.js +1 -3
  285. package/lib/util/ParallelismFactorCalculator.js +1 -1
  286. package/lib/util/Queue.js +1 -1
  287. package/lib/util/Semaphore.js +4 -7
  288. package/lib/util/SetHelpers.js +5 -5
  289. package/lib/util/SortableSet.js +4 -3
  290. package/lib/util/StackedCacheMap.js +4 -6
  291. package/lib/util/StackedMap.js +1 -3
  292. package/lib/util/StringXor.js +0 -5
  293. package/lib/util/TupleQueue.js +1 -1
  294. package/lib/util/TupleSet.js +15 -5
  295. package/lib/util/URLAbsoluteSpecifier.js +7 -7
  296. package/lib/util/WeakTupleMap.js +19 -21
  297. package/lib/util/binarySearchBounds.js +5 -12
  298. package/lib/util/chainedImports.js +1 -1
  299. package/lib/util/cleverMerge.js +21 -19
  300. package/lib/util/comparators.js +57 -52
  301. package/lib/util/compileBooleanMatcher.js +3 -6
  302. package/lib/util/conventions.js +8 -11
  303. package/lib/util/createHash.js +9 -6
  304. package/lib/util/deprecation.js +22 -12
  305. package/lib/util/deterministicGrouping.js +19 -26
  306. package/lib/util/findGraphRoots.js +2 -2
  307. package/lib/util/fs.js +32 -32
  308. package/lib/util/hash/md4.js +2 -2
  309. package/lib/util/hash/wasm-hash.js +7 -7
  310. package/lib/util/hash/xxhash64.js +2 -2
  311. package/lib/util/identifier.js +81 -59
  312. package/lib/util/memoize.js +8 -10
  313. package/lib/util/mergeScope.js +6 -9
  314. package/lib/util/nonNumericOnlyHash.js +2 -2
  315. package/lib/util/numberHash.js +1 -6
  316. package/lib/util/objectToMap.js +0 -1
  317. package/lib/util/propertyAccess.js +2 -5
  318. package/lib/util/propertyName.js +1 -3
  319. package/lib/util/registerExternalSerializer.js +1 -1
  320. package/lib/util/runtime.js +109 -113
  321. package/lib/util/semver.js +29 -27
  322. package/lib/util/serialization.js +16 -1
  323. package/lib/util/smartGrouping.js +5 -5
  324. package/lib/util/source.js +1 -1
  325. package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
  326. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  327. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
  328. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  329. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
  330. package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
  331. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  332. package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
  333. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
  334. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
  335. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  336. package/package.json +18 -17
  337. package/schemas/WebpackOptions.check.js +1 -1
  338. package/schemas/WebpackOptions.json +5 -0
  339. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  340. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  341. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  342. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  343. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  344. package/types.d.ts +681 -355
@@ -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
- return (
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, callbacks) => {
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
- return (
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
- return (
136
- (cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
137
- (cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
138
- cc === CC_LOW_LINE ||
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, callbacks) => {
145
- return pos + 1;
146
- };
130
+ const consumeDelimToken = (input, pos, _callbacks) => pos + 1;
147
131
 
148
132
  /** @type {CharHandler} */
149
- const consumeComments = (input, pos, callbacks) => {
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 = quote_cc => (input, pos, callbacks) => {
161
+ const consumeString = quoteCc => (input, pos, callbacks) => {
178
162
  const start = pos;
179
- pos = _consumeString(input, pos, quote_cc);
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} quote_cc quote char code
173
+ * @param {number} quoteCc quote char code
190
174
  * @returns {number} new position
191
175
  */
192
- const _consumeString = (input, pos, quote_cc) => {
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 === quote_cc) return pos + 1;
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
- return (
220
- cc === CC_LOW_LINE ||
221
- (cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
222
- (cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
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 (callbacks.isSelector(input, pos) && _startsIdentifier(input, pos)) {
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
- } else {
300
- pos = _consumeIdentifier(input, pos, callbacks);
301
- if (callbacks.identifier !== undefined) {
302
- return callbacks.identifier(input, start, pos);
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 (!callbacks.isSelector(input, pos) || !_startsIdentifier(input, pos))
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
- if (callbacks.identifier !== undefined) {
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
- } else {
383
- const contentStart = pos;
384
- /** @type {number} */
385
- let contentEnd;
386
- for (;;) {
387
- if (cc === CC_REVERSE_SOLIDUS) {
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
- } else if (_isWhiteSpace(cc)) {
392
- contentEnd = pos;
393
- do {
394
- pos++;
395
- if (pos === input.length) return pos;
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
- if (pos === input.length) return pos;
417
- cc = input.charCodeAt(pos);
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 (!callbacks.isSelector(input, pos) || !_startsIdentifier(input, pos))
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
- let cc = input.charCodeAt(pos);
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, callbacks) => {
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
- let originalPos = pos;
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
- let originalPos = pos;
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 = undefined;
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 (e) {
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
- return this.session.post(method, params, (err, params) => {
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).forEach(hookName => {
238
- const hook = compiler.hooks[hookName];
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).forEach(hookName => {
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).forEach(hookName => {
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
- moduleTypes.forEach(moduleType => {
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 (error) {
478
+ } catch (err) {
480
479
  tracer.trace.end({
481
480
  name,
482
481
  id,
483
482
  cat: defaultCategory
484
483
  });
485
- throw error;
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 {boolean | null} namedModule true, when define is called with a name
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();