@nuxt/webpack-builder 3.21.0 → 3.21.1

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 +1 -1
  2. package/dist/THIRD-PARTY-LICENSES.md +3847 -0
  3. package/dist/_chunks/libs/@babel/parser.d.mts +1536 -0
  4. package/dist/_chunks/libs/@jridgewell/trace-mapping.d.mts +82 -0
  5. package/dist/_chunks/libs/@types/estree.d.mts +525 -0
  6. package/dist/_chunks/libs/@types/pug.d.mts +123 -0
  7. package/dist/_chunks/libs/@unhead/vue.d.mts +1096 -0
  8. package/dist/_chunks/libs/@vitejs/plugin-vue-jsx.d.mts +5297 -0
  9. package/dist/_chunks/libs/@vitejs/plugin-vue.d.mts +83 -0
  10. package/dist/_chunks/libs/@volar/language-core.d.mts +56 -0
  11. package/dist/_chunks/libs/@volar/source-map.d.mts +10 -0
  12. package/dist/_chunks/libs/@vue/compiler-core.d.mts +1213 -0
  13. package/dist/_chunks/libs/@vue/compiler-dom.d.mts +45 -0
  14. package/dist/_chunks/libs/@vue/language-core.d.mts +11387 -0
  15. package/dist/_chunks/libs/c12.d.mts +147 -0
  16. package/dist/_chunks/libs/compatx.d.mts +47 -0
  17. package/dist/_chunks/libs/h3.d.mts +45 -0
  18. package/dist/_chunks/libs/ofetch.d.mts +870 -0
  19. package/dist/_chunks/libs/open.d.mts +1 -0
  20. package/dist/_chunks/libs/oxc-transform.d.mts +422 -0
  21. package/dist/_chunks/libs/pkg-types.d.mts +23 -0
  22. package/dist/_chunks/libs/rollup-plugin-visualizer.d.mts +90 -0
  23. package/dist/_chunks/libs/scule.d.mts +15 -0
  24. package/dist/_chunks/libs/unctx.d.mts +28 -0
  25. package/dist/_chunks/libs/unimport.d.mts +386 -0
  26. package/dist/_chunks/libs/untyped.d.mts +44 -0
  27. package/dist/_chunks/libs/vue-router.d.mts +1413 -0
  28. package/dist/_chunks/rolldown-runtime.mjs +12 -0
  29. package/dist/index.d.mts +3146 -1
  30. package/dist/index.mjs +107 -191
  31. package/dist/loaders/vue-module-identifier.mjs +1 -6
  32. package/package.json +16 -16
package/dist/index.mjs CHANGED
@@ -36,8 +36,6 @@ import { normalizeWebpackManifest, precomputeDependencies } from "vue-bundle-ren
36
36
  import { hash } from "ohash";
37
37
  import { serialize } from "seroval";
38
38
  import { parseNodeModulePath } from "mlly";
39
-
40
- //#region src/plugins/dynamic-base.ts
41
39
  const defaults = {
42
40
  globalPublicPath: "__webpack_public_path__",
43
41
  sourcemap: true
@@ -67,13 +65,7 @@ const DynamicBasePlugin = createUnplugin((options = {}) => {
67
65
  }
68
66
  };
69
67
  });
70
-
71
- //#endregion
72
- //#region builder.mjs
73
68
  const builder = "webpack";
74
-
75
- //#endregion
76
- //#region src/plugins/chunk.ts
77
69
  const pluginName = "ChunkErrorPlugin";
