@rsbuild/core 0.6.5 → 0.6.7

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 (72) hide show
  1. package/compiled/sirv/index.js +1 -1
  2. package/dist/cli/commands.js +2 -2
  3. package/dist/cli/init.js +1 -1
  4. package/dist/cli/prepare.js +1 -1
  5. package/dist/client/hmr.mjs +11 -3
  6. package/dist/config.d.ts +1 -1
  7. package/dist/config.js +3 -2
  8. package/dist/createContext.d.ts +1 -1
  9. package/dist/createContext.js +2 -2
  10. package/dist/createRsbuild.d.ts +1 -1
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.js +4 -1
  13. package/dist/initHooks.d.ts +1 -1
  14. package/dist/initPlugins.js +7 -2
  15. package/dist/plugins/html.d.ts +1 -1
  16. package/dist/plugins/moduleFederation.js +2 -12
  17. package/dist/plugins/nodeAddons.js +41 -6
  18. package/dist/plugins/server.js +1 -1
  19. package/dist/plugins/startUrl.js +2 -2
  20. package/dist/provider/build.d.ts +1 -1
  21. package/dist/provider/build.js +3 -13
  22. package/dist/provider/createCompiler.d.ts +2 -2
  23. package/dist/provider/createCompiler.js +5 -6
  24. package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
  25. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.js +1 -1
  26. package/dist/provider/initConfigs.d.ts +1 -1
  27. package/dist/provider/initConfigs.js +3 -3
  28. package/dist/provider/inspectConfig.d.ts +1 -1
  29. package/dist/provider/inspectConfig.js +1 -1
  30. package/dist/provider/plugins/css.d.ts +2 -2
  31. package/dist/provider/plugins/minimize.js +2 -11
  32. package/dist/provider/plugins/output.js +2 -12
  33. package/dist/provider/plugins/progress.js +2 -12
  34. package/dist/provider/plugins/rspackProfile.d.ts +1 -1
  35. package/dist/provider/plugins/rspackProfile.js +10 -7
  36. package/dist/provider/plugins/swc.d.ts +5 -4
  37. package/dist/provider/plugins/swc.js +2 -3
  38. package/dist/provider/provider.js +1 -1
  39. package/dist/provider/rspackConfig.d.ts +1 -1
  40. package/dist/provider/rspackConfig.js +4 -4
  41. package/dist/provider/shared.d.ts +1 -1
  42. package/dist/provider/shared.js +3 -3
  43. package/dist/rspack/HtmlBasicPlugin.d.ts +2 -2
  44. package/dist/rspack/InlineChunkHtmlPlugin.d.ts +1 -1
  45. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +1 -1
  46. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +1 -1
  47. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +1 -1
  48. package/dist/rspack/preload/helpers/extractChunks.d.ts +1 -1
  49. package/dist/rspack/transformLoader.d.ts +1 -1
  50. package/dist/rspack/transformRawLoader.d.ts +3 -0
  51. package/dist/rspack/{nodeAddonsLoader.js → transformRawLoader.js} +6 -33
  52. package/dist/server/compilerDevMiddleware.d.ts +1 -1
  53. package/dist/server/compilerDevMiddleware.js +1 -0
  54. package/dist/server/devMiddleware.js +8 -5
  55. package/dist/server/devServer.d.ts +1 -1
  56. package/dist/server/devServer.js +10 -3
  57. package/dist/server/getDevMiddlewares.d.ts +1 -1
  58. package/dist/server/getDevMiddlewares.js +1 -1
  59. package/dist/server/helper.d.ts +2 -1
  60. package/dist/server/helper.js +5 -2
  61. package/dist/server/middlewares.js +3 -3
  62. package/dist/server/prodServer.d.ts +1 -1
  63. package/dist/server/prodServer.js +3 -3
  64. package/dist/server/proxy.d.ts +1 -1
  65. package/dist/server/proxy.js +3 -1
  66. package/dist/server/socketServer.d.ts +1 -1
  67. package/dist/server/socketServer.js +1 -1
  68. package/dist/server/watchFiles.d.ts +10 -0
  69. package/dist/server/watchFiles.js +90 -0
  70. package/dist/types.d.ts +1 -1
  71. package/package.json +20 -6
  72. package/dist/rspack/nodeAddonsLoader.d.ts +0 -3
@@ -34,10 +34,10 @@ __export(middlewares_exports, {
34
34
  notFoundMiddleware: () => notFoundMiddleware
35
35
  });
36
36
  module.exports = __toCommonJS(middlewares_exports);
37
- var import_shared = require("@rsbuild/shared");
38
- var import_node_url = require("node:url");
39
- var import_node_path = __toESM(require("node:path"));
40
37
  var import_node_fs = __toESM(require("node:fs"));
