@nuxt/webpack-builder-nightly 5.0.0-29743829.e99b20d2 → 5.0.0-29745181.e6d3afa3

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 webpackDevMiddleware, { IncomingMessage, ServerResponse } from "webpack-dev-middleware";
2
6
  import { NuxtBuilder } from "@nuxt/schema";
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 { fileURLToPath, pathToFileURL } from "node:url";
@@ -7,7 +14,6 @@ import { joinURL, withTrailingSlash } from "ufo";
7
14
  import { DEFAULT_JS_FILE_EXTENSIONS, bundlerDiagnostics, configDiagnostics, directoryToURL, logger, resolveAlias, setBuildOutput, useNitro, useNuxt } from "@nuxt/kit";
8
15
  import { createUnplugin } from "unplugin";
9
16
  import { generateTransform, rolldownString } from "rolldown-string";
10
- import { MiniCssExtractPlugin, TsCheckerPlugin, VueLoaderPlugin, WebpackBarPlugin, builder, createRsbuild, getVueLoaderHash, vueLoader, webpack } from "#builder";
11
17
  import { existsSync, readFileSync } from "node:fs";
12
18
  import process from "node:process";
13
19
  import { genArrayFromRaw, genObjectFromRawEntries, genString } from "knitwork";
@@ -17,7 +23,6 @@ import querystring from "node:querystring";
17
23
  import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
