@nuxt/rspack-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 (33) hide show
  1. package/README.md +4 -4
  2. package/dist/THIRD-PARTY-LICENSES.md +4 -3796
  3. package/dist/index.d.mts +1 -3145
  4. package/dist/index.mjs +83 -13
  5. package/dist/loaders/vue-module-identifier.mjs +2 -0
  6. package/package.json +22 -22
  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/mini-css-extract-plugin.d.mts +0 -7
  23. package/dist/_chunks/libs/ofetch.d.mts +0 -870
  24. package/dist/_chunks/libs/open.d.mts +0 -1
  25. package/dist/_chunks/libs/oxc-transform.d.mts +0 -422
  26. package/dist/_chunks/libs/pkg-types.d.mts +0 -23
  27. package/dist/_chunks/libs/rollup-plugin-visualizer.d.mts +0 -90
  28. package/dist/_chunks/libs/scule.d.mts +0 -15
  29. package/dist/_chunks/libs/unctx.d.mts +0 -28
  30. package/dist/_chunks/libs/unimport.d.mts +0 -386
  31. package/dist/_chunks/libs/untyped.d.mts +0 -44
  32. package/dist/_chunks/libs/vue-router.d.mts +0 -1413
  33. package/dist/_chunks/rolldown-runtime.mjs +0 -12
package/dist/index.mjs CHANGED
@@ -3,13 +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
10
  import { MiniCssExtractPlugin, TsCheckerPlugin, WebpackBarPlugin, builder, webpack } from "#builder";
11
11
  import { existsSync, readFileSync } from "node:fs";
12
- import { pathToFileURL } from "node:url";
13
12
  import { isAbsolute, join, normalize, relative, resolve } from "pathe";
14
13
  import { genArrayFromRaw, genObjectFromRawEntries, genString } from "knitwork";
15
14
  import { compileStyle, parse } from "@vue/compiler-sfc";
@@ -33,6 +32,7 @@ import { normalizeWebpackManifest, precomputeDependencies } from "vue-bundle-ren
33
32
  import { hash } from "ohash";
34
33
  import { serialize } from "seroval";
35
34
  import { parseNodeModulePath } from "mlly";
35
+ //#region ../webpack/src/plugins/dynamic-base.ts
36
36
  const defaults = {
37
37
  globalPublicPath: "__webpack_public_path__",
38
38
  sourcemap: true
@@ -62,6 +62,8 @@ const DynamicBasePlugin = createUnplugin((options = {}) => {
62
62
  }
63
63
  };
64
64
  });
65
+ //#endregion
66
+ //#region ../webpack/src/plugins/chunk.ts
65
67
  const pluginName = "ChunkErrorPlugin";
