@nuxt/webpack-builder 3.21.1 → 3.21.2

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 (32) hide show
  1. package/README.md +4 -4
  2. package/dist/THIRD-PARTY-LICENSES.md +2 -3816
  3. package/dist/index.d.mts +1 -3146
  4. package/dist/index.mjs +84 -18
  5. package/dist/loaders/vue-module-identifier.mjs +2 -0
  6. package/package.json +23 -23
  7. package/dist/_chunks/libs/@babel/parser.d.mts +0 -1536
  8. package/dist/_chunks/libs/@jridgewell/trace-mapping.d.mts +0 -82
  9. package/dist/_chunks/libs/@types/estree.d.mts +0 -525
  10. package/dist/_chunks/libs/@types/pug.d.mts +0 -123
  11. package/dist/_chunks/libs/@unhead/vue.d.mts +0 -1096
  12. package/dist/_chunks/libs/@vitejs/plugin-vue-jsx.d.mts +0 -5297
  13. package/dist/_chunks/libs/@vitejs/plugin-vue.d.mts +0 -83
  14. package/dist/_chunks/libs/@volar/language-core.d.mts +0 -56
  15. package/dist/_chunks/libs/@volar/source-map.d.mts +0 -10
  16. package/dist/_chunks/libs/@vue/compiler-core.d.mts +0 -1213
  17. package/dist/_chunks/libs/@vue/compiler-dom.d.mts +0 -45
  18. package/dist/_chunks/libs/@vue/language-core.d.mts +0 -11387
  19. package/dist/_chunks/libs/c12.d.mts +0 -147
  20. package/dist/_chunks/libs/compatx.d.mts +0 -47
  21. package/dist/_chunks/libs/h3.d.mts +0 -45
  22. package/dist/_chunks/libs/ofetch.d.mts +0 -870
  23. package/dist/_chunks/libs/open.d.mts +0 -1
  24. package/dist/_chunks/libs/oxc-transform.d.mts +0 -422
  25. package/dist/_chunks/libs/pkg-types.d.mts +0 -23
  26. package/dist/_chunks/libs/rollup-plugin-visualizer.d.mts +0 -90
  27. package/dist/_chunks/libs/scule.d.mts +0 -15
  28. package/dist/_chunks/libs/unctx.d.mts +0 -28
  29. package/dist/_chunks/libs/unimport.d.mts +0 -386
  30. package/dist/_chunks/libs/untyped.d.mts +0 -44
  31. package/dist/_chunks/libs/vue-router.d.mts +0 -1413
  32. package/dist/_chunks/rolldown-runtime.mjs +0 -12
package/dist/index.mjs CHANGED
@@ -3,16 +3,12 @@ import pify from "pify";
3
3
  import webpackDevMiddleware from "webpack-dev-middleware";
4
4
  import webpackHotMiddleware from "webpack-hot-middleware";
5
5
  import { defu } from "defu";
6
- import { joinURL, parseURL, withTrailingSlash } from "ufo";
6
+ import { joinURL, withTrailingSlash } from "ufo";
7
7
  import { directoryToURL, logger, resolveAlias, useNitro, useNuxt } from "@nuxt/kit";
8
8
  import { createUnplugin } from "unplugin";
9
9
  import MagicString from "magic-string";
10
- import webpack from "webpack";
11
- import MiniCssExtractPlugin from "mini-css-extract-plugin";
12
- import WebpackBarPlugin from "webpackbar";
13
- import TsCheckerPlugin from "fork-ts-checker-webpack-plugin";
10
+ import { MiniCssExtractPlugin, TsCheckerPlugin, WebpackBarPlugin, builder, webpack } from "#builder";
14
11
  import { existsSync, readFileSync } from "node:fs";
15
- import { pathToFileURL } from "node:url";
16
12
  import { isAbsolute, join, normalize, relative, resolve } from "pathe";
17
13
  import { genArrayFromRaw, genObjectFromRawEntries, genString } from "knitwork";
18
14
  import { compileStyle, parse } from "@vue/compiler-sfc";
@@ -36,6 +32,7 @@ import { normalizeWebpackManifest, precomputeDependencies } from "vue-bundle-ren
36
32
  import { hash } from "ohash";
37
33
  import { serialize } from "seroval";
38
34
  import { parseNodeModulePath } from "mlly";
35
+ //#region src/plugins/dynamic-base.ts
39
36
  const defaults = {
40
37
  globalPublicPath: "__webpack_public_path__",
41
38
  sourcemap: true
@@ -65,7 +62,8 @@ const DynamicBasePlugin = createUnplugin((options = {}) => {
65
62
  }
66
63
  };
67
64
  });
