@nuxt/webpack-builder-nightly 4.5.1-29744085.ef319e7f → 4.5.1-29746779.3590eee2

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.
package/dist/index.d.mts CHANGED
@@ -1,3 +1,7 @@
1
+ import VueLoaderPlugin from "vue-loader/dist/pluginWebpack5.js";
2
+ import webpack from "webpack";
3
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
4
+ import TsCheckerPlugin from "fork-ts-checker-webpack-plugin";
1
5
  import { NuxtBuilder } from "@nuxt/schema";
2
6
 
3
7
  //#region src/webpack.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,11 @@
1
1
  import { createRequire } from "node:module";
2
+ import { resolveModulePath } from "exsolve";
3
+ import hashSum from "hash-sum";
4
+ import VueLoaderPlugin from "vue-loader/dist/pluginWebpack5.js";
5
+ import webpack from "webpack";
6
+ import MiniCssExtractPlugin from "mini-css-extract-plugin";
7
+ import WebpackBarPlugin from "webpackbar";
8
+ import TsCheckerPlugin from "fork-ts-checker-webpack-plugin";
2
9
  import pify from "pify";
3
10
  import { defu } from "defu";
4
11
  import { basename, dirname, isAbsolute, join, normalize, relative, resolve } from "pathe";
@@ -6,7 +13,6 @@ import { joinURL, withTrailingSlash } from "ufo";
6
13
  import { DEFAULT_JS_FILE_EXTENSIONS, bundlerDiagnostics, configDiagnostics, directoryToURL, logger, resolveAlias, setBuildOutput, useNitro, useNuxt } from "@nuxt/kit";
7
14
  import { createUnplugin } from "unplugin";
8
15
  import { generateTransform, rolldownString } from "rolldown-string";
9
- import { MiniCssExtractPlugin, TsCheckerPlugin, VueLoaderPlugin, WebpackBarPlugin, builder, createRsbuild, getVueLoaderHash, vueLoader, webpack } from "#builder";
10
16
  import { existsSync, readFileSync } from "node:fs";
11
17
  import process from "node:process";
12
18
  import { genArrayFromRaw, genObjectFromRawEntries, genString } from "knitwork";
@@ -17,7 +23,6 @@ import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
17
23
  import { defineEnv } from "unenv";
18
24
  import { fileURLToPath } from "node:url";
19
25
  import { parseNodeModulePath } from "mlly";
20
- import { resolveModulePath } from "exsolve";
21
26
  import TimeFixPlugin from "time-fix-plugin";
22
27
  import FriendlyErrorsWebpackPlugin from "@nuxt/friendly-errors-webpack-plugin";
23
28
  import escapeRegExp from "escape-string-regexp";
@@ -29,6 +34,35 @@ import { mkdir, writeFile } from "node:fs/promises";
29
34
  import { normalizeWebpackManifest, precomputeDependencies } from "vue-bundle-renderer";
30
35
  import { hash } from "ohash";
31
36
  import { serialize } from "seroval";
37
+ //#region src/builder-registry.ts
38
+ let _impl;
39
+ /**
40
+ * Injects the bundler implementation used by all modules in this package.
41
+ *
42
+ * Must be called before `builder.ts` is evaluated. Each builder package does
43
+ * this by importing its `impl.ts` (which calls `setBuilderImpl` as a side
44
+ * effect) as the first import of its entry module.
45
+ */
46
+ function setBuilderImpl(impl) {
47
+ _impl = impl;
48
+ }
49
+ function getBuilderImpl() {
50
+ if (!_impl) throw new Error("Builder implementation is not set. Import the builder package entry (or its `impl.ts`) before any module that uses the builder bindings.");
51
+ return _impl;
52
+ }
53
+ setBuilderImpl({
54
+ builder: "webpack",
55
+ webpack,
56
+ createRsbuild: void 0,
57
+ WebpackBarPlugin,
58
+ MiniCssExtractPlugin,
59
+ TsCheckerPlugin,
60
+ VueLoaderPlugin,
61
+ getVueLoaderHash: hashSum,
62
+ vueLoader: "vue-loader",
63
+ vueModuleIdentifierLoader: resolveModulePath("#vue-module-identifier", { from: import.meta.url })
64
+ });
65
+ //#endregion
32
66
  //#region src/plugins/dynamic-base.ts