18
24
  import { defineEnv } from "unenv";
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",
@@ -1004,7 +1041,7 @@ function extractCSS(ctx) {
1004
1041
  const config = ctx.userConfig.extractCSS;
1005
1042
  if (!config) return;
1006
1043
  const filename = fileName(ctx, "css");
1007
- ctx.config.plugins.push(new MiniCssExtractPlugin({
1044
+ ctx.config.plugins.push(new MiniCssExtractPlugin$1({
1008
1045
  filename,
1009
1046
  chunkFilename: filename,
1010
1047
  ...config === true ? {} : config
@@ -1056,7 +1093,7 @@ function createCssLoadersRule(ctx, cssLoaderOptions) {
1056
1093
  if (cssLoader.options.modules) cssLoader.options.modules.exportOnlyLocals ??= true;
1057
1094
  return [cssLoader];
1058
1095
  }
1059
- return [{ loader: MiniCssExtractPlugin.loader }, cssLoader];
1096
+ return [{ loader: MiniCssExtractPlugin$1.loader }, cssLoader];
1060
1097
  }
1061
1098
  return [cssLoader];
1062
1099
  }
@@ -1182,7 +1219,7 @@ var VueSSRServerPlugin = class {
1182
1219
  compiler.hooks.make.tap("VueSSRServerPlugin", (compilation) => {
1183
1220
  compilation.hooks.processAssets.tapAsync({
1184
1221
  name: "VueSSRServerPlugin",
1185
- stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
1222
+ stage: webpack$1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
1186
1223
  }, (assets, cb) => {
1187
1224
  const stats = compilation.getStats().toJson({
1188
1225
  assets: true,
@@ -1227,7 +1264,7 @@ var VueSSRServerPlugin = class {
1227
1264
  function vue(ctx) {
1228
1265
  ctx.nuxt.hooks.hookOnce(`${builder}:config`, () => {
1229
1266
  ctx.nuxt.hook(`${builder}:configResolved`, (configs) => {
1230
- for (const config of configs) config.plugins.unshift(new (VueLoaderPlugin.default || VueLoaderPlugin)());
1267
+ for (const config of configs) config.plugins.unshift(new (VueLoaderPlugin$1.default || VueLoaderPlugin$1)());
1231
1268
  });
1232
1269
  });
1233
1270
  ctx.config.module.rules.push({
@@ -1241,17 +1278,16 @@ function vue(ctx) {
1241
1278
  if (ctx.isClient) ctx.config.plugins.push(new VueSSRClientPlugin({ nuxt: ctx.nuxt }));
1242
1279
  else {
1243
1280
  ctx.config.plugins.push(new VueSSRServerPlugin({ filename: `${ctx.name}.manifest.json` }));
1244
- const loaderPath = resolveModulePath("#vue-module-identifier", { from: import.meta.url });
1245
1281
  ctx.config.module.rules.push({
1246
1282
  test: /\.vue$/i,
1247
1283
  enforce: "post",
1248
1284
  use: [{
1249
- loader: loaderPath,
1285
+ loader: vueModuleIdentifierLoader,
1250
1286
  options: { srcDir: ctx.nuxt.options.srcDir }
1251
1287
  }]
1252
1288
  });
1253
1289
  }
1254
- ctx.config.plugins.push(new webpack.DefinePlugin({
1290
+ ctx.config.plugins.push(new webpack$1.DefinePlugin({
1255
1291
  "__VUE_OPTIONS_API__": "true",
1256
1292
  "__VUE_PROD_DEVTOOLS__": "false",
1257
1293
  "__VUE_PROD_HYDRATION_MISMATCH_DETAILS__": ctx.nuxt.options.debug && ctx.nuxt.options.debug.hydration
@@ -1305,7 +1341,7 @@ function clientPerformance(ctx) {
1305
1341
  }
1306
1342
  function clientNodeCompat(ctx) {
1307
1343
  if (!ctx.nuxt.options.experimental.clientNodeCompat) return;
1308
- ctx.config.plugins.push(new webpack.DefinePlugin({ global: "globalThis" }));
1344
+ ctx.config.plugins.push(new webpack$1.DefinePlugin({ global: "globalThis" }));
1309
1345
  ctx.config.resolve ||= {};
1310
1346
  ctx.config.resolve.fallback = {
1311
1347
  ...defineEnv({
@@ -1314,14 +1350,14 @@ function clientNodeCompat(ctx) {
1314
1350
  }).env.alias,
1315
1351
  ...ctx.config.resolve.fallback
1316
1352
  };
1317
- ctx.config.plugins.unshift(new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
1353
+ ctx.config.plugins.unshift(new webpack$1.NormalModuleReplacementPlugin(/node:/, (resource) => {
1318
1354
  resource.request = resource.request.replace(/^node:/, "");
1319
1355
  }));
1320
1356
  }
1321
1357
  function clientHMR(ctx) {
1322
1358
  if (!ctx.isDev) return;
1323
1359
  ctx.config.plugins ||= [];
1324
- ctx.config.plugins.push(new webpack.HotModuleReplacementPlugin());
1360
+ ctx.config.plugins.push(new webpack$1.HotModuleReplacementPlugin());
1325
1361
  if (builder === "rspack") return;
1326
1362
  const clientOptions = ctx.userConfig.hotMiddleware?.client || {};
1327
1363
  const hotMiddlewareClientOptions = {
@@ -1374,7 +1410,7 @@ function clientPlugins(ctx) {
1374
1410
  }));
1375
1411
  }
1376
1412
  if (!ctx.nuxt.options.ssr) {
1377
- 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 }));
1413
+ 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 }));
1378
1414
  }
1379
1415
  }
1380
1416
  //#endregion
@@ -1495,11 +1531,11 @@ function serverStandalone(ctx) {
1495
1531
  }
1496
1532
  function serverPlugins(ctx) {
1497
1533
  ctx.config.plugins ||= [];
1498
- if (ctx.userConfig.serverURLPolyfill) ctx.config.plugins.push(new webpack.ProvidePlugin({
1534
+ if (ctx.userConfig.serverURLPolyfill) ctx.config.plugins.push(new webpack$1.ProvidePlugin({
1499
1535
  URL: [ctx.userConfig.serverURLPolyfill, "URL"],
1500
1536
  URLSearchParams: [ctx.userConfig.serverURLPolyfill, "URLSearchParams"]
1501
1537
  }));
1502
- 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 }));
1538
+ 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 }));
1503
1539
  }
1504
1540
  //#endregion
1505
1541
  //#region src/webpack.ts
@@ -1542,7 +1578,7 @@ const bundle = async (nuxt) => {
1542
1578
  return;
1543
1579
  }
1544
1580
  const mfs = nuxt.options.dev ? createMFS() : null;
1545
- const compilers = webpackConfigs.map((config) => webpack(config));
1581
+ const compilers = webpackConfigs.map((config) => webpack$1(config));
1546
1582
  if (nuxt.options.dev) for (const compiler of compilers) compiler.outputFileSystem = mfs;
1547
1583
  nuxt.hook("close", async () => {
1548
1584
  for (const compiler of compilers) await new Promise((resolve) => compiler.close(resolve));
@@ -1624,28 +1660,38 @@ async function startRsbuildDevServer(rsbuild, nuxt) {
1624
1660
  devServer.connectWebSocket({ server: listener });
1625
1661
  await devServer.afterListen();
1626
1662
  } else bundlerDiagnostics.NUXT_B7017();
1627
- await nuxt.callHook("server:devHandler", rsbuildToH3Handler(devServer.middlewares), { cors: () => true });
1663
+ const buildAssetsPrefix = joinURL(nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir);
1664
+ const nitroBuildsPrefix = joinURL(buildAssetsPrefix, "builds");
1665
+ await nuxt.callHook("server:devHandler", rsbuildToH3Handler(devServer.middlewares, buildAssetsPrefix, nitroBuildsPrefix), { cors: () => true });
1628
1666
  await Promise.all(firstCompiles);
1629
1667
  }
1630
- function rsbuildToH3Handler(middlewares) {
1631
- return defineEventHandler(async (event) => {
1668
+ const kHandled = /* @__PURE__ */ Symbol.for("h3.handled");
1669
+ function rsbuildToH3Handler(middlewares, buildAssetsPrefix, nitroBuildsPrefix) {
1670
+ return defineEventHandler((event) => {
1632
1671
  const { req, res } = "runtime" in event ? event.runtime.node : event.node;
1633
1672
  if (!isSameOriginRequest(req)) {
1634
1673
  res.statusCode = 403;
1635
1674
  res.end("Forbidden");
1636
- return;
1675
+ return kHandled;
1637
1676
  }
1638
- await new Promise((resolve) => {
1677
+ return new Promise((resolve) => {
1639
1678
  let settled = false;
1640
- const done = () => {
1679
+ const done = (result) => {
1641
1680
  if (!settled) {
1642
1681
  settled = true;
1643
- resolve();
1682
+ resolve(result);
1644
1683
  }
1645
1684
  };
1646
- res.on("finish", done);
1647
- res.on("close", done);
1648
- middlewares(req, res, () => done());
1685
+ res.on("finish", () => done(kHandled));
1686
+ res.on("close", () => done(kHandled));
1687
+ middlewares(req, res, () => {
1688
+ const url = req.url;
1689
+ if (url && url.startsWith(buildAssetsPrefix) && !url.startsWith(nitroBuildsPrefix)) {
1690
+ res.statusCode = 404;
1691
+ res.end();
1692
+ done(kHandled);
1693
+ } else done(void 0);
1694
+ });
1649
1695
  });
1650
1696
  });
1651
1697
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/webpack-builder-nightly",
3
- "version": "5.0.0-29743829.e99b20d2",
3
+ "version": "5.0.0-29745181.e6d3afa3",
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@5.0.0-29743829.e99b20d2",
27
+ "@nuxt/kit": "npm:@nuxt/kit-nightly@5.0.0-29745181.e6d3afa3",
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@5.0.0-29743829.e99b20d2",
71
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@5.0.0-29745181.e6d3afa3",
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@5.0.0-29743829.e99b20d2",
83
+ "nuxt": "npm:nuxt-nightly@5.0.0-29745181.e6d3afa3",
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'