68
- const builder = "webpack";
65
+ //#endregion
66
+ //#region src/plugins/chunk.ts
69
67
  const pluginName = "ChunkErrorPlugin";
70
68
  var ChunkErrorPlugin = class {
71
69
  apply(compiler) {
@@ -97,19 +95,40 @@ if (typeof ${ensureChunk} !== "undefined") {
97
95
  `;
98
96
  }
99
97
  };
98
+ //#endregion
99
+ //#region ../nuxt/src/core/utils/plugins.ts
100
+ /**
101
+ * Split a bundler module ID into its pathname and search (query) parts.
102
+ *
103
+ * Module IDs from Vite/webpack are already-normalized filesystem paths
104
+ * that may carry query strings (e.g. `?vue&type=style&lang=css`).
105
+ */
106
+ function parseModuleId(id) {
107
+ const qIndex = id.indexOf("?");
108
+ if (qIndex === -1) return {
109
+ pathname: id,
110
+ search: ""
111
+ };
112
+ return {
113
+ pathname: id.slice(0, qIndex),
114
+ search: id.slice(qIndex)
115
+ };
116
+ }
117
+ //#endregion
118
+ //#region src/plugins/ssr-styles.ts
100
119
  const CSS_URL_RE = /url\((['"]?)(\/[^)]+?)\1\)/g;
101
120
  const isVueFile = (id) => /\.vue(?:\?|$)/.test(id);
102
121
  const isCSSLike = (name) => /\.(?:css|scss|sass|less|styl(?:us)?|postcss|pcss)(?:\?|$)/.test(name);
103
122
  function normalizePath(nuxt, id) {
104
123
  if (!id) return null;
105
- const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
124
+ const { pathname } = parseModuleId(id);
106
125
  const rel = relative(nuxt.options.srcDir, pathname);
107
126
  if (rel.startsWith("..")) return null;
108
127
  return rel;
109
128
  }
110
129
  function resolveFilePath(id) {
111
130
  if (!id) return null;
112
- return parseURL(decodeURIComponent(pathToFileURL(id).href)).pathname || null;
131
+ return parseModuleId(normalize(id)).pathname || null;
113
132
  }
114
133
  function sanitizeStyleAssetName(rel) {
115
134
  return rel.replace(/[\\/]/g, "_").replace(/\.{2,}/g, "_");
@@ -236,11 +255,6 @@ var SSRStylesPlugin = class {
236
255
  }
237
256
  return null;
238
257
  }
239
- normalizeResourcePath(resource) {
240
- if (!resource) return null;
241
- const withoutQuery = resource.split("?")[0];
242
- return resolveFilePath(withoutQuery);
243
- }
244
258
  apply(compiler) {
245
259
  if (this.nuxt.options.dev) return;
246
260
  const isClient = compiler.options.name === "client";
@@ -414,6 +428,8 @@ var SSRStylesPlugin = class {
414
428
  return cssChunks;
415
429
  }
416
430
  };
431
+ //#endregion
432
+ //#region src/utils/mfs.ts
417
433
  function createMFS() {
418
434
  const _fs = { ...createFsFromVolume(new Volume()) };
419
435
  _fs.join = join;
@@ -421,9 +437,14 @@ function createMFS() {
421
437
  _fs.readFile = pify(_fs.readFile);
422
438
  return _fs;
423
439
  }
440
+ //#endregion
441
+ //#region src/utils/index.ts
442
+ /** @since 3.9.0 */
424
443
  function toArray(value) {
425
444
  return Array.isArray(value) ? value : [value];
426
445
  }
446
+ //#endregion
447
+ //#region src/utils/config.ts
427
448
  function createWebpackConfigContext(nuxt) {
428
449
  return {
429
450
  nuxt,
@@ -451,6 +472,8 @@ function fileName(ctx, key) {
451
472
  }
452
473
  return fileName;
453
474
  }
475
+ //#endregion
476
+ //#region src/presets/assets.ts
454
477
  function assets(ctx) {
455
478
  ctx.config.module.rules.push({
456
479
  test: /\.(png|jpe?g|gif|svg|webp)$/i,
@@ -481,6 +504,8 @@ function assets(ctx) {
481
504
  }]
482
505
  });
483
506
  }
507
+ //#endregion
508
+ //#region src/plugins/warning-ignore.ts
484
509
  var WarningIgnorePlugin = class {
485
510
  filter;
486
511
  constructor(filter) {
@@ -492,6 +517,12 @@ var WarningIgnorePlugin = class {
492
517
  });
493
518
  }
494
519
  };
520
+ //#endregion
521
+ //#region src/plugins/vue/util.ts
522
+ /**
523
+ * This file is based on Vue.js (MIT) webpack plugins
524
+ * https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/util.js
525
+ */
495
526
  const validate = (compiler) => {
496
527
  if (compiler.options.target !== "node") logger.warn("webpack config `target` should be \"node\".");
497
528
  if (!compiler.options.externals) logger.info("It is recommended to externalize dependencies in the server build for better build performance.");
@@ -502,10 +533,17 @@ const extractQueryPartJS = (file) => isJSRegExp.exec(file)?.[1];
502
533
  const isCSSRegExp = /\.css(?:\?[^.]+)?$/;
503
534
  const isCSS = (file) => isCSSRegExp.test(file);
504
535
  const isHotUpdate = (file) => file.includes("hot-update");
536
+ //#endregion
537
+ //#region src/plugins/rollup-compat-dynamic-import.ts
505
538
  const DYNAMIC_IMPORT_RE = /import\([^)]*\+\s*__webpack_require__[^+]*\)\.then/;
506
539
  const DYNAMIC_IMPORT_REPLACE_RE = /import\([^)]*\+\s*(__webpack_require__[^+]*)\)\.then/g;
507
540
  const HELPER_FILENAME = "_dynamic-import-helper.mjs";
508
541
  const HELPER_IMPORT = `import { _rollupDynamicImport } from "./${HELPER_FILENAME}";\n`;
542
+ /**
543
+ * Webpack plugin that generates rollup-compatible dynamic imports.
544
+ * This plugin uses webpack's native compilation hooks to override dynamic import generation
545
+ * and create rollup-compatible code directly during webpack's compilation process.
546
+ */
509
547
  var RollupCompatDynamicImportPlugin = class {
510
548
  apply(compiler) {
511
549
  compiler.hooks.compilation.tap("RollupCompatDynamicImportPlugin", (compilation) => {
@@ -573,6 +611,8 @@ export function _rollupDynamicImport(chunkId) {
573
611
  `;
574
612
  }
575
613
  };
614
+ //#endregion
615
+ //#region src/presets/base.ts
576
616
  async function base(ctx) {
577
617
  await applyPresets(ctx, [
578
618
  baseAlias,
@@ -743,6 +783,8 @@ const statsMap = {
743
783
  info: "normal",
744
784
  verbose: "verbose"
745
785
  };
786
+ //#endregion
787
+ //#region src/presets/esbuild.ts
746
788
  function esbuild(ctx) {
747
789
  const target = ctx.isServer ? "es2020" : "chrome85";
748
790
  ctx.config.optimization.minimizer.push(new EsbuildPlugin());
@@ -770,6 +812,8 @@ function esbuild(ctx) {
770
812
  }
771
813
  });
772
814
  }
815
+ //#endregion
816
+ //#region src/presets/pug.ts
773
817
  function pug(ctx) {
774
818
  ctx.config.module.rules.push({
775
819
  test: /\.pug$/i,
@@ -785,6 +829,8 @@ function pug(ctx) {
785
829
  }] }]
786
830
  });