38
+ var import_node_path = __toESM(require("node:path"));
39
+ var import_node_url = require("node:url");
40
+ var import_shared = require("@rsbuild/shared");
41
41
  const faviconFallbackMiddleware = (req, res, next) => {
42
42
  if (req.url === "/favicon.ico") {
43
43
  res.statusCode = 204;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { Server } from 'node:http';
3
+ import { type PreviewServerOptions, type RsbuildConfig, type ServerConfig, type StartServerResult } from '@rsbuild/shared';
3
4
  import connect from '@rsbuild/shared/connect';
4
- import { type ServerConfig, type RsbuildConfig, type StartServerResult, type PreviewServerOptions } from '@rsbuild/shared';
5
5
  import type { InternalContext } from '../types';
6
6
  type RsbuildProdServerOptions = {
7
7
  pwd: string;
@@ -37,13 +37,13 @@ __export(prodServer_exports, {
37
37
  startProdServer: () => startProdServer
38
38
  });
39
39
  module.exports = __toCommonJS(prodServer_exports);
40
- var import_connect = __toESM(require("@rsbuild/shared/connect"));
41
40
  var import_node_path = require("node:path");
42
- var import_sirv = __toESM(require("../../compiled/sirv"));
43
41
  var import_shared = require("@rsbuild/shared");
42
+ var import_connect = __toESM(require("@rsbuild/shared/connect"));
43
+ var import_sirv = __toESM(require("../../compiled/sirv"));
44
44
  var import_helper = require("./helper");
45
- var import_middlewares = require("./middlewares");
46
45
  var import_httpServer = require("./httpServer");
46
+ var import_middlewares = require("./middlewares");
47
47
  class RsbuildProdServer {
48
48
  constructor(options) {
49
49
  __publicField(this, "app");
@@ -1,4 +1,4 @@
1
- import { type ProxyDetail, type RequestHandler as Middleware, type ProxyOptions, type UpgradeEvent } from '@rsbuild/shared';
1
+ import { type RequestHandler as Middleware, type ProxyDetail, type ProxyOptions, type UpgradeEvent } from '@rsbuild/shared';
2
2
  export declare function formatProxyOptions(proxyOptions: ProxyOptions): ProxyDetail[];
3
3
  export declare const createProxyMiddleware: (proxyOptions: ProxyOptions) => {
4
4
  middlewares: Middleware[];
@@ -22,8 +22,8 @@ __export(proxy_exports, {
22
22
  formatProxyOptions: () => formatProxyOptions
23
23
  });
24
24
  module.exports = __toCommonJS(proxy_exports);
25
- var import_http_proxy_middleware = require("@rsbuild/shared/http-proxy-middleware");
26
25
  var import_shared = require("@rsbuild/shared");
26
+ var import_http_proxy_middleware = require("@rsbuild/shared/http-proxy-middleware");
27
27
  function formatProxyOptions(proxyOptions) {
28
28
  const ret = [];
29
29
  if (Array.isArray(proxyOptions)) {
@@ -65,6 +65,8 @@ const createProxyMiddleware = (proxyOptions) => {
65
65
  } else if (typeof bypassUrl === "string") {
66
66
  req.url = bypassUrl;
67
67
  next();
68
+ } else if (bypassUrl === true) {
69
+ next();
68
70
  } else {
69
71
  proxyMiddleware(req, res, next);
70
72
  }
@@ -2,8 +2,8 @@
2
2
  /// <reference types="node" />
3
3
  import type { IncomingMessage } from 'node:http';
4
4
  import type { Socket } from 'node:net';
5
+ import { type DevConfig, type Stats } from '@rsbuild/shared';
5
6
  import ws from '../../compiled/ws';
6
- import { type Stats, type DevConfig } from '@rsbuild/shared';
7
7
  export declare class SocketServer {
8
8
  private wsServer;
9
9
  private readonly sockets;
@@ -36,8 +36,8 @@ __export(socketServer_exports, {
36
36
  SocketServer: () => SocketServer
37
37
  });
38
38
  module.exports = __toCommonJS(socketServer_exports);
39
- var import_ws = __toESM(require("../../compiled/ws"));
40
39
  var import_shared = require("@rsbuild/shared");
40
+ var import_ws = __toESM(require("../../compiled/ws"));
41
41
  var import_shared2 = require("../provider/shared");
42
42
  class SocketServer {
43
43
  constructor(options) {
@@ -0,0 +1,10 @@
1
+ import type { CompileMiddlewareAPI, DevConfig, ServerConfig } from '@rsbuild/shared';
2
+ type WatchFilesOptions = {
3
+ dev: DevConfig;
4
+ server: ServerConfig;
5
+ compileMiddlewareAPI?: CompileMiddlewareAPI;
6
+ };
7
+ export declare function setupWatchFiles(options: WatchFilesOptions): Promise<{
8
+ close(): Promise<void>;
9
+ } | undefined>;
10
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var watchFiles_exports = {};
30
+ __export(watchFiles_exports, {
31
+ setupWatchFiles: () => setupWatchFiles
32
+ });
33
+ module.exports = __toCommonJS(watchFiles_exports);
34
+ async function setupWatchFiles(options) {
35
+ const { dev, server, compileMiddlewareAPI } = options;
36
+ const { hmr, liveReload } = dev;
37
+ if (!hmr && !liveReload || !compileMiddlewareAPI) {
38
+ return;
39
+ }
40
+ const devFilesWatcher = await watchDevFiles(dev, compileMiddlewareAPI);
41
+ const serverFilesWatcher = await watchServerFiles(
42
+ server,
43
+ compileMiddlewareAPI
44
+ );
45
+ return {
46
+ async close() {
47
+ await Promise.all([
48
+ devFilesWatcher?.close(),
49
+ serverFilesWatcher?.close()
50
+ ]);
51
+ }
52
+ };
53
+ }
54
+ async function watchDevFiles(devConfig, compileMiddlewareAPI) {
55
+ const { watchFiles } = devConfig;
56
+ if (!watchFiles) {
57
+ return;
58
+ }
59
+ const watchOptions = prepareWatchOptions(
60
+ watchFiles.paths,
61
+ watchFiles.options
62
+ );
63
+ return startWatchFiles(watchOptions, compileMiddlewareAPI);
64
+ }
65
+ function watchServerFiles(serverConfig, compileMiddlewareAPI) {
66
+ const { publicDir } = serverConfig;
67
+ if (!publicDir || !publicDir.watch || !publicDir.name) {
68
+ return;
69
+ }
70
+ const watchOptions = prepareWatchOptions(publicDir.name);
71
+ return startWatchFiles(watchOptions, compileMiddlewareAPI);
72
+ }
73
+ function prepareWatchOptions(paths, options = {}) {
74
+ return {
75
+ paths: typeof paths === "string" ? [paths] : paths,
76
+ options
77
+ };
78
+ }
79
+ async function startWatchFiles({ paths, options }, compileMiddlewareAPI) {
80
+ const chokidar = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/chokidar")));
81
+ const watcher = chokidar.watch(paths, options);
82
+ watcher.on("change", () => {
83
+ compileMiddlewareAPI.sockWrite("static-changed");
84
+ });
85
+ return watcher;
86
+ }
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ setupWatchFiles
90
+ });
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RsbuildConfig, RsbuildPlugin, RsbuildPlugins, RsbuildContext, NormalizedConfig, RsbuildPluginAPI, TransformHandler } from '@rsbuild/shared';
1
+ import type { NormalizedConfig, RsbuildConfig, RsbuildContext, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, TransformHandler } from '@rsbuild/shared';
2
2
  import type { Hooks } from './initHooks';
3
3
  declare module '@rspack/core' {
4
4
  interface Compiler {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "The Rspack-based build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -48,17 +48,30 @@
48
48
  "types.d.ts"
49
49
  ],
50
50
  "dependencies": {
51
- "@rspack/core": "0.6.2",
51
+ "@rspack/core": "0.6.3",
52
52
  "@swc/helpers": "0.5.3",
53
53
  "core-js": "~3.36.0",
54
54
  "html-webpack-plugin": "npm:html-rspack-plugin@5.6.2",
55
55
  "postcss": "^8.4.38",
56
- "@rsbuild/shared": "0.6.5"
56
+ "@rsbuild/shared": "0.6.7"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/node": "16.x",
59
+ "@types/node": "18.x",
60
+ "@types/on-finished": "2.3.4",
61
+ "@types/ws": "^8.5.10",
62
+ "commander": "^12.0.0",
63
+ "connect-history-api-fallback": "^2.0.0",
64
+ "dotenv": "16.4.5",
65
+ "dotenv-expand": "11.0.6",
66
+ "http-compression": "1.0.19",
67
+ "launch-editor-middleware": "^2.6.1",
68
+ "on-finished": "2.4.1",
69
+ "open": "^8.4.0",
70
+ "prebundle": "1.0.3",
71
+ "sirv": "^2.0.4",
60
72
  "typescript": "^5.4.2",
61
- "webpack": "^5.91.0"
73
+ "webpack": "^5.91.0",
74
+ "ws": "^8.16.0"
62
75
  },
63
76
  "engines": {
64
77
  "node": ">=16.0.0"
@@ -70,6 +83,7 @@
70
83
  },
71
84
  "scripts": {
72
85
  "build": "modern build",
73
- "dev": "modern build --watch"
86
+ "dev": "modern build --watch",
87
+ "prebundle": "prebundle"
74
88
  }
75
89
  }
@@ -1,3 +0,0 @@
1
- import type { Rspack } from '@rsbuild/shared';
2
- export default function (this: Rspack.LoaderContext, source: string): string;
3
- export declare const raw = true;