Showing with 4,182 additions and 935 deletions.
  1. +1 −1 .eslintrc.js
  2. +17 −14 .github/workflows/test.yml
  3. +21 −17 README.md
  4. +6 −0 declarations/LoaderContext.d.ts
  5. +27 −2 declarations/WebpackOptions.d.ts
  6. +4 −0 declarations/plugins/BannerPlugin.d.ts
  7. +1 −1 examples/template-common.js
  8. +17 −4 hot/dev-server.js
  9. +1 −1 hot/poll.js
  10. +1 −1 hot/signal.js
  11. +4 −2 lib/BannerPlugin.js
  12. +1 −1 lib/Chunk.js
  13. +93 −6 lib/ChunkGraph.js
  14. +1 −1 lib/ChunkGroup.js
  15. +19 −10 lib/Compilation.js
  16. +17 −4 lib/Compiler.js
  17. +2 −2 lib/ConstPlugin.js
  18. +31 −8 lib/ContextModule.js
  19. +7 −11 lib/ContextModuleFactory.js
  20. +1 −1 lib/DelegatedModuleFactoryPlugin.js
  21. +7 −0 lib/Dependency.js
  22. +1 −1 lib/DllReferencePlugin.js
  23. +2 −2 lib/ErrorHelpers.js
  24. +7 −3 lib/EvalSourceMapDevToolPlugin.js
  25. +1 −1 lib/ExportsInfo.js
  26. +4 −4 lib/ExternalModuleFactoryPlugin.js
  27. +43 −14 lib/FileSystemInfo.js
  28. +1 −1 lib/LoaderOptionsPlugin.js
  29. +3 −0 lib/Module.js
  30. +3 −3 lib/ModuleFilenameHelpers.js
  31. +3 −3 lib/NodeStuffPlugin.js
  32. +13 −10 lib/NormalModule.js
  33. +2 −2 lib/NormalModuleFactory.js
  34. +25 −0 lib/RuntimePlugin.js
  35. +1 −1 lib/Template.js
  36. +22 −0 lib/WebpackOptionsApply.js
  37. +36 −9 lib/asset/AssetGenerator.js
  38. +1 −0 lib/asset/AssetParser.js
  39. +31 −6 lib/asset/AssetSourceGenerator.js
  40. +1 −0 lib/asset/AssetSourceParser.js
  41. +2 −1 lib/buildChunkGraph.js
  42. +8 −4 lib/cache/PackFileCacheStrategy.js
  43. +23 −7 lib/config/defaults.js
  44. +2 −3 lib/config/normalization.js
  45. +2 −0 lib/container/ModuleFederationPlugin.js
  46. +8 −7 lib/container/RemoteRuntimeModule.js
  47. +9 −7 lib/css/CssLoadingRuntimeModule.js
  48. +1 −1 lib/css/CssParser.js
  49. +1 −2 lib/dependencies/CommonJsExportsParserPlugin.js
  50. +342 −61 lib/dependencies/CommonJsImportsParserPlugin.js
  51. +2 −2 lib/dependencies/CommonJsRequireContextDependency.js
  52. +2 −1 lib/dependencies/CommonJsRequireDependency.js
  53. +15 −2 lib/dependencies/ContextDependency.js
  54. +20 −7 lib/dependencies/ContextDependencyHelpers.js
  55. +17 −1 lib/dependencies/ContextElementDependency.js
  56. +127 −0 lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js
  57. +127 −43 lib/dependencies/HarmonyImportDependencyParserPlugin.js
  58. +22 −8 lib/dependencies/HarmonyImportSpecifierDependency.js
  59. +10 −0 lib/dependencies/HarmonyModulesPlugin.js
  60. +1 −1 lib/dependencies/ImportMetaContextDependencyParserPlugin.js
  61. +35 −29 lib/dependencies/ImportParserPlugin.js
  62. +17 −21 lib/dependencies/JsonExportsDependency.js
  63. +13 −0 lib/dependencies/LoaderDependency.js
  64. +13 −0 lib/dependencies/LoaderImportDependency.js
  65. +11 −1 lib/dependencies/ModuleDependency.js
  66. +31 −8 lib/dependencies/ProvidedDependency.js
  67. +2 −2 lib/dependencies/RequireResolveContextDependency.js
  68. +2 −1 lib/dependencies/RequireResolveDependency.js
  69. +21 −0 lib/dependencies/URLPlugin.js
  70. +2 −0 lib/dependencies/WorkerPlugin.js
  71. +3 −1 lib/esm/ModuleChunkLoadingPlugin.js
  72. +29 −14 lib/hmr/HotModuleReplacement.runtime.js
  73. +4 −3 lib/hmr/JavascriptHotModuleReplacement.runtime.js
  74. +2 −2 lib/ids/HashedModuleIdsPlugin.js
  75. +2 −2 lib/ids/IdHelpers.js
  76. +7 −0 lib/index.js
  77. +5 −2 lib/javascript/BasicEvaluatedExpression.js
  78. +127 −65 lib/javascript/JavascriptParser.js
  79. +8 −0 lib/json/JsonData.js
  80. +4 −6 lib/json/JsonParser.js
  81. +5 −3 lib/library/UmdLibraryPlugin.js
  82. +1 −0 lib/node/NodeTargetPlugin.js
  83. +42 −18 lib/optimize/ConcatenatedModule.js
  84. +21 −2 lib/optimize/ModuleConcatenationPlugin.js
  85. +4 −1 lib/optimize/RealContentHashPlugin.js
  86. +32 −58 lib/runtime/AsyncModuleRuntimeModule.js
  87. +31 −0 lib/runtime/BaseUriRuntimeModule.js
  88. +11 −9 lib/runtime/LoadScriptRuntimeModule.js
  89. +24 −0 lib/runtime/NonceRuntimeModule.js
  90. +1 −2 lib/sharing/ProvideSharedPlugin.js
  91. +1 −1 lib/stats/DefaultStatsFactoryPlugin.js
  92. +1 −1 lib/stats/DefaultStatsPrinterPlugin.js
  93. +2 −0 lib/util/internalSerializables.js
  94. +1 −1 lib/wasm-sync/WebAssemblyParser.js
  95. +13 −10 lib/web/JsonpChunkLoadingRuntimeModule.js
  96. +10 −9 package.json
  97. +1 −1 schemas/WebpackOptions.check.js
  98. +68 −2 schemas/WebpackOptions.json
  99. +1 −1 schemas/plugins/BannerPlugin.check.js
  100. +4 −0 schemas/plugins/BannerPlugin.json
  101. +44 −4 test/BannerPlugin.test.js
  102. +1 −1 test/BuildDependencies.longtest.js
  103. +152 −0 test/Compiler-filesystem-caching.test.js
  104. +6 −1 test/ConfigTestCases.template.js
  105. +3 −2 test/ContextModuleFactory.unittest.js
  106. +282 −0 test/Defaults.unittest.js
  107. +2 −2 test/Examples.test.js
  108. +46 −0 test/FileSystemInfo.unittest.js
  109. +1 −1 test/HotTestCases.template.js
  110. +6 −6 test/JavascriptParser.unittest.js
  111. +131 −0 test/MemoryLimitTestCases.test.js
  112. +1 −1 test/TestCases.template.js
  113. +304 −0 test/__snapshots__/Cli.basictest.js.snap
  114. +183 −139 test/__snapshots__/StatsTestCases.basictest.js.snap
  115. +1 −1 test/benchmarkCases/many-chunks/b.js
  116. +1 −1 test/benchmarkCases/many-modules-source-map/b.js
  117. +1 −1 test/benchmarkCases/many-modules/b.js
  118. +1 −1 test/benchmarkCases/many-stuff-harmony/a.js
  119. +2 −0 test/cases/async-modules/runtime-performance/async.js
  120. +5 −0 test/cases/async-modules/runtime-performance/index.js
  121. +14 −0 test/cases/async-modules/runtime-performance/loader.js
  122. +1 −1 test/cases/compile/long-module-chain/module.js
  123. +1 −1 test/cases/errors/loader-error-warning/error-loader.js
  124. +1 −1 test/cases/errors/loader-error-warning/warning-loader.js
  125. +0 −3 test/cases/large/big-assets/infrastructure-log.js
  126. +1 −0 test/cases/loaders/import-module/a.json
  127. +6 −0 test/cases/loaders/import-module/index.js
  128. +25 −0 test/cases/loaders/import-module/loader.js
  129. +3 −0 test/cases/loaders/import-module/module.js
  130. +3 −0 test/cases/loaders/import-module/test.filter.js
  131. +4 −0 test/cases/parsing/es2022/counter.js
  132. +20 −0 test/cases/parsing/es2022/es2022.js
  133. +7 −0 test/cases/parsing/es2022/index.js
  134. +1 −0 test/cases/parsing/es2022/reexport.js
  135. +11 −0 test/cases/parsing/es2022/test.filter.js
  136. +1 −1 test/cases/parsing/evaluate/resourceFragment/index.js
  137. +1 −1 test/cases/parsing/evaluate/resourceQuery/index.js
  138. +2 −2 test/cases/parsing/extract-amd.nominimize/index.js
  139. +2 −2 test/cases/parsing/extract-amd/index.js
  140. +1 −0 test/cases/parsing/harmony-deep-exports/cjs2.js
  141. +3 −0 test/cases/parsing/harmony-deep-exports/cjs3.js
  142. +2 −0 test/cases/parsing/harmony-deep-exports/esm1.js
  143. +13 −0 test/cases/parsing/harmony-deep-exports/index.js
  144. +2 −0 test/cases/parsing/harmony-export-import-specifier/cjs1.js
  145. +1 −0 test/cases/parsing/harmony-export-import-specifier/cjs2.js
  146. +53 −0 test/cases/parsing/harmony-export-import-specifier/index.js
  147. +7 −0 test/cases/parsing/harmony-export-import-specifier/m.js
  148. +5 −0 test/cases/parsing/harmony-export-import-specifier/n.js
  149. +2 −0 test/cases/parsing/harmony-export-import-specifier/o.js
  150. 0 test/cases/parsing/harmony-export-import-specifier/p.js
  151. +1 −0 test/cases/parsing/harmony-export-import-specifier/q.js
  152. +1 −0 test/cases/parsing/harmony-export-import-specifier/side-effect-free/m.js
  153. +1 −0 test/cases/parsing/harmony-export-import-specifier/side-effect-free/o.js
  154. +3 −0 test/cases/parsing/harmony-export-import-specifier/side-effect-free/package.json
  155. +1 −0 test/cases/parsing/harmony-export-import-specifier/some.json
  156. +3 −0 test/cases/parsing/harmony-export-import-specifier/some1.json
  157. +7 −0 test/cases/parsing/harmony-export-import-specifier/weird-cjs.js
  158. +4 −0 test/cases/parsing/harmony-reexport/a.js
  159. +5 −2 test/cases/parsing/harmony-reexport/index.js
  160. +3 −0 test/cases/parsing/optional-chaining/b.js
  161. +2 −0 test/cases/parsing/optional-chaining/c.js
  162. +12 −0 test/cases/parsing/optional-chaining/index.js
  163. +1 −0 test/cases/runtime/issue-15518/dynamic_a/module_a1.js
  164. 0 test/cases/runtime/issue-15518/dynamic_a/module_a2.js
  165. +13 −0 test/cases/runtime/issue-15518/index.js
  166. +1 −1 test/cases/wasm/imports-complex-types/index.js
  167. BIN test/cases/wasm/imports-complex-types/other.wasm
  168. +2 −2 test/cases/wasm/imports-complex-types/test.filter.js
  169. BIN test/cases/wasm/imports-complex-types/wasm.wasm
  170. +2 −0 test/configCases/assets/delete-asset/infrastructure-log.js
  171. +1 −0 test/configCases/concatenate-modules/import-module/a.txt
  172. +7 −0 test/configCases/concatenate-modules/import-module/index.js
  173. +8 −0 test/configCases/concatenate-modules/import-module/loader.js
  174. +3 −0 test/configCases/concatenate-modules/import-module/module1.js
  175. +6 −0 test/configCases/concatenate-modules/import-module/webpack.config.js
  176. +11 −0 test/configCases/concatenate-modules/side-effects/index.js
  177. +4 −0 test/configCases/concatenate-modules/side-effects/node_modules/dep/a.js
  178. +4 −0 test/configCases/concatenate-modules/side-effects/node_modules/dep/b.js
  179. +4 −0 test/configCases/concatenate-modules/side-effects/node_modules/dep/c.js
  180. +8 −0 test/configCases/concatenate-modules/side-effects/node_modules/dep/index.js
  181. +4 −0 test/configCases/concatenate-modules/side-effects/node_modules/dep/order.js
  182. +6 −0 test/configCases/concatenate-modules/side-effects/node_modules/dep/package.json
  183. +6 −0 test/configCases/concatenate-modules/side-effects/webpack.config.js
  184. 0 test/configCases/contenthash/salt/img.jpg
  185. +5 −0 test/configCases/contenthash/salt/index.js
  186. +24 −0 test/configCases/contenthash/salt/test.config.js
  187. +48 −0 test/configCases/contenthash/salt/webpack.config.js
  188. +6 −0 test/configCases/css/external-in-node/index.js
  189. +11 −0 test/configCases/css/external-in-node/webpack.config.js
  190. +10 −0 test/configCases/devtools/eval-nosources-source-map/index.js
  191. +3 −0 test/configCases/devtools/eval-nosources-source-map/test.js
  192. +4 −0 test/configCases/devtools/eval-nosources-source-map/webpack.config.js
  193. +2 −0 test/configCases/plugins/provide-plugin/a.js
  194. +7 −0 test/configCases/plugins/provide-plugin/b.js
  195. +2 −0 test/configCases/plugins/provide-plugin/harmony2.js
  196. +5 −0 test/configCases/plugins/provide-plugin/index.js
  197. +2 −0 test/configCases/plugins/provide-plugin/webpack.config.js
  198. +2 −0 test/configCases/process-assets/html-plugin/infrastructure-log.js
  199. +1 −0 test/configCases/require/module-require/a.js
  200. +1 −0 test/configCases/require/module-require/b.js
  201. +1 −0 test/configCases/require/module-require/c.js
  202. +1 −0 test/configCases/require/module-require/foo/a.js
  203. +1 −0 test/configCases/require/module-require/foo/c.js
  204. +58 −0 test/configCases/require/module-require/index.js
  205. +4 −0 test/configCases/require/module-require/warnings.js
  206. +7 −0 test/configCases/require/module-require/webpack.config.js
  207. +1 −0 test/configCases/resolve/fallback/#/a.js
  208. +5 −0 test/configCases/resolve/fallback/index.js
  209. +3 −0 test/configCases/resolve/fallback/webpack.config.js
  210. +19 −0 test/configCases/resolve/issue-15580/index.js
  211. +1 −0 test/configCases/resolve/issue-15580/locales/en.json
  212. +1 −0 test/configCases/resolve/issue-15580/node_modules/vuetify/lib/locale/en.json
  213. +1 −0 test/configCases/resolve/issue-15580/node_modules/vuetify/lib/locale/hu.json
  214. +1 −0 test/configCases/resolve/issue-15580/node_modules/vuetify/lib/locale/ru.json
  215. +4 −0 test/configCases/resolve/issue-15580/node_modules/vuetify/package.json
  216. +8 −0 test/configCases/resolve/issue-15580/webpack.config.js
  217. +1 −0 test/configCases/source-map/context-module-source-path/foo/a.js
  218. +1 −0 test/configCases/source-map/context-module-source-path/foo/b.js
  219. +9 −0 test/configCases/source-map/context-module-source-path/index.js
  220. +7 −0 test/configCases/source-map/context-module-source-path/webpack.config.js
  221. +5 −0 test/configCases/umd/issue-15545/index.js
  222. +9 −0 test/configCases/umd/issue-15545/test.config.js
  223. +19 −0 test/configCases/umd/issue-15545/webpack.config.js
  224. +9 −0 test/configCases/wasm/bigints/index.js
  225. +5 −0 test/configCases/wasm/bigints/test.filter.js
  226. +4 −0 test/configCases/wasm/bigints/wasm.wat
  227. +16 −0 test/configCases/wasm/bigints/webpack.config.js
  228. +5 −0 test/configCases/web/nonce/index.js
  229. +1 −0 test/configCases/web/nonce/nonce.js
  230. +7 −0 test/configCases/web/nonce/webpack.config.js
  231. +1 −0 test/fixtures/empty-svg-loader.js
  232. +1 −0 test/fixtures/file.svg
  233. +1 −0 test/fixtures/uses-asset.js
  234. +2 −2 test/helpers/FakeDocument.js
  235. +8 −3 test/hotCases/runtime/import-after-download/index.js
  236. +5 −0 test/hotCases/runtime/import-after-download/unaffected-chunk.js
  237. +1 −0 test/hotCases/runtime/import-after-download/unaffected-inner.js
  238. +3 −0 test/hotCases/status/check/file.js
  239. +6 −0 test/hotCases/status/check/index.js
  240. +15 −0 test/hotCases/status/check/update.js
  241. +1 −0 test/memoryLimitCases/json/index.js
  242. +1 −0 test/memoryLimitCases/json/src/1.json
  243. +1 −0 test/memoryLimitCases/json/src/2.json
  244. +1 −0 test/memoryLimitCases/json/src/3.json
  245. +1 −0 test/memoryLimitCases/json/src/4.json
  246. +1 −0 test/memoryLimitCases/json/src/5.json
  247. +1 −0 test/memoryLimitCases/json/src/6.json
  248. +1 −0 test/memoryLimitCases/json/src/7.json
  249. +1 −0 test/statsCases/asset-concat/a.css
  250. +1 −0 test/statsCases/asset-concat/a.source.js
  251. BIN test/statsCases/asset-concat/images/file.jpg
  252. BIN test/statsCases/asset-concat/images/file.png
  253. +1 −0 test/statsCases/asset-concat/images/file.svg
  254. +9 −0 test/statsCases/asset-concat/index.js
  255. +1 −0 test/statsCases/asset-concat/static/file.html
  256. +35 −0 test/statsCases/asset-concat/webpack.config.js
  257. +1 −0 test/statsCases/asset/a.css
  258. +1 −0 test/statsCases/asset/a.source.js
  259. +5 −3 test/statsCases/asset/index.js
  260. +11 −0 test/statsCases/asset/webpack.config.js
  261. 0 test/statsCases/dynamic-chunk-name-error/dynamic.js
  262. +1 −0 test/statsCases/dynamic-chunk-name-error/entry-1.js
  263. 0 test/statsCases/dynamic-chunk-name-error/entry-2.js
  264. +1 −0 test/statsCases/dynamic-chunk-name-error/entry-3.js
  265. +9 −0 test/statsCases/dynamic-chunk-name-error/webpack.config.js
  266. +3 −0 test/statsCases/import-weak-parser-option/entry.js
  267. +2 −0 test/statsCases/import-weak-parser-option/modules/a.js
  268. +1 −0 test/statsCases/import-weak-parser-option/modules/b.js
  269. +14 −0 test/statsCases/import-weak-parser-option/webpack.config.js
  270. BIN test/watchCases/cache/asset-concat/0/images/file.jpg
  271. BIN test/watchCases/cache/asset-concat/0/images/file.png
  272. +1 −0 test/watchCases/cache/asset-concat/0/images/file.svg
  273. +9 −0 test/watchCases/cache/asset-concat/0/index.js
  274. +9 −0 test/watchCases/cache/asset-concat/1/index.js
  275. +3 −0 test/watchCases/cache/asset-concat/test.filter.js
  276. +26 −0 test/watchCases/cache/asset-concat/webpack.config.js
  277. +274 −140 types.d.ts
  278. +33 −28 yarn.lock
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = {
...["implements", "const", "memberof", "readonly", "yields"].reduce(
(acc, tag) => {
acc[tag] = {
message: `@${tag} currently not supported in Typescript`
message: `@${tag} currently not supported in TypeScript`
};
return acc;
},
Expand Down
31 changes: 17 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@ on:
- main
- dev-1

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 17.x
cache: "yarn"
- run: yarn --frozen-lockfile
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: .eslintcache
key: lint-${{ env.GITHUB_SHA }}
Expand All @@ -33,39 +36,39 @@ jobs:
basic:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 17.x
cache: "yarn"
- run: yarn --frozen-lockfile
- run: yarn link --frozen-lockfile || true
- run: yarn link webpack --frozen-lockfile
- run: yarn test:basic --ci
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
flags: basic
functionalities: gcov
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 17.x
cache: "yarn"
- run: yarn --frozen-lockfile
- run: yarn link --frozen-lockfile || true
- run: yarn link webpack --frozen-lockfile
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: .jest-cache
key: jest-unit-${{ env.GITHUB_SHA }}
restore-keys: jest-unit-
- run: yarn cover:unit --ci --cacheDirectory .jest-cache
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
flags: unit
functionalities: gcov
Expand All @@ -89,23 +92,23 @@ jobs:
part: a
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- run: yarn --frozen-lockfile
- run: yarn link --frozen-lockfile || true
- run: yarn link webpack --frozen-lockfile
- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: .jest-cache
key: jest-integration-${{ env.GITHUB_SHA }}
restore-keys: jest-integration-
- run: yarn cover:integration:${{ matrix.part }} --ci --cacheDirectory .jest-cache || yarn cover:integration:${{ matrix.part }} --ci --cacheDirectory .jest-cache -f
- run: yarn cover:merge
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
with:
flags: integration
functionalities: gcov
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
[![npm][npm]][npm-url]

[![node][node]][node-url]
[![deps][deps]][deps-url]
[![builds2][builds2]][builds2-url]
[![coverage][cover]][cover-url]
[![licenses][licenses]][licenses-url]
[![PR's welcome][prs]][prs-url]

<br>
<a href="https://dependabot.com/compatibility-score.html?dependency-name=webpack&package-manager=npm_and_yarn&new-version=latest">
<img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=webpack&package-manager=npm_and_yarn&version-scheme=semver&target-version=latest">
<a href="https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates#about-compatibility-scores">
<img src="https://api.dependabot.com/badges/compatibility_score?dependency-name=webpack&package-manager=npm_and_yarn&previous-version=5.72.1&new-version=5.73.0">
</a>
<a href="https://npmcharts.com/compare/webpack?minimal=true">
<img src="https://img.shields.io/npm/dm/webpack.svg">
Expand Down Expand Up @@ -110,6 +109,7 @@ within webpack itself use this plugin interface. This makes webpack very
| [mini-css-extract-plugin][mini-css] | ![mini-css-npm] | ![mini-css-size] | Extracts CSS into separate files. It creates a CSS file per JS file which contains CSS. |
| [compression-webpack-plugin][compression] | ![compression-npm] | ![compression-size] | Prepares compressed versions of assets to serve them with Content-Encoding |
| [html-webpack-plugin][html-plugin] | ![html-plugin-npm] | ![html-plugin-size] | Simplifies creation of HTML files (`index.html`) to serve your bundles |
| [pug-plugin][pug-plugin] | ![pug-plugin-npm] | ![pug-plugin-size] | Renders Pug files to HTML, extracts JS and CSS from sources specified directly in Pug. |

[common-npm]: https://img.shields.io/npm/v/webpack.svg
[mini-css]: https://github.com/webpack-contrib/mini-css-extract-plugin
Expand All @@ -124,6 +124,9 @@ within webpack itself use this plugin interface. This makes webpack very
[html-plugin]: https://github.com/jantimon/html-webpack-plugin
[html-plugin-npm]: https://img.shields.io/npm/v/html-webpack-plugin.svg
[html-plugin-size]: https://packagephobia.com/badge?p=html-webpack-plugin
[pug-plugin]: https://github.com/webdiscus/pug-plugin
[pug-plugin-npm]: https://img.shields.io/npm/v/pug-plugin.svg
[pug-plugin-size]: https://packagephobia.com/badge?p=pug-plugin

### [Loaders](https://webpack.js.org/loaders/)

Expand Down Expand Up @@ -155,11 +158,11 @@ or are automatically applied via regex from your webpack configuration.

#### Transpiling

| Name | Status | Install Size | Description |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
| <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
| <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
| <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
| Name | Status | Install Size | Description |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
| <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
| <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://raw.githubusercontent.com/microsoft/TypeScript-Website/f407e1ae19e5e990d9901ac8064a32a8cc60edf0/packages/typescriptlang-org/static/branding/ts-logo-128.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
| <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |

[babel-npm]: https://img.shields.io/npm/v/babel-loader.svg
[babel-size]: https://packagephobia.com/badge?p=babel-loader
Expand All @@ -170,18 +173,21 @@ or are automatically applied via regex from your webpack configuration.

#### Templating

| Name | Status | Install Size | Description |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- |
| <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
| <a href="https://github.com/pugjs/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function |
| <a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a> | ![md-npm] | ![md-size] | Compiles Markdown to HTML |
| <a href="https://github.com/posthtml/posthtml-loader"><img width="48" height="48" src="https://posthtml.github.io/posthtml/logo.svg"></a> | ![posthtml-npm] | ![posthtml-size] | Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml) |
| <a href="https://github.com/pcardune/handlebars-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/handlebars-1.svg"></a> | ![hbs-npm] | ![hbs-size] | Compiles Handlebars to HTML |
| Name | Status | Install Size | Description |
| :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- |
| <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5-2.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
| <a href="https://github.com/pugjs/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function |
| <a href="https://github.com/webdiscus/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular |
| <a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a> | ![md-npm] | ![md-size] | Compiles Markdown to HTML |
| <a href="https://github.com/posthtml/posthtml-loader"><img width="48" height="48" src="https://posthtml.github.io/posthtml/logo.svg"></a> | ![posthtml-npm] | ![posthtml-size] | Loads and transforms a HTML file using [PostHTML](https://github.com/posthtml/posthtml) |
| <a href="https://github.com/pcardune/handlebars-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/handlebars-1.svg"></a> | ![hbs-npm] | ![hbs-size] | Compiles Handlebars to HTML |

[html-npm]: https://img.shields.io/npm/v/html-loader.svg
[html-size]: https://packagephobia.com/badge?p=html-loader
[pug-npm]: https://img.shields.io/npm/v/pug-loader.svg
[pug-size]: https://packagephobia.com/badge?p=pug-loader
[pug3-npm]: https://img.shields.io/npm/v/@webdiscus/pug-loader.svg
[pug3-size]: https://packagephobia.com/badge?p=@webdiscus/pug-loader
[jade-npm]: https://img.shields.io/npm/v/jade-loader.svg
[jade-size]: https://packagephobia.com/badge?p=jade-loader
[md-npm]: https://img.shields.io/npm/v/markdown-loader.svg
Expand Down Expand Up @@ -699,8 +705,6 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
[npm-url]: https://npmjs.com/package/webpack
[node]: https://img.shields.io/node/v/webpack.svg
[node-url]: https://nodejs.org
[deps]: https://img.shields.io/david/webpack/webpack.svg
[deps-url]: https://david-dm.org/webpack/webpack
[prs]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
[prs-url]: https://webpack.js.org/contribute/
[builds2]: https://dev.azure.com/webpack/webpack/_apis/build/status/webpack.webpack
Expand Down
6 changes: 6 additions & 0 deletions declarations/LoaderContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ export interface LoaderRunnerLoaderContext<OptionsType> {
* Example: "/abc/resource.js?query#frag"
*/
resource: string;

/**
* Target of compilation.
* Example: "web"
*/
target: string;
}

type AdditionalData = {
Expand Down
29 changes: 27 additions & 2 deletions declarations/WebpackOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,15 @@ export interface ResolveOptions {
* Field names from the description file (usually package.json) which are used to provide entry points of a package.
*/
exportsFields?: string[];
/**
* An object which maps extension to extension aliases.
*/
extensionAlias?: {
/**
* Extension alias.
*/
[k: string]: string[] | string;
};
/**
* Extensions added to the request when trying to find the file.
*/
Expand Down Expand Up @@ -2929,6 +2938,22 @@ export interface JavascriptParserOptions {
* Enable/disable parsing of magic comments in CommonJs syntax.
*/
commonjsMagicComments?: boolean;
/**
* Enable/disable parsing "import { createRequire } from "module"" and evaluating createRequire().
*/
createRequire?: boolean | string;
/**
* Specifies global mode for dynamic import.
*/
dynamicImportMode?: "eager" | "weak" | "lazy" | "lazy-once";
/**
* Specifies global prefetch for dynamic import.
*/
dynamicImportPrefetch?: number | boolean;
/**
* Specifies global preload for dynamic import.
*/
dynamicImportPreload?: number | boolean;
/**
* Specifies the behavior of invalid export names in "import ... from ..." and "export ... from ...".
*/
Expand Down Expand Up @@ -3498,11 +3523,11 @@ export interface ExperimentsNormalizedExtra {
/**
* Enable css support.
*/
css?: CssExperimentOptions;
css?: false | CssExperimentOptions;
/**
* Compile entrypoints and import()s only when they are accessed.
*/
lazyCompilation?: LazyCompilationOptions;
lazyCompilation?: false | LazyCompilationOptions;
}
/**
* If an dependency matches exactly a property of the object, the property value is used as dependency.
Expand Down
4 changes: 4 additions & 0 deletions declarations/plugins/BannerPlugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export interface BannerPluginOptions {
* Exclude all modules matching any of these conditions.
*/
exclude?: Rules;
/**
* If true, banner will be placed at the end of the output.
*/
footer?: boolean;
/**
* Include all modules matching any of these conditions.
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/template-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ exports.replaceResults = (template, baseDir, stdout, prefix) => {
const regexp = new RegExp("_\\{\\{" + (prefix ? prefix + ":" : "") + "([^:\\}]+)\\}\\}_", "g");

return template.replace(regexp, function(match) {
match = match.substr(3 + (prefix ? prefix.length + 1 : 0), match.length - 6 - (prefix ? prefix.length + 1 : 0));
match = match.slice(3 + (prefix ? prefix.length + 1 : 0), -3);
if(match === "stdout")
return stdout;
try {
Expand Down
21 changes: 17 additions & 4 deletions hot/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ if (module.hot) {
.check(true)
.then(function (updatedModules) {
if (!updatedModules) {
log("warning", "[HMR] Cannot find update. Need to do a full reload!");
log(
"warning",
"[HMR] Cannot find update. " +
(typeof window !== "undefined"
? "Need to do a full reload!"
: "Please reload manually!")
);
log(
"warning",
"[HMR] (Probably because of restarting the webpack-dev-server)"
);
window.location.reload();
if (typeof window !== "undefined") {
window.location.reload();
}
return;
}

Expand All @@ -38,10 +46,15 @@ if (module.hot) {
if (["abort", "fail"].indexOf(status) >= 0) {
log(
"warning",
"[HMR] Cannot apply update. Need to do a full reload!"
"[HMR] Cannot apply update. " +
(typeof window !== "undefined"
? "Need to do a full reload!"
: "Please reload manually!")
);
log("warning", "[HMR] " + log.formatError(err));
window.location.reload();
if (typeof window !== "undefined") {
window.location.reload();
}
} else {
log("warning", "[HMR] Update failed: " + log.formatError(err));
}
Expand Down
2 changes: 1 addition & 1 deletion hot/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
/*globals __resourceQuery */
if (module.hot) {
var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000;
var hotPollInterval = +__resourceQuery.slice(1) || 10 * 60 * 1000;
var log = require("./log");

var checkForUpdate = function checkForUpdate(fromUpdate) {
Expand Down
2 changes: 1 addition & 1 deletion hot/signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (module.hot) {
});
};

process.on(__resourceQuery.substr(1) || "SIGUSR2", function () {
process.on(__resourceQuery.slice(1) || "SIGUSR2", function () {
if (module.hot.status() !== "idle") {
log(
"warning",
Expand Down
6 changes: 4 additions & 2 deletions lib/BannerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const wrapComment = str => {
.split("\n")
.join("\n * ")
.replace(/\s+\n/g, "\n")
.trimRight()}\n */`;
.trimEnd()}\n */`;
};

class BannerPlugin {
Expand Down Expand Up @@ -106,7 +106,9 @@ class BannerPlugin {
compilation.updateAsset(file, old => {
let cached = cache.get(old);
if (!cached || cached.comment !== comment) {
const source = new ConcatSource(comment, "\n", old);
const source = options.footer
? new ConcatSource(old, "\n", comment)
: new ConcatSource(comment, "\n", old);
cache.set(old, { source, comment });
return source;
}
Expand Down
Loading