787
831
  }
832
+ //#endregion
833
+ //#region src/utils/postcss.ts
788
834
  const isPureObject = (obj) => obj !== null && !Array.isArray(obj) && typeof obj === "object";
789
835
  function sortPlugins({ plugins, order }) {
790
836
  const names = Object.keys(plugins);
@@ -830,6 +876,8 @@ async function getPostcssConfig(nuxt) {
830
876
  postcssOptions
831
877
  };
832
878
  }
879
+ //#endregion
880
+ //#region src/presets/style.ts
833
881
  async function style(ctx) {
834
882
  await applyPresets(ctx, [
835
883
  loaders,
@@ -909,6 +957,12 @@ async function createPostcssLoadersRule(ctx) {
909
957
  options: config
910
958
  };
911
959
  }
960
+ //#endregion
961
+ //#region src/plugins/vue/client.ts
962
+ /**
963
+ * This file is based on Vue.js (MIT) webpack plugins
964
+ * https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/client.js
965
+ */
912
966
  var VueSSRClientPlugin = class {
913
967
  serverDist;
914
968
  nuxt;
@@ -991,6 +1045,8 @@ var VueSSRClientPlugin = class {
991
1045
  });
992
1046
  }
993
1047
  };
1048
+ //#endregion
1049
+ //#region src/plugins/vue/server.ts
994
1050
  const JS_MAP_RE = /\.js\.map$/;
995
1051
  var VueSSRServerPlugin = class {
996
1052
  options;
@@ -1039,6 +1095,8 @@ var VueSSRServerPlugin = class {
1039
1095
  });