78
70
  var ChunkErrorPlugin = class {
79
71
  apply(compiler) {
@@ -105,16 +97,13 @@ if (typeof ${ensureChunk} !== "undefined") {
105
97
  `;
106
98
  }
107
99
  };
108
-
109
- //#endregion
110
- //#region src/plugins/ssr-styles.ts
111
100
  const CSS_URL_RE = /url\((['"]?)(\/[^)]+?)\1\)/g;
112
101
  const isVueFile = (id) => /\.vue(?:\?|$)/.test(id);
113
102
  const isCSSLike = (name) => /\.(?:css|scss|sass|less|styl(?:us)?|postcss|pcss)(?:\?|$)/.test(name);
114
- function normalizePath(nuxt$1, id) {
103
+ function normalizePath(nuxt, id) {
115
104
  if (!id) return null;
116
105
  const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
117
- const rel = relative(nuxt$1.options.srcDir, pathname);
106
+ const rel = relative(nuxt.options.srcDir, pathname);
118
107
  if (rel.startsWith("..")) return null;
119
108
  return rel;
120
109
  }
@@ -134,12 +123,12 @@ function extractVueStyles(filePath) {
134
123
  const styles = [];
135
124
  const scopeId = createHash("sha256").update(filePath).digest("hex").slice(0, 8);
136
125
  for (let i = 0; i < descriptor.styles.length; i++) {
137
- const style$1 = descriptor.styles[i];
126
+ const style = descriptor.styles[i];
138
127
  const result = compileStyle({
139
- source: style$1.content,
128
+ source: style.content,
140
129
  filename: filePath,
141
130
  id: `data-v-${scopeId}`,
142
- scoped: style$1.scoped
131
+ scoped: style.scoped
143
132
  });
144
133
  if (!result.errors.length && result.code) styles.push(normalizeCSSContent(result.code));
145
134
  }
@@ -153,10 +142,10 @@ var SSRStylesPlugin = class {
153
142
  clientCSSByIssuer = /* @__PURE__ */ new Map();
154
143
  chunksWithInlinedCSS = /* @__PURE__ */ new Set();
155
144
  globalCSSPaths = /* @__PURE__ */ new Set();
156
- constructor(nuxt$1) {
157
- this.nuxt = nuxt$1;
145
+ constructor(nuxt) {
146
+ this.nuxt = nuxt;
158
147
  this.globalCSSPaths = this.resolveGlobalCSS();
159
- nuxt$1.hook("build:manifest", (manifest) => {
148
+ nuxt.hook("build:manifest", (manifest) => {
160
149
  for (const [id, chunk] of Object.entries(manifest)) {
161
150
  if (chunk.isEntry && chunk.src) this.chunksWithInlinedCSS.add(chunk.src);
162
151
  else if (this.chunksWithInlinedCSS.has(id)) chunk.css &&= [];
@@ -182,9 +171,9 @@ var SSRStylesPlugin = class {
182
171
  isPublicAsset(url, nitro) {
183
172
  const cleaned = url.replace(/[?#].*$/, "");
184
173
  for (const dir of nitro.options.publicAssets) {
185
- const base$1 = withTrailingSlash(dir.baseURL || "/");
186
- if (!url.startsWith(base$1)) continue;
187
- if (existsSync(cleaned.replace(base$1, withTrailingSlash(dir.dir)))) return true;
174
+ const base = withTrailingSlash(dir.baseURL || "/");
175
+ if (!url.startsWith(base)) continue;
176
+ if (existsSync(cleaned.replace(base, withTrailingSlash(dir.dir)))) return true;
188
177
  }
189
178
  return false;
190
179
  }
@@ -264,8 +253,8 @@ var SSRStylesPlugin = class {
264
253
  });
265
254
  }
266
255
  emitServerStyles(compilation) {
267
- const { webpack: webpack$1 } = compilation.compiler;
268
- const stage = webpack$1.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE;
256
+ const { webpack } = compilation.compiler;
257
+ const stage = webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE;
269
258
  compilation.hooks.processAssets.tap({
270
259
  name: "SSRStylesPlugin",
271
260
  stage
@@ -295,10 +284,10 @@ var SSRStylesPlugin = class {
295
284
  if (vueStyles.length) collected.set(rel, new Set(vueStyles));
296
285
  }
297
286
  const emitted = {};
298
- const rawSource = webpack$1.sources.RawSource;
287
+ const rawSource = webpack.sources.RawSource;
299
288
  for (const [rel, cssSet] of collected.entries()) {
300
289
  if (!cssSet.size) continue;
301
- const transformed = Array.from(cssSet).map((style$1) => this.rewriteStyle(style$1, nitro));
290
+ const transformed = Array.from(cssSet).map((style) => this.rewriteStyle(style, nitro));
302
291
  const needsPublicAssets = transformed.some((t) => t.needsPublicAsset);
303
292
  const needsBuildAssets = transformed.some((t) => t.needsBuildAsset);
304
293
  const imports = [];
@@ -365,8 +354,8 @@ var SSRStylesPlugin = class {
365
354
  });
366
355
  }
367
356
  collectCSS(compilation) {
368
- const { webpack: webpack$1 } = compilation.compiler;
369
- const stage = compilation.compiler.options.name === "server" ? webpack$1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS : webpack$1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER;
357
+ const { webpack } = compilation.compiler;
358
+ const stage = compilation.compiler.options.name === "server" ? webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS : webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER;
370
359
  const chunkCSSMeta = /* @__PURE__ */ new Map();
371
360
  compilation.hooks.processAssets.tap({
372
361
  name: "SSRStylesPlugin",
@@ -425,9 +414,6 @@ var SSRStylesPlugin = class {
425
414
  return cssChunks;
426
415
  }
427
416
  };
428
-
429
- //#endregion
430
- //#region src/utils/mfs.ts
431
417
  function createMFS() {
432
418
  const _fs = { ...createFsFromVolume(new Volume()) };
433
419
  _fs.join = join;
@@ -435,24 +421,17 @@ function createMFS() {
435
421
  _fs.readFile = pify(_fs.readFile);
436
422
  return _fs;
437
423
  }
438
-
439
- //#endregion
440
- //#region src/utils/index.ts
441
- /** @since 3.9.0 */
442
424
  function toArray(value) {
443
425
  return Array.isArray(value) ? value : [value];
444
426
  }
445
-
446
- //#endregion
447
- //#region src/utils/config.ts
448
- function createWebpackConfigContext(nuxt$1) {
427
+ function createWebpackConfigContext(nuxt) {
449
428
  return {
450
- nuxt: nuxt$1,
451
- options: nuxt$1.options,
452
- userConfig: nuxt$1.options.webpack,
429
+ nuxt,
430
+ options: nuxt.options,
431
+ userConfig: nuxt.options.webpack,
453
432
  config: {},
454
433
  name: "base",
455
- isDev: nuxt$1.options.dev,
434
+ isDev: nuxt.options.dev,
456
435
  isServer: false,
457
436
  isClient: false,
458
437
  alias: {},
@@ -464,17 +443,14 @@ async function applyPresets(ctx, presets) {
464
443
  else await preset(ctx);
465
444
  }
466
445
  function fileName(ctx, key) {
467
- let fileName$1 = ctx.userConfig.filenames[key];
468
- if (typeof fileName$1 === "function") fileName$1 = fileName$1(ctx);
469
- if (typeof fileName$1 === "string" && ctx.options.dev) {
470
- const hash$1 = /\[(chunkhash|contenthash|hash)(?::\d+)?\]/.exec(fileName$1);
471
- if (hash$1) logger.warn(`Notice: Please do not use ${hash$1[1]} in dev mode to prevent memory leak`);
446
+ let fileName = ctx.userConfig.filenames[key];
447
+ if (typeof fileName === "function") fileName = fileName(ctx);
448
+ if (typeof fileName === "string" && ctx.options.dev) {
449
+ const hash = /\[(chunkhash|contenthash|hash)(?::\d+)?\]/.exec(fileName);
450
+ if (hash) logger.warn(`Notice: Please do not use ${hash[1]} in dev mode to prevent memory leak`);
472
451
  }
473
- return fileName$1;
452
+ return fileName;
474
453
  }
475
-
476
- //#endregion
477
- //#region src/presets/assets.ts
478
454
  function assets(ctx) {
479
455
  ctx.config.module.rules.push({
480
456
  test: /\.(png|jpe?g|gif|svg|webp)$/i,
@@ -505,9 +481,6 @@ function assets(ctx) {
505
481
  }]
506
482
  });
507
483
  }
508
-
509
- //#endregion
510
- //#region src/plugins/warning-ignore.ts
511
484
  var WarningIgnorePlugin = class {
512
485
  filter;
513
486
  constructor(filter) {
@@ -519,13 +492,6 @@ var WarningIgnorePlugin = class {
519
492
  });
520
493
  }
521
494
  };
522
-
523
- //#endregion
524
- //#region src/plugins/vue/util.ts
525
- /**
526
- * This file is based on Vue.js (MIT) webpack plugins
527
- * https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/util.js
528
- */
529
495
  const validate = (compiler) => {
530
496
  if (compiler.options.target !== "node") logger.warn("webpack config `target` should be \"node\".");
531
497
  if (!compiler.options.externals) logger.info("It is recommended to externalize dependencies in the server build for better build performance.");
@@ -536,36 +502,28 @@ const extractQueryPartJS = (file) => isJSRegExp.exec(file)?.[1];
536
502
  const isCSSRegExp = /\.css(?:\?[^.]+)?$/;
537
503
  const isCSS = (file) => isCSSRegExp.test(file);
538
504
  const isHotUpdate = (file) => file.includes("hot-update");
539
-
540
- //#endregion
541
- //#region src/plugins/rollup-compat-dynamic-import.ts
542
505
  const DYNAMIC_IMPORT_RE = /import\([^)]*\+\s*__webpack_require__[^+]*\)\.then/;
543
506
  const DYNAMIC_IMPORT_REPLACE_RE = /import\([^)]*\+\s*(__webpack_require__[^+]*)\)\.then/g;
544
507
  const HELPER_FILENAME = "_dynamic-import-helper.mjs";
545
508
  const HELPER_IMPORT = `import { _rollupDynamicImport } from "./${HELPER_FILENAME}";\n`;
546
- /**
547
- * Webpack plugin that generates rollup-compatible dynamic imports.
548
- * This plugin uses webpack's native compilation hooks to override dynamic import generation
549
- * and create rollup-compatible code directly during webpack's compilation process.
550
- */
551
509
  var RollupCompatDynamicImportPlugin = class {
552
510
  apply(compiler) {
553
511
  compiler.hooks.compilation.tap("RollupCompatDynamicImportPlugin", (compilation) => {
554
512
  compilation.hooks.processAssets.tapAsync({
555
513
  name: "RollupCompatDynamicImportPlugin",
556
514
  stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
557
- }, (assets$1, callback) => {
515
+ }, (assets, callback) => {
558
516
  try {
559
517
  const targetFiles = /* @__PURE__ */ new Set();
560
518
  for (const chunk of compilation.chunks) if (chunk.canBeInitial() || chunk.hasRuntime()) for (const file of chunk.files || []) targetFiles.add(file);
561
- for (const [filename, asset] of Object.entries(assets$1)) {
519
+ for (const [filename, asset] of Object.entries(assets)) {
562
520
  if (!isJS(filename)) continue;
563
521
  if (!targetFiles.has(filename)) continue;
564
522
  const source = asset.source();
565
523
  const originalCode = typeof source === "string" ? source : source.toString();
566
524
  if (!DYNAMIC_IMPORT_RE.test(originalCode)) continue;
567
525
  const transformedCode = this.transformDynamicImports(originalCode);
568
- if (transformedCode !== originalCode) assets$1[filename] = new compiler.webpack.sources.RawSource(transformedCode);
526
+ if (transformedCode !== originalCode) assets[filename] = new compiler.webpack.sources.RawSource(transformedCode);
569
527
  }
570
528
  this.generateDynamicImportHelper(compilation);
571
529
  callback();
@@ -615,9 +573,6 @@ export function _rollupDynamicImport(chunkId) {
615
573
  `;
616
574
  }
617
575
  };
618
-
619
- //#endregion
620
- //#region src/presets/base.ts
621
576
  async function base(ctx) {
622
577
  await applyPresets(ctx, [
623
578
  baseAlias,
@@ -788,9 +743,6 @@ const statsMap = {
788
743
  info: "normal",
789
744
  verbose: "verbose"
790
745
  };
791
-
792
- //#endregion
793
- //#region src/presets/esbuild.ts
794
746
  function esbuild(ctx) {
795
747
  const target = ctx.isServer ? "es2020" : "chrome85";
796
748
  ctx.config.optimization.minimizer.push(new EsbuildPlugin());
@@ -818,9 +770,6 @@ function esbuild(ctx) {
818
770
  }
819
771
  });
820
772
  }
821
-
822
- //#endregion
823
- //#region src/presets/pug.ts
824
773
  function pug(ctx) {
825
774
  ctx.config.module.rules.push({
826
775
  test: /\.pug$/i,
@@ -836,35 +785,32 @@ function pug(ctx) {
836
785
  }] }]
837
786
  });
