@rsbuild/core 0.0.21 → 0.0.23

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 (56) hide show
  1. package/bin/rsbuild.js +1 -1
  2. package/compiled/commander/index.js +1 -0
  3. package/compiled/commander/license +22 -0
  4. package/compiled/commander/package.json +1 -0
  5. package/compiled/commander/typings/index.d.ts +889 -0
  6. package/compiled/connect-history-api-fallback/index.d.ts +1 -0
  7. package/compiled/connect-history-api-fallback/index.js +1 -0
  8. package/compiled/connect-history-api-fallback/license +21 -0
  9. package/compiled/connect-history-api-fallback/package.json +1 -0
  10. package/compiled/http-compression/index.d.ts +1 -0
  11. package/compiled/http-compression/index.js +1 -0
  12. package/compiled/http-compression/package.json +1 -0
  13. package/compiled/open/index.d.ts +153 -0
  14. package/compiled/open/index.js +1 -0
  15. package/compiled/open/license +9 -0
  16. package/compiled/open/package.json +1 -0
  17. package/compiled/open/xdg-open +1066 -0
  18. package/dist/cli/commands.js +1 -1
  19. package/dist/cli/config.d.ts +2 -8
  20. package/dist/cli/config.js +0 -18
  21. package/dist/cli/run.d.ts +1 -1
  22. package/dist/cli/run.js +0 -2
  23. package/dist/client/hmr.js +418 -0
  24. package/dist/createRsbuild.js +0 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/plugins/fileSize.js +2 -2
  27. package/dist/plugins/html.js +1 -1
  28. package/dist/plugins/index.js +0 -1
  29. package/dist/plugins/startUrl.js +1 -1
  30. package/dist/rspack-provider/core/createCompiler.d.ts +1 -1
  31. package/dist/rspack-provider/core/createCompiler.js +3 -3
  32. package/dist/rspack-provider/core/createContext.js +3 -2
  33. package/dist/rspack-provider/core/rspackConfig.js +1 -1
  34. package/dist/rspack-provider/index.d.ts +1 -1
  35. package/dist/rspack-provider/plugins/css.js +3 -10
  36. package/dist/rspack-provider/plugins/{rspack-profile.js → rspackProfile.js} +3 -3
  37. package/dist/rspack-provider/plugins/swc.js +1 -1
  38. package/dist/rspack-provider/provider.js +6 -5
  39. package/dist/rspack-provider/shared/plugin.js +1 -4
  40. package/dist/rspack-provider/types/plugin.d.ts +1 -1
  41. package/dist/server/dev-middleware/index.d.ts +2 -0
  42. package/dist/server/dev-middleware/index.js +10 -9
  43. package/dist/server/devServer.d.ts +2 -2
  44. package/dist/server/devServer.js +16 -16
  45. package/dist/server/prodServer.d.ts +1 -1
  46. package/dist/server/prodServer.js +2 -2
  47. package/package.json +7 -15
  48. package/dist/plugins/rem.d.ts +0 -2
  49. package/dist/plugins/rem.js +0 -103
  50. package/dist/rspack-provider/plugins/fallback.d.ts +0 -2
  51. package/dist/rspack-provider/plugins/fallback.js +0 -52
  52. package/dist/server/dev-middleware/hmr-client/createSocketUrl.js +0 -68
  53. package/dist/server/dev-middleware/hmr-client/index.js +0 -141
  54. /package/dist/{server/dev-middleware/hmr-client → client/hmr}/createSocketUrl.d.ts +0 -0
  55. /package/dist/{server/dev-middleware/hmr-client → client/hmr}/index.d.ts +0 -0
  56. /package/dist/rspack-provider/plugins/{rspack-profile.d.ts → rspackProfile.d.ts} +0 -0