1040
1096
  }
1041
1097
  };
1098
+ //#endregion
1099
+ //#region src/presets/vue.ts
1042
1100
  function vue(ctx) {
1043
1101
  ctx.config.plugins.push(new (VueLoaderPlugin.default || VueLoaderPlugin)());
1044
1102
  ctx.config.module.rules.push({
@@ -1068,6 +1126,8 @@ function vue(ctx) {
1068
1126
  "__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": ctx.nuxt.options.debug && ctx.nuxt.options.debug.hydration
1069
1127
  }));
1070
1128
  }
1129
+ //#endregion
1130
+ //#region src/presets/nuxt.ts
1071
1131
  async function nuxt(ctx) {
1072
1132
  await applyPresets(ctx, [
1073
1133
  base,
@@ -1078,6 +1138,8 @@ async function nuxt(ctx) {
1078
1138
  vue
1079
1139
  ]);
1080
1140
  }
1141
+ //#endregion
1142
+ //#region src/configs/client.ts
1081
1143
  async function client(ctx) {
1082
1144
  ctx.name = "client";
1083
1145
  ctx.isClient = true;
@@ -1183,6 +1245,8 @@ function clientPlugins(ctx) {
1183
1245
  if (!ctx.nuxt.options.test && (ctx.nuxt.options.typescript.typeCheck === true || ctx.nuxt.options.typescript.typeCheck === "build" && !ctx.nuxt.options.dev)) ctx.config.plugins.push(new TsCheckerPlugin({ logger }));
1184
1246
  }
1185
1247
  }
1248
+ //#endregion
1249
+ //#region src/presets/node.ts
1186
1250
  function node(ctx) {
1187
1251
  ctx.config.target = "node";
1188
1252
  ctx.config.node = false;
@@ -1211,6 +1275,8 @@ function node(ctx) {
1211
1275
  maxAssetSize: Number.POSITIVE_INFINITY
1212
1276
  };
1213
1277
  }
1278
+ //#endregion
1279
+ //#region src/configs/server.ts
1214
1280
  const assetPattern = /\.(?:css|s[ca]ss|png|jpe?g|gif|svg|woff2?|eot|ttf|otf|webp|webm|mp4|ogv)(?:\?.*)?$/i;
1215
1281
  const VIRTUAL_RE = /^\0?virtual:(?:nuxt:)?/;
1216
1282
  async function server(ctx) {
@@ -1300,6 +1366,8 @@ function serverPlugins(ctx) {
1300
1366
  }));
1301
1367
  if (!ctx.nuxt.options.test && (ctx.nuxt.options.typescript.typeCheck === true || ctx.nuxt.options.typescript.typeCheck === "build" && !ctx.nuxt.options.dev)) ctx.config.plugins.push(new TsCheckerPlugin({ logger }));
1302
1368
  }