838
787
  }
839
-
840
- //#endregion
841
- //#region src/utils/postcss.ts
842
788
  const isPureObject = (obj) => obj !== null && !Array.isArray(obj) && typeof obj === "object";
843
789
  function sortPlugins({ plugins, order }) {
844
790
  const names = Object.keys(plugins);
845
791
  return typeof order === "function" ? order(names) : order || names;
846
792
  }
847
- async function getPostcssConfig(nuxt$1) {
848
- if (!nuxt$1.options.webpack.postcss || !nuxt$1.options.postcss) return false;
849
- const postcssOptions = defu({}, nuxt$1.options.postcss, {
793
+ async function getPostcssConfig(nuxt) {
794
+ if (!nuxt.options.webpack.postcss || !nuxt.options.postcss) return false;
795
+ const postcssOptions = defu({}, nuxt.options.postcss, {
850
796
  plugins: {
851
797
  "postcss-import": { resolve: createResolver({
852
- alias: { ...nuxt$1.options.alias },
853
- modules: nuxt$1.options.modulesDir
798
+ alias: { ...nuxt.options.alias },
799
+ modules: nuxt.options.modulesDir
854
800
  }) },
855
801
  "postcss-url": {}
856
802
  },
857
- sourceMap: nuxt$1.options.webpack.cssSourceMap
803
+ sourceMap: nuxt.options.webpack.cssSourceMap
858
804
  });
859
- const jiti = createJiti(nuxt$1.options.rootDir, { alias: nuxt$1.options.alias });
805
+ const jiti = createJiti(nuxt.options.rootDir, { alias: nuxt.options.alias });
860
806
  if (!Array.isArray(postcssOptions.plugins) && isPureObject(postcssOptions.plugins)) {
861
807
  const plugins = [];
862
- for (const pluginName$1 of sortPlugins(postcssOptions)) {
863
- const pluginOptions = postcssOptions.plugins[pluginName$1];
808
+ for (const pluginName of sortPlugins(postcssOptions)) {
809
+ const pluginOptions = postcssOptions.plugins[pluginName];
864
810
  if (!pluginOptions) continue;
865
811
  let pluginFn;
866
- for (const parentURL of nuxt$1.options.modulesDir) {
867
- pluginFn = await jiti.import(pluginName$1, {
812
+ for (const parentURL of nuxt.options.modulesDir) {
813
+ pluginFn = await jiti.import(pluginName, {
868
814
  parentURL: parentURL.replace(/\/node_modules\/?$/, ""),
869
815
  try: true,
870
816
  default: true
@@ -874,19 +820,16 @@ async function getPostcssConfig(nuxt$1) {
874
820
  break;
875
821
  }
876
822
  }
877
- if (typeof pluginFn !== "function") console.warn(`[nuxt] could not import postcss plugin \`${pluginName$1}\`. Please report this as a bug.`);
823
+ if (typeof pluginFn !== "function") console.warn(`[nuxt] could not import postcss plugin \`${pluginName}\`. Please report this as a bug.`);
878
824
  }
879
825
  postcssOptions.plugins = plugins;
880
826
  }
881
827
  return {
882
- sourceMap: nuxt$1.options.webpack.cssSourceMap,
883
- ...nuxt$1.options.webpack.postcss,
828
+ sourceMap: nuxt.options.webpack.cssSourceMap,
829
+ ...nuxt.options.webpack.postcss,
884
830
  postcssOptions
885
831
  };
886
832
  }
887
-
888
- //#endregion
889
- //#region src/presets/style.ts
890
833
  async function style(ctx) {
891
834
  await applyPresets(ctx, [
892
835
  loaders,
@@ -966,13 +909,6 @@ async function createPostcssLoadersRule(ctx) {
966
909
  options: config
967
910
  };
968
911
  }
969
-
970
- //#endregion
971
- //#region src/plugins/vue/client.ts
972
- /**
973
- * This file is based on Vue.js (MIT) webpack plugins
974
- * https://github.com/vuejs/vue/blob/dev/src/server/webpack-plugin/client.js
975
- */
976
912
  var VueSSRClientPlugin = class {
977
913
  serverDist;
978
914
  nuxt;
@@ -990,9 +926,9 @@ var VueSSRClientPlugin = class {
990
926
  const stats = compilation.getStats().toJson();
991
927
  const context = this.nuxt.options.srcDir;
992
928
  const initialFiles = /* @__PURE__ */ new Set();
993
- for (const { assets: assets$1 } of Object.values(stats.entrypoints)) {
994
- if (!assets$1) continue;
995
- for (const asset of assets$1) {
929
+ for (const { assets } of Object.values(stats.entrypoints)) {
930
+ if (!assets) continue;
931
+ for (const asset of assets) {
996
932
  const file = asset.name;
997
933
  if ((isJS(file) || isCSS(file)) && !isHotUpdate(file)) initialFiles.add(file);
998
934
  }
@@ -1038,11 +974,11 @@ var VueSSRClientPlugin = class {
1038
974
  const files = Array.from(filesSet);
1039
975
  webpackManifest.modules[relativeId] = files;
1040
976
  if (Array.isArray(m.modules)) for (const concatenatedModule of m.modules) {
1041
- const relativeId$1 = this.getRelativeModuleId(concatenatedModule.identifier, context);
1042
- webpackManifest.modules[relativeId$1] ||= files;
977
+ const relativeId = this.getRelativeModuleId(concatenatedModule.identifier, context);
978
+ webpackManifest.modules[relativeId] ||= files;
1043
979
  }
1044
980
  if (stats.modules) {
1045
- for (const m$1 of stats.modules) if (m$1.assets?.length && m$1.chunks?.includes(cid)) files.push(...m$1.assets.map(fileToIndex));
981
+ for (const m of stats.modules) if (m.assets?.length && m.chunks?.includes(cid)) files.push(...m.assets.map(fileToIndex));
1046
982
  }
1047
983
  }
1048
984
  const manifest = normalizeWebpackManifest(webpackManifest);
@@ -1055,9 +991,6 @@ var VueSSRClientPlugin = class {
1055
991
  });
1056
992
  }
1057
993
  };
1058
-
1059
- //#endregion
1060
- //#region src/plugins/vue/server.ts
1061
994
  const JS_MAP_RE = /\.js\.map$/;
1062
995
  var VueSSRServerPlugin = class {
1063
996
  options;
@@ -1070,7 +1003,7 @@ var VueSSRServerPlugin = class {
1070
1003
  compilation.hooks.processAssets.tapAsync({
1071
1004
  name: "VueSSRServerPlugin",
1072
1005
  stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
1073
- }, (assets$1, cb) => {
1006
+ }, (assets, cb) => {
1074
1007
  const stats = compilation.getStats().toJson();
1075
1008
  const [entryName] = Object.keys(stats.entrypoints);
1076
1009
  const entryInfo = stats.entrypoints[entryName];
@@ -1079,24 +1012,24 @@ var VueSSRServerPlugin = class {
1079
1012
  if (entryAssets.length > 1) throw new Error("Server-side bundle should have one single entry file. Avoid using CommonsChunkPlugin in the server config.");
1080
1013
  const [entry] = entryAssets;
1081
1014
  if (!entry || typeof entry.name !== "string") throw new Error(`Entry "${entryName}" not found. Did you specify the correct entry option?`);
1082
- const bundle$1 = {
1015
+ const bundle = {
1083
1016
  entry: entry.name,
1084
1017
  files: {},
1085
1018
  maps: {}
1086
1019
  };
1087
1020
  for (const asset of stats.assets) if (isJS(asset.name)) {
1088
1021
  const queryPart = extractQueryPartJS(asset.name);
1089
- if (queryPart !== void 0) bundle$1.files[asset.name] = asset.name.replace(queryPart, "");
1090
- else bundle$1.files[asset.name] = asset.name;
1091
- } else if (JS_MAP_RE.test(asset.name)) bundle$1.maps[asset.name.replace(/\.map$/, "")] = asset.name;
1092
- else delete assets$1[asset.name];
1093
- const src = JSON.stringify(bundle$1, null, 2);
1094
- assets$1[this.options.filename] = {
1022
+ if (queryPart !== void 0) bundle.files[asset.name] = asset.name.replace(queryPart, "");
1023
+ else bundle.files[asset.name] = asset.name;
1024
+ } else if (JS_MAP_RE.test(asset.name)) bundle.maps[asset.name.replace(/\.map$/, "")] = asset.name;
1025
+ else delete assets[asset.name];
1026
+ const src = JSON.stringify(bundle, null, 2);
1027
+ assets[this.options.filename] = {
1095
1028
  source: () => src,
1096
1029
  size: () => src.length
1097
1030
  };
1098
1031
  const mjsSrc = "export default " + src;
1099
- assets$1[this.options.filename.replace(".json", ".mjs")] = {
1032
+ assets[this.options.filename.replace(".json", ".mjs")] = {
1100
1033
  source: () => mjsSrc,
1101
1034
  map: () => null,
1102
1035
  size: () => mjsSrc.length
@@ -1106,9 +1039,6 @@ var VueSSRServerPlugin = class {
1106
1039
  });
1107
1040
  }
1108
1041
  };
1109
-
1110
- //#endregion
1111
- //#region src/presets/vue.ts
1112
1042
  function vue(ctx) {
1113
1043
  ctx.config.plugins.push(new (VueLoaderPlugin.default || VueLoaderPlugin)());
1114
1044
  ctx.config.module.rules.push({
@@ -1138,9 +1068,6 @@ function vue(ctx) {
1138
1068
  "__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": ctx.nuxt.options.debug && ctx.nuxt.options.debug.hydration
1139
1069
  }));
1140
1070
  }
1141
-
1142
- //#endregion
1143
- //#region src/presets/nuxt.ts
1144
1071
  async function nuxt(ctx) {
1145
1072
  await applyPresets(ctx, [
1146
1073
  base,
@@ -1151,9 +1078,6 @@ async function nuxt(ctx) {
1151
1078
  vue
1152
1079
  ]);
1153
1080
  }
1154
-
1155
- //#endregion
1156
- //#region src/configs/client.ts
1157
1081
  async function client(ctx) {
1158
1082
  ctx.name = "client";
1159
1083
  ctx.isClient = true;
@@ -1259,9 +1183,6 @@ function clientPlugins(ctx) {
1259
1183
  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 }));
1260
1184
  }
1261
1185
  }
1262
-
1263
- //#endregion
1264
- //#region src/presets/node.ts
1265
1186
  function node(ctx) {
1266
1187
  ctx.config.target = "node";
1267
1188
  ctx.config.node = false;
@@ -1290,9 +1211,6 @@ function node(ctx) {
1290
1211
  maxAssetSize: Number.POSITIVE_INFINITY
1291
1212
  };
1292
1213
  }
1293
-
1294
- //#endregion
1295
- //#region src/configs/server.ts
1296
1214
  const assetPattern = /\.(?:css|s[ca]ss|png|jpe?g|gif|svg|woff2?|eot|ttf|otf|webp|webm|mp4|ogv)(?:\?.*)?$/i;
1297
1215
  const VIRTUAL_RE = /^\0?virtual:(?:nuxt:)?/;
1298
1216
  async function server(ctx) {
@@ -1382,117 +1300,117 @@ function serverPlugins(ctx) {
1382
1300
  }));
1383
1301
  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 }));
1384
1302
  }
1385
-
1386
- //#endregion
1387
- //#region src/webpack.ts
1388
- const bundle = async (nuxt$1) => {
1389
- const webpackConfigs = await Promise.all([client, ...nuxt$1.options.ssr ? [server] : []].map(async (preset) => {
1390
- const ctx = createWebpackConfigContext(nuxt$1);
1391
- ctx.userConfig = defu(nuxt$1.options.webpack[`$${preset.name}`], ctx.userConfig);
1303
+ const bundle = async (nuxt) => {
1304
+ const webpackConfigs = await Promise.all([client, ...nuxt.options.ssr ? [server] : []].map(async (preset) => {
1305
+ const ctx = createWebpackConfigContext(nuxt);
1306
+ ctx.userConfig = defu(nuxt.options.webpack[`$${preset.name}`], ctx.userConfig);
1392
1307
  await applyPresets(ctx, preset);
1393
1308
  return ctx.config;
1394
1309
  }));
1395
- /** Remove Nitro rollup plugin for handling dynamic imports from webpack chunks */
1396
- if (!nuxt$1.options.dev) useNitro().hooks.hook("rollup:before", (_nitro, config) => {
1310
+ if (!nuxt.options.dev) useNitro().hooks.hook("rollup:before", (_nitro, config) => {
1397
1311
  const plugins = config.plugins;
1398
1312
  const existingPlugin = plugins.findIndex((i) => i && "name" in i && i.name === "dynamic-require");
1399
1313
  if (existingPlugin >= 0) plugins.splice(existingPlugin, 1);
1400
1314
  });
1401
- await nuxt$1.callHook(`${builder}:config`, webpackConfigs);
1402
- const mfs = nuxt$1.options.dev ? createMFS() : null;
1403
- const ssrStylesPlugin = nuxt$1.options.ssr && !nuxt$1.options.dev && nuxt$1.options.features.inlineStyles ? new SSRStylesPlugin(nuxt$1) : null;
1315
+ await nuxt.callHook(`${builder}:config`, webpackConfigs);
1316
+ const mfs = nuxt.options.dev ? createMFS() : null;
1317
+ const ssrStylesPlugin = nuxt.options.ssr && !nuxt.options.dev && nuxt.options.features.inlineStyles ? new SSRStylesPlugin(nuxt) : null;
1404
1318
  for (const config of webpackConfigs) {
1405
- config.plugins.push(DynamicBasePlugin.webpack({ sourcemap: !!nuxt$1.options.sourcemap[config.name] }));
1406
- if (config.name === "client" && nuxt$1.options.experimental.emitRouteChunkError && nuxt$1.options.builder !== "@nuxt/rspack-builder") config.plugins.push(new ChunkErrorPlugin());
1319
+ config.plugins.push(DynamicBasePlugin.webpack({ sourcemap: !!nuxt.options.sourcemap[config.name] }));
1320
+ if (config.name === "client" && nuxt.options.experimental.emitRouteChunkError && nuxt.options.builder !== "@nuxt/rspack-builder") config.plugins.push(new ChunkErrorPlugin());
1407
1321
  if (ssrStylesPlugin) config.plugins.push(ssrStylesPlugin);
1408
1322
  }
1409
- await nuxt$1.callHook(`${builder}:configResolved`, webpackConfigs);
1323
+ await nuxt.callHook(`${builder}:configResolved`, webpackConfigs);
1410
1324
  const compilers = webpackConfigs.map((config) => {
1411
1325
  const compiler = webpack(config);
1412
- if (nuxt$1.options.dev && compiler) compiler.outputFileSystem = mfs;
1326
+ if (nuxt.options.dev && compiler) compiler.outputFileSystem = mfs;
1413
1327
  return compiler;
1414
1328
  });
1415
- nuxt$1.hook("close", async () => {
1416
- for (const compiler of compilers) await new Promise((resolve$1) => compiler.close(resolve$1));
1329
+ nuxt.hook("close", async () => {
1330
+ for (const compiler of compilers) await new Promise((resolve) => compiler.close(resolve));
1417
1331
  });
1418
- if (nuxt$1.options.dev) {
1332
+ if (nuxt.options.dev) {
1419
1333
  await Promise.all(compilers.map((c) => compile(c)));
1420
1334
  return;
1421
1335
  }
1422
1336
  for (const c of compilers) await compile(c);
1423
1337
  };
1424
1338
  async function createDevMiddleware(compiler) {
1425
- const nuxt$1 = useNuxt();
1339
+ const nuxt = useNuxt();
1426
1340
  logger.debug("Creating webpack middleware...");
1427
1341
  const devMiddleware = webpackDevMiddleware(compiler, {
1428
- publicPath: joinURL(nuxt$1.options.app.baseURL, nuxt$1.options.app.buildAssetsDir),
1342
+ publicPath: joinURL(nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir),
1429
1343
  outputFileSystem: compiler.outputFileSystem,
1430
1344
  stats: "none",
1431
- ...nuxt$1.options.webpack.devMiddleware
1345
+ ...nuxt.options.webpack.devMiddleware
1432
1346
  });
1433
- nuxt$1.hook("close", () => pify(devMiddleware.close.bind(devMiddleware))());
1434
- const { client: _client, ...hotMiddlewareOptions } = nuxt$1.options.webpack.hotMiddleware || {};
1347
+ nuxt.hook("close", () => pify(devMiddleware.close.bind(devMiddleware))());
1348
+ const { client: _client, ...hotMiddlewareOptions } = nuxt.options.webpack.hotMiddleware || {};
1435
1349
  const hotMiddleware = webpackHotMiddleware(compiler, {
1436
1350
  log: false,
1437
1351
  heartbeat: 1e4,
1438
- path: joinURL(nuxt$1.options.app.baseURL, "__webpack_hmr", compiler.options.name),
1352
+ path: joinURL(nuxt.options.app.baseURL, "__webpack_hmr", compiler.options.name),
1439
1353
  ...hotMiddlewareOptions
1440
1354
  });
1441
1355
  const devHandler = wdmToH3Handler(devMiddleware);
1442
- await nuxt$1.callHook("server:devHandler", defineEventHandler(async (event) => {
1356
+ await nuxt.callHook("server:devHandler", defineEventHandler(async (event) => {
1443
1357
  const body = await devHandler(event);
1444
1358
  if (body !== void 0) return body;
1445
1359
  const { req, res } = "runtime" in event ? event.runtime.node : event.node;
1446
- await new Promise((resolve$1, reject) => hotMiddleware(req, res, (err) => err ? reject(err) : resolve$1()));
1360
+ await new Promise((resolve, reject) => hotMiddleware(req, res, (err) => err ? reject(err) : resolve()));
1447
1361
  }), { cors: () => true });
1448
1362
  return devMiddleware;
1449
1363
  }
1450
1364
  function wdmToH3Handler(devMiddleware) {
1451
1365
  return defineEventHandler(async (event) => {
1452
1366
  const { req, res } = "runtime" in event ? event.runtime.node : event.node;
1453
- if (req.headers["sec-fetch-mode"] === "no-cors" && req.headers["sec-fetch-site"] === "cross-site") throw { status: 403 };
1367
+ if (req.headers["sec-fetch-mode"] === "no-cors" && req.headers["sec-fetch-site"] === "cross-site") {
1368
+ res.statusCode = 403;
1369
+ res.end("Forbidden");
1370
+ return;
1371
+ }
1454
1372
  event.context.webpack = {
1455
1373
  ...event.context.webpack,
1456
1374
  devMiddleware: devMiddleware.context
1457
1375
  };
1458
- return await new Promise((resolve$1, reject) => {
1376
+ return await new Promise((resolve, reject) => {
1459
1377
  res.stream = (stream) => {
1460
- resolve$1(stream);
1378
+ resolve(stream);
1461
1379
  };
1462
1380
  res.send = (data) => {
1463
- resolve$1(data);
1381
+ resolve(data);
1464
1382
  };
1465
1383
  res.finish = (data) => {
1466
- resolve$1(data);
1384
+ resolve(data);
1467
1385
  };
1468
1386
  devMiddleware(req, res, (err) => {
1469
1387
  if (err) reject(err);
1470
- else resolve$1(void 0);
1388
+ else resolve(void 0);
1471
1389
  });
1472
1390
  });
1473
1391
  });
1474
1392
  }
1475
1393
  async function compile(compiler) {
1476
- const nuxt$1 = useNuxt();
1477
- await nuxt$1.callHook(`${builder}:compile`, {
1394
+ const nuxt = useNuxt();
1395
+ await nuxt.callHook(`${builder}:compile`, {
1478
1396
  name: compiler.options.name,
1479
1397
  compiler
1480
1398
  });
1481
- compiler.hooks.done.tap("load-resources", async (stats$1) => {
1482
- await nuxt$1.callHook(`${builder}:compiled`, {
1399
+ compiler.hooks.done.tap("load-resources", async (stats) => {
1400
+ await nuxt.callHook(`${builder}:compiled`, {
1483
1401
  name: compiler.options.name,
1484
1402
  compiler,
1485
- stats: stats$1
1403
+ stats
1486
1404
  });
1487
1405
  });
1488
- if (nuxt$1.options.dev) {
1406
+ if (nuxt.options.dev) {
1489
1407
  const compilersWatching = [];
1490
- nuxt$1.hook("close", async () => {
1408
+ nuxt.hook("close", async () => {
1491
1409
  await Promise.all(compilersWatching.map((watching) => watching && pify(watching.close.bind(watching))()));
1492
1410
  });
1493
- if (compiler.options.name === "client") return new Promise((resolve$1, reject) => {
1411
+ if (compiler.options.name === "client") return new Promise((resolve, reject) => {
1494
1412
  compiler.hooks.done.tap("nuxt-dev", () => {
1495
- resolve$1(null);
1413
+ resolve(null);
1496
1414
  });
1497
1415
  compiler.hooks.failed.tap("nuxt-errorlog", (err) => {
1498
1416
  reject(err);
@@ -1501,15 +1419,15 @@ async function compile(compiler) {
1501
1419
  if (devMiddleware.context.watching) compilersWatching.push(devMiddleware.context.watching);
1502
1420
  });
1503
1421
  });
1504
- return new Promise((resolve$1, reject) => {
1505
- const watching = compiler.watch(nuxt$1.options.watchers.webpack, (err) => {
1422
+ return new Promise((resolve, reject) => {
1423
+ const watching = compiler.watch(nuxt.options.watchers.webpack, (err) => {
1506
1424
  if (err) return reject(err);
1507
- resolve$1(null);
1425
+ resolve(null);
1508
1426
  });
1509
1427
  compilersWatching.push(watching);
1510
1428
  });
1511
1429
  }
1512
- const stats = await new Promise((resolve$1, reject) => compiler.run((err, stats$1) => err ? reject(err) : resolve$1(stats$1)));
1430
+ const stats = await new Promise((resolve, reject) => compiler.run((err, stats) => err ? reject(err) : resolve(stats)));
1513
1431
  if (stats.hasErrors()) {
1514
1432
  const error = /* @__PURE__ */ new Error("Nuxt build error");
1515
1433
  error.stack = stats.toString("errors-only");
@@ -1519,6 +1437,4 @@ async function compile(compiler) {
1519
1437
  function defineEventHandler(handler) {
1520
1438
  return Object.assign(handler, { __is_handler__: true });
1521
1439
  }
1522
-
1523
- //#endregion
1524
- export { bundle };
1440
+ export { bundle };