66
68
  var ChunkErrorPlugin = class {
67
69
  apply(compiler) {
@@ -93,19 +95,40 @@ if (typeof ${ensureChunk} !== "undefined") {
93
95
  `;
94
96
  }
95
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 ../webpack/src/plugins/ssr-styles.ts
96
119
  const CSS_URL_RE = /url\((['"]?)(\/[^)]+?)\1\)/g;
97
120
  const isVueFile = (id) => /\.vue(?:\?|$)/.test(id);
98
121
  const isCSSLike = (name) => /\.(?:css|scss|sass|less|styl(?:us)?|postcss|pcss)(?:\?|$)/.test(name);
99
122
  function normalizePath(nuxt, id) {
100
123
  if (!id) return null;
101
- const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
124
+ const { pathname } = parseModuleId(id);
102
125
  const rel = relative(nuxt.options.srcDir, pathname);
103
126
  if (rel.startsWith("..")) return null;
104
127
  return rel;
105
128
  }
106
129
  function resolveFilePath(id) {
107
130
  if (!id) return null;
108
- return parseURL(decodeURIComponent(pathToFileURL(id).href)).pathname || null;
131
+ return parseModuleId(normalize(id)).pathname || null;
109
132
  }
110
133
  function sanitizeStyleAssetName(rel) {
111
134
  return rel.replace(/[\\/]/g, "_").replace(/\.{2,}/g, "_");
@@ -232,11 +255,6 @@ var SSRStylesPlugin = class {
232
255
  }
233
256
  return null;
234
257
  }
235
- normalizeResourcePath(resource) {
236
- if (!resource) return null;
237
- const withoutQuery = resource.split("?")[0];
238
- return resolveFilePath(withoutQuery);
239
- }
240
258
  apply(compiler) {
241
259
  if (this.nuxt.options.dev) return;
242
260
  const isClient = compiler.options.name === "client";
@@ -410,6 +428,8 @@ var SSRStylesPlugin = class {
410
428
  return cssChunks;
411
429
  }
412
430
  };
431
+ //#endregion
432
+ //#region ../webpack/src/utils/mfs.ts
413
433
  function createMFS() {
414
434
  const _fs = { ...createFsFromVolume(new Volume()) };
415
435
  _fs.join = join;
@@ -417,9 +437,14 @@ function createMFS() {
417
437
  _fs.readFile = pify(_fs.readFile);
418
438
  return _fs;
419
439
  }
440
+ //#endregion
441
+ //#region ../webpack/src/utils/index.ts
442
+ /** @since 3.9.0 */
420
443
  function toArray(value) {
421
444
  return Array.isArray(value) ? value : [value];
422
445
  }
446
+ //#endregion
447
+ //#region ../webpack/src/utils/config.ts
423
448
  function createWebpackConfigContext(nuxt) {
424
449
  return {
425
450
  nuxt,
@@ -447,6 +472,8 @@ function fileName(ctx, key) {
447
472
  }
448
473
  return fileName;
449
474
  }
475
+ //#endregion
476
+ //#region ../webpack/src/presets/assets.ts
450
477
  function assets(ctx) {
451
478
  ctx.config.module.rules.push({
452
479
  test: /\.(png|jpe?g|gif|svg|webp)$/i,
@@ -477,6 +504,8 @@ function assets(ctx) {
477
504
  }]
478
505
  });
479
506
  }
507
+ //#endregion
508
+ //#region ../webpack/src/plugins/warning-ignore.ts
480
509
  var WarningIgnorePlugin = class {
481
510
  filter;
482
511
  constructor(filter) {
@@ -488,6 +517,12 @@ var WarningIgnorePlugin = class {
488
517
  });
489
518
  }
490
519
  };
520
+ //#endregion
521
+ //#region ../webpack/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
+ */
491
526
  const validate = (compiler) => {
492
527
  if (compiler.options.target !== "node") logger.warn("webpack config `target` should be \"node\".");
493
528
  if (!compiler.options.externals) logger.info("It is recommended to externalize dependencies in the server build for better build performance.");
@@ -498,10 +533,17 @@ const extractQueryPartJS = (file) => isJSRegExp.exec(file)?.[1];
498
533
  const isCSSRegExp = /\.css(?:\?[^.]+)?$/;
499
534
  const isCSS = (file) => isCSSRegExp.test(file);
500
535
  const isHotUpdate = (file) => file.includes("hot-update");
536
+ //#endregion
537
+ //#region ../webpack/src/plugins/rollup-compat-dynamic-import.ts
501
538
  const DYNAMIC_IMPORT_RE = /import\([^)]*\+\s*__webpack_require__[^+]*\)\.then/;
502
539
  const DYNAMIC_IMPORT_REPLACE_RE = /import\([^)]*\+\s*(__webpack_require__[^+]*)\)\.then/g;
503
540
  const HELPER_FILENAME = "_dynamic-import-helper.mjs";
504
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
+ */
505
547
  var RollupCompatDynamicImportPlugin = class {
506
548
  apply(compiler) {
507
549
  compiler.hooks.compilation.tap("RollupCompatDynamicImportPlugin", (compilation) => {
@@ -569,6 +611,8 @@ export function _rollupDynamicImport(chunkId) {
569
611
  `;
570
612
  }
571
613
  };
614
+ //#endregion
615
+ //#region ../webpack/src/presets/base.ts
572
616
  async function base(ctx) {
573
617
  await applyPresets(ctx, [
574
618
  baseAlias,
@@ -739,6 +783,8 @@ const statsMap = {
739
783
  info: "normal",
740
784
  verbose: "verbose"
741
785
  };
786
+ //#endregion
787
+ //#region ../webpack/src/presets/esbuild.ts
742
788
  function esbuild(ctx) {
743
789
  const target = ctx.isServer ? "es2020" : "chrome85";
744
790
  ctx.config.optimization.minimizer.push(new EsbuildPlugin());
@@ -766,6 +812,8 @@ function esbuild(ctx) {
766
812
  }
767
813
  });
768
814
  }
815
+ //#endregion
816
+ //#region ../webpack/src/presets/pug.ts
769
817
  function pug(ctx) {
770
818
  ctx.config.module.rules.push({
771
819
  test: /\.pug$/i,
@@ -781,6 +829,8 @@ function pug(ctx) {
781
829
  }] }]
782
830
  });
783
831
  }