1369
+ //#endregion
1370
+ //#region src/webpack.ts
1303
1371
  const bundle = async (nuxt) => {
1304
1372
  const webpackConfigs = await Promise.all([client, ...nuxt.options.ssr ? [server] : []].map(async (preset) => {
1305
1373
  const ctx = createWebpackConfigContext(nuxt);
@@ -1307,6 +1375,7 @@ const bundle = async (nuxt) => {
1307
1375
  await applyPresets(ctx, preset);
1308
1376
  return ctx.config;
1309
1377
  }));
1378
+ /** Remove Nitro rollup plugin for handling dynamic imports from webpack chunks */
1310
1379
  if (!nuxt.options.dev) useNitro().hooks.hook("rollup:before", (_nitro, config) => {
1311
1380
  const plugins = config.plugins;
1312
1381
  const existingPlugin = plugins.findIndex((i) => i && "name" in i && i.name === "dynamic-require");
@@ -1369,10 +1438,6 @@ function wdmToH3Handler(devMiddleware) {
1369
1438
  res.end("Forbidden");
1370
1439
  return;
1371
1440
  }
1372
- event.context.webpack = {
1373
- ...event.context.webpack,
1374
- devMiddleware: devMiddleware.context
1375
- };
1376
1441
  return await new Promise((resolve, reject) => {
1377
1442
  res.stream = (stream) => {
1378
1443
  resolve(stream);
@@ -1437,4 +1502,5 @@ async function compile(compiler) {
1437
1502
  function defineEventHandler(handler) {
1438
1503
  return Object.assign(handler, { __is_handler__: true });
1439
1504
  }
1505
+ //#endregion
1440
1506
  export { bundle };
@@ -1,4 +1,5 @@
1
1
  import { normalize, relative } from "pathe";
2
+ //#region src/loaders/vue-module-identifier.ts
2
3
  const vueModuleIdentifierLoader = function(source) {
3
4
  this.cacheable?.();
4
5
  const { srcDir } = this.getOptions() || {};
@@ -8,4 +9,5 @@ const vueModuleIdentifierLoader = function(source) {
8
9
  const moduleId = normalize(context ? relative(context, resourcePath) : resourcePath).replace(/^\.\//, "").replace(/\\/g, "/");
9
10
  return source + `\n;__exports__.__moduleIdentifier = ${JSON.stringify(moduleId)};`;
10
11
  };
12
+ //#endregion
11
13
  export { vueModuleIdentifierLoader as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder",
3
- "version": "3.21.1",
3
+ "version": "3.21.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
28
- "@vue/compiler-sfc": "3.5.27",
29
- "autoprefixer": "^10.4.24",
30
- "css-loader": "^7.1.3",
31
- "css-minimizer-webpack-plugin": "^7.0.4",
32
- "cssnano": "^7.1.2",
28
+ "@vue/compiler-sfc": "3.5.30",
29
+ "autoprefixer": "^10.4.27",
30
+ "css-loader": "^7.1.4",
31
+ "css-minimizer-webpack-plugin": "^8.0.0",
32
+ "cssnano": "^7.1.3",
33
33
  "defu": "^6.1.4",
34
34
  "esbuild-loader": "^4.4.2",
35
35
  "escape-string-regexp": "^5.0.0",
@@ -39,20 +39,20 @@
39
39
  "jiti": "^2.6.1",
40
40
  "knitwork": "^1.3.0",
41
41
  "magic-string": "^0.30.21",
42
- "memfs": "^4.56.10",
43
- "mini-css-extract-plugin": "^2.10.0",
44
- "mlly": "^1.8.0",
42
+ "memfs": "^4.56.11",
43
+ "mini-css-extract-plugin": "^2.10.1",
44
+ "mlly": "^1.8.1",
45
45
  "ohash": "^2.0.11",
46
46
  "pathe": "^2.0.3",
47
47
  "pify": "^6.1.0",
48
- "postcss": "^8.5.6",
48
+ "postcss": "^8.5.8",
49
49
  "postcss-import": "^16.1.1",
50
50
  "postcss-import-resolver": "^2.0.0",
51
- "postcss-loader": "^8.2.0",
51
+ "postcss-loader": "^8.2.1",
52
52
  "postcss-url": "^10.1.3",
53
53
  "pug-plain-loader": "^1.1.0",
54
- "seroval": "^1.5.0",
55
- "std-env": "^3.10.0",
54
+ "seroval": "^1.5.1",
55
+ "std-env": "^4.0.0",
56
56
  "time-fix-plugin": "^2.0.7",
57
57
  "ufo": "^1.6.3",
58
58
  "unenv": "^2.0.0-rc.24",
@@ -60,28 +60,28 @@
60
60
  "url-loader": "^4.1.1",
61
61
  "vue-bundle-renderer": "^2.2.0",
62
62
  "vue-loader": "^17.4.2",
63
- "webpack": "^5.104.1",
63
+ "webpack": "^5.105.4",
64
64
  "webpack-bundle-analyzer": "^5.2.0",
65
65
  "webpack-dev-middleware": "^7.4.5",
66
66
  "webpack-hot-middleware": "^2.26.1",
67
67
  "webpackbar": "^7.0.0",
68
- "@nuxt/kit": "3.21.1"
68
+ "@nuxt/kit": "3.21.2"
69
69
  },
70
70
  "devDependencies": {
71
- "@rspack/core": "1.7.5",
71
+ "@rspack/core": "1.7.8",
72
72
  "@types/pify": "6.1.0",
73
73
  "@types/webpack-bundle-analyzer": "4.7.0",
74
74
  "@types/webpack-hot-middleware": "2.25.12",
75
- "h3": "1.15.5",
76
- "h3-next": "npm:h3@2.0.1-rc.14",
77
- "obuild": "0.4.27",
78
- "rollup": "4.57.1",
79
- "vue": "3.5.27",
80
- "@nuxt/schema": "3.21.1"
75
+ "h3": "1.15.6",
76
+ "h3-next": "npm:h3@2.0.1-rc.16",
77
+ "obuild": "0.4.32",
78
+ "rollup": "4.59.0",
79
+ "vue": "3.5.30",
80
+ "@nuxt/schema": "3.21.2"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "vue": "^3.3.4",
84
- "nuxt": "3.21.1"
84
+ "nuxt": "3.21.2"
85
85
  },
86
86
  "engines": {
87
87
  "node": "^20.19.0 || >=22.12.0"