33
67
  const ENTRY_RE = /import ["']#build\/css["'];/;
34
68
  const DynamicBasePlugin = createUnplugin(() => {
@@ -49,23 +83,26 @@ const DynamicBasePlugin = createUnplugin(() => {
49
83
  };
50
84
  });
51
85
  //#endregion
86
+ //#region src/builder.ts
87
+ const { builder, webpack: webpack$1, createRsbuild, WebpackBarPlugin: WebpackBarPlugin$1, MiniCssExtractPlugin: MiniCssExtractPlugin$1, TsCheckerPlugin: TsCheckerPlugin$1, VueLoaderPlugin: VueLoaderPlugin$1, getVueLoaderHash, vueLoader, vueModuleIdentifierLoader } = getBuilderImpl();
88
+ //#endregion
52
89
  //#region src/plugins/chunk.ts
53
90
  const pluginName = "ChunkErrorPlugin";
54
91
  var ChunkErrorPlugin = class {
55
92
  apply(compiler) {
56
93
  compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
57
- compilation.hooks.runtimeRequirementInTree.for(webpack.RuntimeGlobals.ensureChunk).tap(pluginName, (chunk) => {
94
+ compilation.hooks.runtimeRequirementInTree.for(webpack$1.RuntimeGlobals.ensureChunk).tap(pluginName, (chunk) => {
58
95
  compilation.addRuntimeModule(chunk, new ChunkErrorRuntimeModule());
59
96
  });
60
97
  });
61
98
  }
62
99
  };
63
- var ChunkErrorRuntimeModule = class extends webpack.RuntimeModule {
100
+ var ChunkErrorRuntimeModule = class extends webpack$1.RuntimeModule {
64
101
  constructor() {
65
- super("chunk preload error handler", webpack.RuntimeModule.STAGE_ATTACH);
102
+ super("chunk preload error handler", webpack$1.RuntimeModule.STAGE_ATTACH);
66
103
  }
67
104
  generate() {
68
- const { ensureChunk } = webpack.RuntimeGlobals;
105
+ const { ensureChunk } = webpack$1.RuntimeGlobals;
69
106
  return `
70
107
  if (typeof ${ensureChunk} !== "undefined") {
71
108
  var _ensureChunk = ${ensureChunk};
@@ -716,13 +753,13 @@ function basePlugins(ctx) {
716
753
  }
717
754
  ctx.config.plugins.push(...ctx.userConfig.plugins || []);
718
755
  if (ctx.nuxt.options.builder !== "@nuxt/rspack-builder") ctx.config.plugins.push(new WarningIgnorePlugin(getWarningIgnoreFilter(ctx)));
719
- ctx.config.plugins.push(new webpack.DefinePlugin(getEnv(ctx)));
756
+ ctx.config.plugins.push(new webpack$1.DefinePlugin(getEnv(ctx)));
720
757
  if (ctx.isServer || ctx.isDev && ctx.userConfig.friendlyErrors) ctx.config.plugins.push(new FriendlyErrorsWebpackPlugin({
721
758
  clearConsole: false,
722
759
  reporter: "consola",
723
760
  logLevel: "ERROR"
724
761
  }));
725
- if (ctx.nuxt.options.webpack.profile) ctx.config.plugins.push(new WebpackBarPlugin({
762
+ if (ctx.nuxt.options.webpack.profile) ctx.config.plugins.push(new WebpackBarPlugin$1({
726
763
  name: ctx.name,
727
764
  color: {
728
765
  client: "green",
@@ -1002,7 +1039,7 @@ function extractCSS(ctx) {
1002
1039
  const config = ctx.userConfig.extractCSS;
1003
1040
  if (!config) return;
1004
1041
  const filename = fileName(ctx, "css");
1005
- ctx.config.plugins.push(new MiniCssExtractPlugin({
1042
+ ctx.config.plugins.push(new MiniCssExtractPlugin$1({
1006
1043
  filename,
1007
1044
  chunkFilename: filename,
1008
1045
  ...config === true ? {} : config
@@ -1054,7 +1091,7 @@ function createCssLoadersRule(ctx, cssLoaderOptions) {
1054
1091
  if (cssLoader.options.modules) cssLoader.options.modules.exportOnlyLocals ??= true;
1055
1092
  return [cssLoader];
1056
1093
  }
1057
- return [{ loader: MiniCssExtractPlugin.loader }, cssLoader];
1094
+ return [{ loader: MiniCssExtractPlugin$1.loader }, cssLoader];
1058
1095
  }
1059
1096
  return [cssLoader];
1060
1097
  }
@@ -1180,7 +1217,7 @@ var VueSSRServerPlugin = class {
1180
1217
  compiler.hooks.make.tap("VueSSRServerPlugin", (compilation) => {
1181
1218
  compilation.hooks.processAssets.tapAsync({
1182
1219
  name: "VueSSRServerPlugin",
1183
- stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
1220
+ stage: webpack$1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
1184
1221
  }, (assets, cb) => {
1185
1222
  const stats = compilation.getStats().toJson({
1186
1223
  assets: true,
@@ -1225,7 +1262,7 @@ var VueSSRServerPlugin = class {
1225
1262
  function vue(ctx) {
1226
1263
  ctx.nuxt.hooks.hookOnce(`${builder}:config`, () => {
1227
1264
  ctx.nuxt.hook(`${builder}:configResolved`, (configs) => {
1228
- for (const config of configs) config.plugins.unshift(new (VueLoaderPlugin.default || VueLoaderPlugin)());
1265
+ for (const config of configs) config.plugins.unshift(new (VueLoaderPlugin$1.default || VueLoaderPlugin$1)());
1229
1266
  });
1230
1267
  });
1231
1268
  ctx.config.module.rules.push({
@@ -1239,18 +1276,17 @@ function vue(ctx) {
1239
1276
  if (ctx.isClient) ctx.config.plugins.push(new VueSSRClientPlugin({ nuxt: ctx.nuxt }));
1240
1277
  else {
1241
1278
  ctx.config.plugins.push(new VueSSRServerPlugin({ filename: `${ctx.name}.manifest.json` }));
1242
- const loaderPath = resolveModulePath("#vue-module-identifier", { from: import.meta.url });
1243
1279
  ctx.config.module.rules.push({
1244
1280
  test: /\.vue$/i,
1245
1281
  enforce: "post",
1246
1282
  use: [{
1247
- loader: loaderPath,
1283
+ loader: vueModuleIdentifierLoader,
1248
1284
  options: { srcDir: ctx.nuxt.options.srcDir }
1249
1285
  }]
1250
1286
  });
1251
1287
  }
1252
- ctx.config.plugins.push(new webpack.DefinePlugin({
1253
- "__VUE_OPTIONS_API__": "true",
1288
+ ctx.config.plugins.push(new webpack$1.DefinePlugin({
1289
+ "__VUE_OPTIONS_API__": String(ctx.nuxt.options.vue.optionsApi),
1254
1290
  "__VUE_PROD_DEVTOOLS__": "false",
1255
1291
  "__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": ctx.nuxt.options.debug && ctx.nuxt.options.debug.hydration
1256
1292
  }));
@@ -1303,7 +1339,7 @@ function clientPerformance(ctx) {
1303
1339
  }
1304
1340
  function clientNodeCompat(ctx) {
1305
1341
  if (!ctx.nuxt.options.experimental.clientNodeCompat) return;
1306
- ctx.config.plugins.push(new webpack.DefinePlugin({ global: "globalThis" }));
1342
+ ctx.config.plugins.push(new webpack$1.DefinePlugin({ global: "globalThis" }));
1307
1343
  ctx.config.resolve ||= {};
1308
1344
  ctx.config.resolve.fallback = {
1309
1345
  ...defineEnv({
@@ -1312,14 +1348,14 @@ function clientNodeCompat(ctx) {
1312
1348
  }).env.alias,
1313
1349
  ...ctx.config.resolve.fallback
1314
1350
  };
1315
- ctx.config.plugins.unshift(new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
1351
+ ctx.config.plugins.unshift(new webpack$1.NormalModuleReplacementPlugin(/node:/, (resource) => {
1316
1352
  resource.request = resource.request.replace(/^node:/, "");
1317
1353
  }));
1318
1354
  }
1319
1355
  function clientHMR(ctx) {
1320
1356
  if (!ctx.isDev) return;
1321
1357
  ctx.config.plugins ||= [];
1322
- ctx.config.plugins.push(new webpack.HotModuleReplacementPlugin());
1358
+ ctx.config.plugins.push(new webpack$1.HotModuleReplacementPlugin());
1323
1359
  if (builder === "rspack") return;
1324
1360
  const clientOptions = ctx.userConfig.hotMiddleware?.client || {};
1325
1361
  const hotMiddlewareClientOptions = {
@@ -1372,7 +1408,7 @@ function clientPlugins(ctx) {
1372
1408
  }));
1373
1409
  }
1374
1410
  if (!ctx.nuxt.options.ssr) {
1375
- 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 }));
1411
+ 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$1({ logger }));
1376
1412
  }
1377
1413
  }
1378
1414
  //#endregion
@@ -1493,11 +1529,11 @@ function serverStandalone(ctx) {
1493
1529
  }
1494
1530
  function serverPlugins(ctx) {
1495
1531
  ctx.config.plugins ||= [];
1496
- if (ctx.userConfig.serverURLPolyfill) ctx.config.plugins.push(new webpack.ProvidePlugin({
1532
+ if (ctx.userConfig.serverURLPolyfill) ctx.config.plugins.push(new webpack$1.ProvidePlugin({
1497
1533
  URL: [ctx.userConfig.serverURLPolyfill, "URL"],
1498
1534
  URLSearchParams: [ctx.userConfig.serverURLPolyfill, "URLSearchParams"]
1499
1535
  }));
1500
- 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 }));
1536
+ 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$1({ logger }));
1501
1537
  }
1502
1538
  //#endregion
1503
1539
  //#region src/webpack.ts
@@ -1540,7 +1576,7 @@ const bundle = async (nuxt) => {
1540
1576
  return;
1541
1577
  }
1542
1578
  const mfs = nuxt.options.dev ? createMFS() : null;
1543
- const compilers = webpackConfigs.map((config) => webpack(config));
1579
+ const compilers = webpackConfigs.map((config) => webpack$1(config));
1544
1580
  if (nuxt.options.dev) for (const compiler of compilers) compiler.outputFileSystem = mfs;
1545
1581
  nuxt.hook("close", async () => {
1546
1582
  for (const compiler of compilers) await new Promise((resolve) => compiler.close(resolve));
@@ -1622,28 +1658,38 @@ async function startRsbuildDevServer(rsbuild, nuxt) {
1622
1658
  devServer.connectWebSocket({ server: listener });
1623
1659
  await devServer.afterListen();
1624
1660
  } else bundlerDiagnostics.NUXT_B7017();
1625
- await nuxt.callHook("server:devHandler", rsbuildToH3Handler(devServer.middlewares), { cors: () => true });
1661
+ const buildAssetsPrefix = joinURL(nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir);
1662
+ const nitroBuildsPrefix = joinURL(buildAssetsPrefix, "builds");
1663
+ await nuxt.callHook("server:devHandler", rsbuildToH3Handler(devServer.middlewares, buildAssetsPrefix, nitroBuildsPrefix), { cors: () => true });
1626
1664
  await Promise.all(firstCompiles);
1627
1665
  }
1628
- function rsbuildToH3Handler(middlewares) {
1629
- return defineEventHandler(async (event) => {
1666
+ const kHandled = /* @__PURE__ */ Symbol.for("h3.handled");
1667
+ function rsbuildToH3Handler(middlewares, buildAssetsPrefix, nitroBuildsPrefix) {
1668
+ return defineEventHandler((event) => {
1630
1669
  const { req, res } = "runtime" in event ? event.runtime.node : event.node;
1631
1670
  if (!isSameOriginRequest(req)) {
1632
1671
  res.statusCode = 403;
1633
1672
  res.end("Forbidden");
1634
- return;
1673
+ return kHandled;
1635
1674
  }
1636
- await new Promise((resolve) => {
1675
+ return new Promise((resolve) => {
1637
1676
  let settled = false;
1638
- const done = () => {
1677
+ const done = (result) => {
1639
1678
  if (!settled) {
1640
1679
  settled = true;
1641
- resolve();
1680
+ resolve(result);
1642
1681
  }
1643
1682
  };
1644
- res.on("finish", done);
1645
- res.on("close", done);
1646
- middlewares(req, res, () => done());
1683
+ res.on("finish", () => done(kHandled));
1684
+ res.on("close", () => done(kHandled));
1685
+ middlewares(req, res, () => {
1686
+ const url = req.url;
1687
+ if (url && url.startsWith(buildAssetsPrefix) && !url.startsWith(nitroBuildsPrefix)) {
1688
+ res.statusCode = 404;
1689
+ res.end();
1690
+ done(kHandled);
1691
+ } else done(void 0);
1692
+ });
1647
1693
  });
1648
1694
  });
1649
1695
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder-nightly",
3
- "version": "4.5.1-29744085.ef319e7f",
3
+ "version": "4.5.1-29746779.3590eee2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -12,7 +12,6 @@
12
12
  "type": "module",
13
13
  "types": "./dist/index.d.mts",
14
14
  "imports": {
15
- "#builder": "./builder.mjs",
16
15
  "#vue-module-identifier": "./dist/loaders/vue-module-identifier.mjs"
17
16
  },
18
17
  "exports": {
@@ -21,12 +20,11 @@
21
20
  "./package.json": "./package.json"
22
21
  },
23
22
  "files": [
24
- "dist",
25
- "builder.mjs"
23
+ "dist"
26
24
  ],
27
25
  "dependencies": {
28
26
  "@nuxt/friendly-errors-webpack-plugin": "^2.6.0",
29
- "@nuxt/kit": "npm:@nuxt/kit-nightly@4.5.1-29744085.ef319e7f",
27
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@4.5.1-29746779.3590eee2",
30
28
  "@vue/compiler-sfc": "3.5.40",
31
29
  "autoprefixer": "^10.5.4",
32
30
  "css-loader": "^7.1.4",
@@ -70,8 +68,9 @@
70
68
  "webpackbar": "^7.0.0"
71
69
  },
72
70
  "devDependencies": {
73
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.5.1-29744085.ef319e7f",
71
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.5.1-29746779.3590eee2",
74
72
  "@rspack/core": "2.1.4",
73
+ "@types/hash-sum": "1.0.2",
75
74
  "@types/webpack-bundle-analyzer": "4.7.0",
76
75
  "@types/webpack-hot-middleware": "2.25.12",
77
76
  "h3": "1.15.11",
@@ -81,7 +80,7 @@
81
80
  "vue": "^3.5.40"
82
81
  },
83
82
  "peerDependencies": {
84
- "nuxt": "npm:nuxt-nightly@4.5.1-29744085.ef319e7f",
83
+ "nuxt": "npm:nuxt-nightly@4.5.1-29746779.3590eee2",
85
84
  "vue": "^3.3.4"
86
85
  },
87
86
  "engines": {
package/builder.mjs DELETED
@@ -1,12 +0,0 @@
1
- import hashSum from 'hash-sum'
2
- import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5.js'
3
-
4
- export const builder = 'webpack'
5
- export const createRsbuild = undefined
6
- export { default as webpack } from 'webpack'
7
- export { default as MiniCssExtractPlugin } from 'mini-css-extract-plugin'
8
- export { default as WebpackBarPlugin } from 'webpackbar'
9
- export { default as TsCheckerPlugin } from 'fork-ts-checker-webpack-plugin'
10
- export { VueLoaderPlugin }
11
- export const getVueLoaderHash = hashSum
12
- export const vueLoader = 'vue-loader'