832
+ //#endregion
833
+ //#region ../webpack/src/utils/postcss.ts
784
834
  const isPureObject = (obj) => obj !== null && !Array.isArray(obj) && typeof obj === "object";
785
835
  function sortPlugins({ plugins, order }) {
786
836
  const names = Object.keys(plugins);
@@ -826,6 +876,8 @@ async function getPostcssConfig(nuxt) {
826
876
  postcssOptions
827
877
  };
828
878
  }
879
+ //#endregion
880
+ //#region ../webpack/src/presets/style.ts
829
881
  async function style(ctx) {
830
882
  await applyPresets(ctx, [
831
883
  loaders,
@@ -905,6 +957,12 @@ async function createPostcssLoadersRule(ctx) {
905
957
  options: config
906
958
  };
907
959
  }
960
+ //#endregion
961
+ //#region ../webpack/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
+ */
908
966
  var VueSSRClientPlugin = class {
909
967
  serverDist;
910
968
  nuxt;
@@ -987,6 +1045,8 @@ var VueSSRClientPlugin = class {
987
1045
  });
988
1046
  }
989
1047
  };
1048
+ //#endregion
1049
+ //#region ../webpack/src/plugins/vue/server.ts
990
1050
  const JS_MAP_RE = /\.js\.map$/;
991
1051
  var VueSSRServerPlugin = class {
992
1052
  options;
@@ -1035,6 +1095,8 @@ var VueSSRServerPlugin = class {
1035
1095
  });
1036
1096
  }
1037
1097
  };
1098
+ //#endregion
1099
+ //#region ../webpack/src/presets/vue.ts
1038
1100
  function vue(ctx) {
1039
1101
  ctx.config.plugins.push(new (VueLoaderPlugin.default || VueLoaderPlugin)());
1040
1102
  ctx.config.module.rules.push({
@@ -1064,6 +1126,8 @@ function vue(ctx) {
1064
1126
  "__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": ctx.nuxt.options.debug && ctx.nuxt.options.debug.hydration
1065
1127
  }));
1066
1128
  }
1129
+ //#endregion
1130
+ //#region ../webpack/src/presets/nuxt.ts
1067
1131
  async function nuxt(ctx) {
1068
1132
  await applyPresets(ctx, [
1069
1133
  base,
@@ -1074,6 +1138,8 @@ async function nuxt(ctx) {
1074
1138
  vue
1075
1139
  ]);
1076
1140
  }
1141
+ //#endregion
1142
+ //#region ../webpack/src/configs/client.ts
1077
1143
  async function client(ctx) {
1078
1144
  ctx.name = "client";
1079
1145
  ctx.isClient = true;
@@ -1179,6 +1245,8 @@ function clientPlugins(ctx) {
1179
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 }));
1180
1246
  }
1181
1247
  }
1248
+ //#endregion
1249
+ //#region ../webpack/src/presets/node.ts
1182
1250
  function node(ctx) {
1183
1251
  ctx.config.target = "node";
1184
1252
  ctx.config.node = false;
@@ -1207,6 +1275,8 @@ function node(ctx) {
1207
1275
  maxAssetSize: Number.POSITIVE_INFINITY
1208
1276
  };
1209
1277
  }
1278
+ //#endregion
1279
+ //#region ../webpack/src/configs/server.ts
1210
1280
  const assetPattern = /\.(?:css|s[ca]ss|png|jpe?g|gif|svg|woff2?|eot|ttf|otf|webp|webm|mp4|ogv)(?:\?.*)?$/i;
1211
1281
  const VIRTUAL_RE = /^\0?virtual:(?:nuxt:)?/;
1212
1282
  async function server(ctx) {
@@ -1296,6 +1366,8 @@ function serverPlugins(ctx) {
1296
1366
  }));
1297
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 }));
1298
1368
  }