@@ -26,12 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var rspack_profile_exports = {};
30
- __export(rspack_profile_exports, {
29
+ var rspackProfile_exports = {};
30
+ __export(rspackProfile_exports, {
31
31
  pluginRspackProfile: () => pluginRspackProfile,
32
32
  stopProfiler: () => stopProfiler
33
33
  });
34
- module.exports = __toCommonJS(rspack_profile_exports);
34
+ module.exports = __toCommonJS(rspackProfile_exports);
35
35
  var import_path = __toESM(require("path"));
36
36
  var import_core = require("@rspack/core");
37
37
  var import_inspector = __toESM(require("inspector"));
@@ -71,7 +71,7 @@ const pluginSwc = () => ({
71
71
  isServer,
72
72
  isServiceWorker
73
73
  });
74
- const rule = chain.module.rule(CHAIN_ID.RULE.JS).test((0, import_shared.mergeRegex)(import_shared.JS_REGEX, import_shared.TS_REGEX)).type("javascript/auto");
74
+ const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
75
75
  (0, import_shared.applyScriptCondition)({
76
76
  rule,
77
77
  config,
@@ -37,7 +37,6 @@ var import_initConfigs = require("./core/initConfigs");
37
37
  var import_initPlugins = require("./core/initPlugins");
38
38
  var import_plugin = require("./shared/plugin");
39
39
  var import_rspackVersion = require("./shared/rspackVersion");
40
- var import_server = require("../server");
41
40
  function rspackProvider({
42
41
  rsbuildConfig: originalRsbuildConfig
43
42
  }) {
@@ -73,15 +72,17 @@ function rspackProvider({
73
72
  });
74
73
  },
75
74
  async startDevServer(options) {
76
- const { startDevCompile } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
77
- return (0, import_server.startDevServer)(
75
+ const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
76
+ const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
77
+ return startDevServer(
78
78
  { context, pluginStore, rsbuildOptions },
79
- startDevCompile,
79
+ createDevMiddleware,
80
80
  options
81
81
  );
82
82
  },
83
83
  async preview(options) {
84
- return (0, import_server.startProdServer)(context, context.config, options);
84
+ const { startProdServer } = await Promise.resolve().then(() => __toESM(require("../server/prodServer")));
85
+ return startProdServer(context, context.config, options);
85
86
  },
86
87
  async build(options) {
87
88
  const { build: buildImpl, rspackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
@@ -54,7 +54,6 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
54
54
  Promise.resolve().then(() => __toESM(require("../plugins/less"))).then((m) => m.pluginLess()),
55
55
  Promise.resolve().then(() => __toESM(require("../plugins/sass"))).then((m) => m.pluginSass()),
56
56
  Promise.resolve().then(() => __toESM(require("../plugins/minimize"))).then((m) => m.pluginMinimize()),
57
- plugins.rem(),
58
57
  Promise.resolve().then(() => __toESM(require("../plugins/hmr"))).then((m) => m.pluginHMR()),
59
58
  Promise.resolve().then(() => __toESM(require("../plugins/progress"))).then((m) => m.pluginProgress()),
60
59
  Promise.resolve().then(() => __toESM(require("../plugins/swc"))).then((m) => m.pluginSwc()),
@@ -68,9 +67,7 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
68
67
  plugins.networkPerformance(),
69
68
  plugins.preloadOrPrefetch(),
70
69
  plugins.performance(),
71
- Promise.resolve().then(() => __toESM(require("../plugins/rspack-profile"))).then((m) => m.pluginRspackProfile()),
72
- Promise.resolve().then(() => __toESM(require("../plugins/fallback"))).then((m) => m.pluginFallback())
73
- // fallback should be the last plugin
70
+ Promise.resolve().then(() => __toESM(require("../plugins/rspackProfile"))).then((m) => m.pluginRspackProfile())
74
71
  ]);
75
72
  // Annotate the CommonJS export names for ESM import in node:
76
73
  0 && (module.exports = {
@@ -1,4 +1,4 @@
1
1
  import type { RsbuildConfig, NormalizedConfig, DefaultRsbuildPluginAPI, RsbuildPlugin as BaseRsbuildPlugin } from '@rsbuild/shared';
2
2
  import type { RspackConfig, RspackCompiler, RspackMultiCompiler } from '@rsbuild/shared';
3
3
  export interface RsbuildPluginAPI extends DefaultRsbuildPluginAPI<RsbuildConfig, NormalizedConfig, RspackConfig, RspackCompiler | RspackMultiCompiler> {}
4
- export type RsbuildPlugin = BaseRsbuildPlugin<RsbuildPluginAPI>;
4
+ export type RsbuildPlugin<T = RsbuildPluginAPI> = BaseRsbuildPlugin<T>;
@@ -10,12 +10,14 @@ type Options = {
10
10
  export default class DevMiddleware extends EventEmitter {
11
11
  middleware?: DevMiddlewareAPI;
12
12
  private devOptions;
13
+ private devMiddleware?;
13
14
  private socketServer;
14
15
  constructor({
15
16
  dev,
16
17
  devMiddleware
17
18
  }: Options);
18
19
  init(app: Server): void;
20
+ close(): void;
19
21
  sockWrite(type: string, data?: Record<string, any> | string | boolean): void;
20
22
  private setupDevMiddleware;
21
23
  }
@@ -40,7 +40,7 @@ function getHMRClientPath(client) {
40
40
  const host = (client == null ? void 0 : client.host) ? `&host=${client.host}` : "";
41
41
  const path = (client == null ? void 0 : client.path) ? `&path=${client.path}` : "";
42
42
  const port = (client == null ? void 0 : client.port) ? `&port=${client.port}` : "";
43
- const clientEntry = `${require.resolve("@rsbuild/core/hmr-client")}?${host}${path}${port}${protocol}`;
43
+ const clientEntry = `${require.resolve("@rsbuild/core/client/hmr")}?${host}${path}${port}${protocol}`;
44
44
  return clientEntry;
45
45
  }
46
46
  class DevMiddleware extends import_events.EventEmitter {
@@ -48,19 +48,20 @@ class DevMiddleware extends import_events.EventEmitter {
48
48
  super();
49
49
  this.devOptions = dev;
50
50
  this.socketServer = new import_socketServer.default(dev);
51
- if (devMiddleware) {
52
- this.middleware = this.setupDevMiddleware(devMiddleware);
53
- }
51
+ this.devMiddleware = devMiddleware;
54
52
  }
55
53
  init(app) {
54
+ if (this.devMiddleware) {
55
+ this.middleware = this.setupDevMiddleware(this.devMiddleware);
56
+ }
56
57
  app.on("listening", () => {
57
58
  this.socketServer.prepare(app);
58
59
  });
59
- app.on("close", async () => {
60
- var _a;
61
- (_a = this.middleware) == null ? void 0 : _a.close(noop);
62
- this.socketServer.close();
63
- });
60
+ }
61
+ close() {
62
+ var _a;
63
+ this.socketServer.close();
64
+ (_a = this.middleware) == null ? void 0 : _a.close(noop);
64
65
  }
65
66
  sockWrite(type, data) {
66
67
  this.socketServer.sockWrite(type, data);
@@ -4,7 +4,7 @@
4
4
  import { Server } from 'http';
5
5
  import type { ListenOptions } from 'net';
6
6
  import { RsbuildDevServerOptions, CreateDevServerOptions, DevServerContext, StartDevServerOptions, StartServerResult } from '@rsbuild/shared';
7
- import connect from 'connect';
7
+ import connect from '@rsbuild/shared/connect';
8
8
  export declare class RsbuildDevServer {
9
9
  private readonly dev;
10
10
  private readonly devMiddleware;
@@ -22,7 +22,7 @@ export declare class RsbuildDevServer {
22
22
  }
23
23
  export declare function startDevServer<Options extends {
24
24
  context: DevServerContext;
25
- }>(options: Options, startDevCompile: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevServerOptions['devMiddleware']>, {
25
+ }>(options: Options, createDevMiddleware: (options: Options, compiler: StartDevServerOptions['compiler']) => Promise<CreateDevServerOptions['devMiddleware']>, {
26
26
  open,
27
27
  compiler,
28
28
  printURLs,
@@ -37,7 +37,7 @@ var import_https = require("https");
37
37
  var import_url = __toESM(require("url"));
38
38
  var import_shared = require("@rsbuild/shared");
39
39
  var import_dev_middleware = __toESM(require("./dev-middleware"));
40
- var import_connect = __toESM(require("connect"));
40
+ var import_connect = __toESM(require("@rsbuild/shared/connect"));
41
41
  var import_proxy = require("./proxy");
42
42
  var import_middlewares = require("./middlewares");
43
43
  var import_path = require("path");
@@ -82,7 +82,7 @@ class RsbuildDevServer {
82
82
  async applyDefaultMiddlewares(app) {
83
83
  const { dev, devMiddleware } = this;
84
84
  if (dev.compress) {
85
- const { default: compression } = await Promise.resolve().then(() => __toESM(require("http-compression")));
85
+ const { default: compression } = await Promise.resolve().then(() => __toESM(require("../../compiled/http-compression")));
86
86
  this.middlewares.use((req, res, next) => {
87
87
  compression({
88
88
  gzip: true,
@@ -121,9 +121,8 @@ class RsbuildDevServer {
121
121
  })
122
122
  );
123
123
  if (dev.historyApiFallback) {
124
- const { default: connectHistoryApiFallback } = await Promise.resolve().then(() => __toESM(require("connect-history-api-fallback")));
124
+ const { default: connectHistoryApiFallback } = await Promise.resolve().then(() => __toESM(require("../../compiled/connect-history-api-fallback")));
125
125
  const historyApiFallbackMiddleware = connectHistoryApiFallback(
126
- // @ts-expect-error
127
126
  typeof dev.historyApiFallback === "boolean" ? {} : dev.historyApiFallback
128
127
  );
129
128
  this.middlewares.use(historyApiFallbackMiddleware);
@@ -154,10 +153,11 @@ class RsbuildDevServer {
154
153
  }
155
154
  }
156
155
  close() {
156
+ this.devMiddleware.close();
157
157
  this.app.close();
158
158
  }
159
159
  }
160
- async function startDevServer(options, startDevCompile, {
160
+ async function startDevServer(options, createDevMiddleware, {
161
161
  open,
162
162
  compiler,
163
163
  printURLs = true,
@@ -188,17 +188,8 @@ async function startDevServer(options, startDevCompile, {
188
188
  options.context.entry,
189
189
  (_c = (_b = rsbuildConfig.output) == null ? void 0 : _b.distPath) == null ? void 0 : _c.html
190
190
  );
191
- if (printURLs) {
192
- if ((0, import_shared.isFunction)(printURLs)) {
193
- urls = printURLs(urls);
194
- if (!Array.isArray(urls)) {
195
- throw new Error("Please return an array in the `printURLs` function.");
196
- }
197
- }
198
- (0, import_shared.printServerURLs)(urls, routes, logger);
199
- }
200
191
  (0, import_shared.debug)("create dev server");
201
- const devMiddleware = await startDevCompile(options, compiler);
192
+ const devMiddleware = await createDevMiddleware(options, compiler);
202
193
  const server = new RsbuildDevServer({
203
194
  pwd: options.context.rootPath,
204
195
  devMiddleware,
@@ -211,6 +202,15 @@ async function startDevServer(options, startDevCompile, {
211
202
  (0, import_shared.debug)("create dev server done");
212
203
  await options.context.hooks.onBeforeStartDevServerHook.call();
213
204
  const httpServer = await server.createHTTPServer();
205
+ if (printURLs) {
206
+ if ((0, import_shared.isFunction)(printURLs)) {
207
+ urls = printURLs(urls);
208
+ if (!Array.isArray(urls)) {
209
+ throw new Error("Please return an array in the `printURLs` function.");
210
+ }
211
+ }
212
+ (0, import_shared.printServerURLs)(urls, routes, logger);
213
+ }
214
214
  await server.onInit(httpServer);
215
215
  (0, import_shared.debug)("listen dev server");
216
216
  return new Promise((resolve) => {
@@ -233,7 +233,7 @@ async function startDevServer(options, startDevCompile, {
233
233
  port,
234
234
  urls: urls.map((item) => item.url),
235
235
  server: {
236
- close: () => {
236
+ close: async () => {
237
237
  server.close();
238
238
  }
239
239
  }
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import type { ListenOptions } from 'net';
4
4
  import { Server } from 'http';
5
- import connect from 'connect';
5
+ import connect from '@rsbuild/shared/connect';
6
6
  import { Context, RsbuildConfig, StartServerResult, PreviewServerOptions } from '@rsbuild/shared';
7
7
  type RsbuildProdServerOptions = {
8
8
  pwd: string;
@@ -33,7 +33,7 @@ __export(prodServer_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(prodServer_exports);
35
35
  var import_http = require("http");
36
- var import_connect = __toESM(require("connect"));
36
+ var import_connect = __toESM(require("@rsbuild/shared/connect"));
37
37
  var import_path = require("path");
38
38
  var import_sirv = __toESM(require("sirv"));
39
39
  var import_shared = require("@rsbuild/shared");
@@ -130,7 +130,7 @@ async function startProdServer(context, rsbuildConfig, { printURLs = true } = {}
130
130
  port,
131
131
  urls: urls.map((item) => item.url),
132
132
  server: {
133
- close: () => {
133
+ close: async () => {
134
134
  server.close();
135
135
  }
136
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/core",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Unleash the power of Rspack with the out-of-the-box build tool.",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "bugs": {
@@ -21,9 +21,9 @@
21
21
  "types": "./dist/server/index.d.ts",
22
22
  "default": "./dist/server/index.js"
23
23
  },
24
- "./hmr-client": {
25
- "types": "./dist/server/dev-middleware/hmr-client/index.d.ts",
26
- "default": "./dist/server/dev-middleware/hmr-client/index.js"
24
+ "./client/*": {
25
+ "types": "./dist/client/*.d.ts",
26
+ "default": "./dist/client/*.js"
27
27
  },
28
28
  "./cli": {
29
29
  "types": "./dist/cli/index.d.ts",
@@ -54,30 +54,22 @@
54
54
  "bin",
55
55
  "dist",
56
56
  "static",
57
+ "compiled",
57
58
  "types.d.ts"
58
59
  ],
59
60
  "dependencies": {
60
- "@rspack/core": "0.3.11",
61
- "connect": "3.7.0",
62
- "connect-history-api-fallback": "^2.0.0",
63
- "commander": "^10.0.1",
61
+ "@rspack/core": "0.3.12",
64
62
  "core-js": "~3.32.2",
65
- "gzip-size": "^6.0.0",
66
63
  "html-webpack-plugin": "npm:html-rspack-plugin@5.5.5",
67
- "http-compression": "1.0.6",
68
64
  "http-proxy-middleware": "^2.0.1",
69
65
  "jiti": "^1.20.0",
70
- "open": "^8.4.0",
71
66
  "postcss": "8.4.31",
72
- "rslog": "^1.1.0",
73
67
  "semver": "^7.5.4",
74
68
  "sirv": "^2.0.3",
75
69
  "ws": "^8.2.0",
76
- "@rsbuild/shared": "0.0.21"
70
+ "@rsbuild/shared": "0.0.23"
77
71
  },
78
72
  "devDependencies": {
79
- "@types/connect": "3.4.35",
80
- "@types/connect-history-api-fallback": "^1.3.5",
81
73
  "@types/node": "^16",
82
74
  "@types/ws": "^8.2.0",
83
75
  "@types/semver": "^7.5.4",
@@ -1,2 +0,0 @@
1
- import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginRem: () => DefaultRsbuildPlugin;
@@ -1,103 +0,0 @@
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 rem_exports = {};
30
- __export(rem_exports, {
31
- pluginRem: () => pluginRem
32
- });
33
- module.exports = __toCommonJS(rem_exports);
34
- var import_shared = require("@rsbuild/shared");
35
- var import_shared2 = require("@rsbuild/shared");
36
- const defaultOptions = {
37
- enableRuntime: true,
38
- rootFontSize: 50
39
- };
40
- const pluginRem = () => ({
41
- name: "plugin-rem",
42
- pre: ["plugin-css", "plugin-less", "plugin-sass", "plugin-stylus"],
43
- setup(api) {
44
- api.modifyBundlerChain(
45
- async (chain, { CHAIN_ID, isServer, isWebWorker, HtmlPlugin }) => {
46
- const config = api.getNormalizedConfig();
47
- const {
48
- output: { convertToRem }
49
- } = config;
50
- if (!convertToRem || isServer || isWebWorker) {
51
- return;
52
- }
53
- const userOptions = {
54
- ...defaultOptions,
55
- ...typeof convertToRem === "boolean" ? {} : convertToRem
56
- };
57
- const { default: PxToRemPlugin } = await Promise.resolve().then(() => __toESM(require((0, import_shared.getSharedPkgCompiledPath)("postcss-pxtorem"))));
58
- const applyRules = [
59
- CHAIN_ID.RULE.CSS,
60
- CHAIN_ID.RULE.LESS,
61
- CHAIN_ID.RULE.SASS,
62
- CHAIN_ID.RULE.STYLUS
63
- ];
64
- const getPxToRemPlugin = () => PxToRemPlugin({
65
- rootValue: userOptions.rootFontSize,
66
- unitPrecision: 5,
67
- propList: ["*"],
68
- ...userOptions.pxtorem ? (0, import_shared2.cloneDeep)(userOptions.pxtorem) : {}
69
- });
70
- applyRules.forEach((name) => {
71
- chain.module.rules.has(name) && chain.module.rule(name).use(CHAIN_ID.USE.POSTCSS).tap((options = {}) => {
72
- var _a;
73
- return {
74
- ...options,
75
- postcssOptions: {
76
- ...options.postcssOptions || {},
77
- plugins: [
78
- ...((_a = options.postcssOptions) == null ? void 0 : _a.plugins) || [],
79
- getPxToRemPlugin()
80
- ]
81
- }
82
- };
83
- });
84
- });
85
- if (!userOptions.enableRuntime) {
86
- return;
87
- }
88
- const entries = Object.keys(chain.entryPoints.entries() || {});
89
- const distDir = (0, import_shared.getDistPath)(config.output, "js");
90
- chain.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE).use(import_shared.AutoSetRootFontSizePlugin, [
91
- userOptions,
92
- entries,
93
- HtmlPlugin,
94
- distDir
95
- ]);
96
- }
97
- );
98
- }
99
- });
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- pluginRem
103
- });
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '../types';
2
- export declare const pluginFallback: () => RsbuildPlugin;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var fallback_exports = {};
20
- __export(fallback_exports, {
21
- pluginFallback: () => pluginFallback
22
- });
23
- module.exports = __toCommonJS(fallback_exports);
24
- var import_path = require("path");
25
- var import_shared = require("@rsbuild/shared");
26
- const pluginFallback = () => ({
27
- name: "plugin-fallback",
28
- setup(api) {
29
- api.modifyRspackConfig((config, { isProd }) => {
30
- var _a;
31
- const rsbuildConfig = api.getNormalizedConfig();
32
- if (!rsbuildConfig.output.enableAssetFallback) {
33
- return;
34
- }
35
- const distDir = (0, import_shared.getDistPath)(rsbuildConfig.output, "media");
36
- const filename = (0, import_shared.getFilename)(rsbuildConfig.output, "media", isProd);
37
- (0, import_shared.setConfig)(config, "output.assetModuleFilename", (0, import_path.join)(distDir, filename));
38
- if (!config.module) {
39
- return;
40
- }
41
- (0, import_shared.setConfig)(
42
- config,
43
- "module.rules",
44
- (0, import_shared.resourceRuleFallback)((_a = config.module) == null ? void 0 : _a.rules)
45
- );
46
- });
47
- }
48
- });
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {
51
- pluginFallback
52
- });
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var createSocketUrl_exports = {};
20
- __export(createSocketUrl_exports, {
21
- HMR_SOCK_PATH: () => HMR_SOCK_PATH,
22
- createSocketUrl: () => createSocketUrl,
23
- formatURL: () => formatURL
24
- });
25
- module.exports = __toCommonJS(createSocketUrl_exports);
26
- const HMR_SOCK_PATH = "/rsbuild-hmr";
27
- function createSocketUrl(resourceQuery) {
28
- const searchParams = resourceQuery.substr(1).split("&");
29
- const options = {};
30
- for (const pair of searchParams) {
31
- const ary = pair.split("=");
32
- options[ary[0]] = decodeURIComponent(ary[1]);
33
- }
34
- const currentLocation = self.location;
35
- return getSocketUrl(options, currentLocation);
36
- }
37
- function formatURL({
38
- port,
39
- protocol,
40
- hostname,
41
- pathname
42
- }) {
43
- if (window.URL) {
44
- const url = new URL("http://localhost");
45
- url.port = port;
46
- url.hostname = hostname;
47
- url.protocol = protocol;
48
- url.pathname = pathname;
49
- return url.toString();
50
- }
51
- const colon = protocol.indexOf(":") === -1 ? ":" : "";
52
- return `${protocol}${colon}//${hostname}:${port}${pathname}`;
53
- }
54
- function getSocketUrl(urlParts, location) {
55
- const { host, port, path, protocol } = urlParts;
56
- return formatURL({
57
- protocol: protocol || (location.protocol === "https:" ? "wss" : "ws"),
58
- hostname: host || location.hostname,
59
- port: port || location.port,
60
- pathname: path || HMR_SOCK_PATH
61
- });
62
- }
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- HMR_SOCK_PATH,
66
- createSocketUrl,
67
- formatURL
68
- });