1369
+ //#endregion
1370
+ //#region ../webpack/src/webpack.ts
1299
1371
  const bundle = async (nuxt) => {
1300
1372
  const webpackConfigs = await Promise.all([client, ...nuxt.options.ssr ? [server] : []].map(async (preset) => {
1301
1373
  const ctx = createWebpackConfigContext(nuxt);
@@ -1303,6 +1375,7 @@ const bundle = async (nuxt) => {
1303
1375
  await applyPresets(ctx, preset);
1304
1376
  return ctx.config;
1305
1377
  }));
1378
+ /** Remove Nitro rollup plugin for handling dynamic imports from webpack chunks */
1306
1379
  if (!nuxt.options.dev) useNitro().hooks.hook("rollup:before", (_nitro, config) => {
1307
1380
  const plugins = config.plugins;
1308
1381
  const existingPlugin = plugins.findIndex((i) => i && "name" in i && i.name === "dynamic-require");
@@ -1365,10 +1438,6 @@ function wdmToH3Handler(devMiddleware) {
1365
1438
  res.end("Forbidden");
1366
1439
  return;
1367
1440
  }
1368
- event.context.webpack = {
1369
- ...event.context.webpack,
1370
- devMiddleware: devMiddleware.context
1371
- };
1372
1441
  return await new Promise((resolve, reject) => {
1373
1442
  res.stream = (stream) => {
1374
1443
  resolve(stream);
@@ -1433,4 +1502,5 @@ async function compile(compiler) {
1433
1502
  function defineEventHandler(handler) {
1434
1503
  return Object.assign(handler, { __is_handler__: true });
1435
1504
  }
1505
+ //#endregion
1436
1506
  export { bundle };
@@ -1,4 +1,5 @@
1
1
  import { normalize, relative } from "pathe";
2
+ //#region ../webpack/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/rspack-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,12 +25,12 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
28
- "@rspack/core": "^1.7.5",
29
- "@vue/compiler-sfc": "3.5.27",
30
- "autoprefixer": "^10.4.24",
31
- "css-loader": "^7.1.3",
32
- "css-minimizer-webpack-plugin": "^7.0.4",
33
- "cssnano": "^7.1.2",
28
+ "@rspack/core": "^1.7.8",
29
+ "@vue/compiler-sfc": "3.5.30",
30
+ "autoprefixer": "^10.4.27",
31
+ "css-loader": "^7.1.4",
32
+ "css-minimizer-webpack-plugin": "^8.0.0",
33
+ "cssnano": "^7.1.3",
34
34
  "defu": "^6.1.4",
35
35
  "esbuild-loader": "^4.4.2",
36
36
  "escape-string-regexp": "^5.0.0",
@@ -39,21 +39,21 @@
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
- "mlly": "^1.8.0",
42
+ "memfs": "^4.56.11",
43
+ "mlly": "^1.8.1",
44
44
  "ohash": "^2.0.11",
45
45
  "pathe": "^2.0.3",
46
46
  "pify": "^6.1.0",
47
- "postcss": "^8.5.6",
47
+ "postcss": "^8.5.8",
48
48
  "postcss-import": "^16.1.1",
49
49
  "postcss-import-resolver": "^2.0.0",
50
- "postcss-loader": "^8.2.0",
50
+ "postcss-loader": "^8.2.1",
51
51
  "postcss-url": "^10.1.3",
52
52
  "pug-plain-loader": "^1.1.0",
53
- "seroval": "^1.5.0",
54
- "std-env": "^3.10.0",
53
+ "seroval": "^1.5.1",
54
+ "std-env": "^4.0.0",
55
55
  "time-fix-plugin": "^2.0.7",
56
- "ts-checker-rspack-plugin": "^1.2.6",
56
+ "ts-checker-rspack-plugin": "^1.3.0",
57
57
  "ufo": "^1.6.3",
58
58
  "unenv": "^2.0.0-rc.24",
59
59
  "unplugin": "^3.0.0",
@@ -64,22 +64,22 @@
64
64
  "webpack-dev-middleware": "^7.4.5",
65
65
  "webpack-hot-middleware": "^2.26.1",
66
66
  "webpackbar": "^7.0.0",
67
- "@nuxt/kit": "3.21.1"
67
+ "@nuxt/kit": "3.21.2"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/pify": "6.1.0",
71
71
  "@types/webpack-bundle-analyzer": "4.7.0",
72
72
  "@types/webpack-hot-middleware": "2.25.12",
73
- "h3": "1.15.5",
74
- "h3-next": "npm:h3@2.0.1-rc.14",
75
- "obuild": "0.4.27",
76
- "rollup": "4.57.1",
77
- "vue": "3.5.27",
78
- "@nuxt/schema": "3.21.1"
73
+ "h3": "1.15.6",
74
+ "h3-next": "npm:h3@2.0.1-rc.16",
75
+ "obuild": "0.4.32",
76
+ "rollup": "4.59.0",
77
+ "vue": "3.5.30",
78
+ "@nuxt/schema": "3.21.2"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "vue": "^3.3.4",
82
- "nuxt": "3.21.1"
82
+ "nuxt": "3.21.2"
83
83
  },
84
84
  "engines": {
85
85
  "node": "^20.19.0 || >=22.12.0"