@rsbuild/webpack 0.0.20 → 0.0.22

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.
@@ -8,4 +8,4 @@ export declare function createCompiler({
8
8
  context: Context;
9
9
  webpackConfigs: WebpackConfig[];
10
10
  }): Promise<Compiler | MultiCompiler>;
11
- export declare function startDevCompile(options: InitConfigsOptions, customCompiler?: Compiler | MultiCompiler): Promise<import("@rsbuild/shared").DevMiddleware>;
11
+ export declare function createDevMiddleware(options: InitConfigsOptions, customCompiler?: Compiler | MultiCompiler): Promise<import("@rsbuild/shared").DevMiddleware>;
@@ -29,7 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var createCompiler_exports = {};
30
30
  __export(createCompiler_exports, {
31
31
  createCompiler: () => createCompiler,
32
- startDevCompile: () => startDevCompile
32
+ createDevMiddleware: () => createDevMiddleware
33
33
  });
34
34
  module.exports = __toCommonJS(createCompiler_exports);
35
35
  var import_shared = require("@rsbuild/shared");
@@ -65,7 +65,7 @@ async function createCompiler({
65
65
  (0, import_shared.debug)("create compiler done");
66
66
  return compiler;
67
67
  }
68
- async function startDevCompile(options, customCompiler) {
68
+ async function createDevMiddleware(options, customCompiler) {
69
69
  let compiler;
70
70
  if (customCompiler) {
71
71
  compiler = customCompiler;
@@ -81,5 +81,5 @@ async function startDevCompile(options, customCompiler) {
81
81
  // Annotate the CommonJS export names for ESM import in node:
82
82
  0 && (module.exports = {
83
83
  createCompiler,
84
- startDevCompile
84
+ createDevMiddleware
85
85
  });
@@ -127,7 +127,7 @@ const pluginBabel = () => ({
127
127
  includes,
128
128
  excludes
129
129
  });
130
- rule.test(useTsLoader ? import_shared.JS_REGEX : (0, import_shared.mergeRegex)(import_shared.JS_REGEX, import_shared.TS_REGEX)).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelOptions);
130
+ rule.test(useTsLoader ? import_shared.JS_REGEX : import_shared.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelOptions);
131
131
  chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
132
132
  or: ["text/javascript", "application/javascript"]
133
133
  }).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(import_lodash.default.cloneDeep(babelOptions));
@@ -31,7 +31,7 @@ __export(copy_exports, {
31
31
  pluginCopy: () => pluginCopy
32
32
  });
33
33
  module.exports = __toCommonJS(copy_exports);
34
- var import_fs_extra = require("@rsbuild/shared/fs-extra");
34
+ var import_fs = __toESM(require("fs"));
35
35
  const pluginCopy = () => ({
36
36
  name: "plugin-copy",
37
37
  setup(api) {
@@ -52,7 +52,7 @@ const pluginCopy = () => ({
52
52
  );
53
53
  if (copyPlugin) {
54
54
  const isContextNotExists = copyPlugin.patterns.every(
55
- (pattern) => typeof pattern !== "string" && pattern.context && !import_fs_extra.fs.existsSync(pattern.context)
55
+ (pattern) => typeof pattern !== "string" && pattern.context && !import_fs.default.existsSync(pattern.context)
56
56
  );
57
57
  if (isContextNotExists) {
58
58
  config.plugins = (_b = config.plugins) == null ? void 0 : _b.filter(
package/dist/provider.js CHANGED
@@ -70,16 +70,16 @@ function webpackProvider({
70
70
  return createCompiler({ context, webpackConfigs });
71
71
  },
72
72
  async startDevServer(options) {
73
- const { startDevCompile } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
73
+ const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
74
74
  return (0, import_server.startDevServer)(
75
75
  { context, pluginStore, rsbuildOptions },
76
76
  // @ts-expect-error compiler type mismatch
77
- startDevCompile,
77
+ createDevMiddleware,
78
78
  options
79
79
  );
80
80
  },
81
- async preview() {
82
- return (0, import_server.startProdServer)(context, context.config);
81
+ async preview(options) {
82
+ return (0, import_server.startProdServer)(context, context.config, options);
83
83
  },
84
84
  async build(options) {
85
85
  const { build: buildImpl, webpackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
package/dist/shared/fs.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,18 +17,26 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var fs_exports = {};
20
30
  __export(fs_exports, {
21
31
  getCompiledPath: () => getCompiledPath
22
32
  });
23
33
  module.exports = __toCommonJS(fs_exports);
34
+ var import_fs = __toESM(require("fs"));
24
35
  var import_path = require("path");
25
36
  var import_shared = require("@rsbuild/shared");
26
- var import_fs_extra = require("@rsbuild/shared/fs-extra");
27
37
  const getCompiledPath = (packageName) => {
28
38
  const providerCompilerPath = (0, import_path.join)(__dirname, "../../compiled", packageName);
29
- if (import_fs_extra.fs.existsSync(providerCompilerPath)) {
39
+ if (import_fs.default.existsSync(providerCompilerPath)) {
30
40
  return providerCompilerPath;
31
41
  } else {
32
42
  return (0, import_shared.getSharedPkgCompiledPath)(packageName);
@@ -60,7 +60,6 @@ const applyDefaultPlugins = (plugins) => {
60
60
  Promise.resolve().then(() => __toESM(require("../plugins/css"))).then((m) => m.pluginCss()),
61
61
  Promise.resolve().then(() => __toESM(require("../plugins/sass"))).then((m) => m.pluginSass()),
62
62
  Promise.resolve().then(() => __toESM(require("../plugins/less"))).then((m) => m.pluginLess()),
63
- plugins.rem(),
64
63
  plugins.bundleAnalyzer(),
65
64
  plugins.toml(),
66
65
  plugins.yaml(),
@@ -70,9 +69,7 @@ const applyDefaultPlugins = (plugins) => {
70
69
  plugins.externals(),
71
70
  plugins.performance(),
72
71
  plugins.networkPerformance(),
73
- plugins.preloadOrPrefetch(),
74
- Promise.resolve().then(() => __toESM(require("../plugins/fallback"))).then((m) => m.pluginFallback())
75
- // fallback should be the last plugin
72
+ plugins.preloadOrPrefetch()
76
73
  ]);
77
74
  };
78
75
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "homepage": "https://rsbuild.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,16 +24,6 @@
24
24
  },
25
25
  "main": "./dist/index.js",
26
26
  "types": "./dist/index.d.ts",
27
- "typesVersions": {
28
- "*": {
29
- "plugin-babel": [
30
- "./dist/plugins/babel.d.ts"
31
- ],
32
- "plugin-css": [
33
- "./dist/plugins/css.d.ts"
34
- ]
35
- }
36
- },
37
27
  "files": [
38
28
  "static",
39
29
  "compiled",
@@ -51,7 +41,7 @@
51
41
  "fast-glob": "^3.3.1",
52
42
  "glob": "^9.3.5",
53
43
  "globby": "^11.1.0",
54
- "html-webpack-plugin": "npm:html-rspack-plugin@5.5.4",
44
+ "html-webpack-plugin": "npm:html-rspack-plugin@5.5.5",
55
45
  "lodash": "^4.17.21",
56
46
  "mini-css-extract-plugin": "2.7.6",
57
47
  "postcss": "8.4.31",
@@ -61,11 +51,11 @@
61
51
  "ts-loader": "9.4.4",
62
52
  "tsconfig-paths-webpack-plugin": "4.1.0",
63
53
  "webpack": "^5.89.0",
64
- "@rsbuild/babel-preset": "0.0.20",
65
- "@rsbuild/core": "0.0.20",
66
- "@rsbuild/plugin-css-minimizer": "0.0.20",
67
- "@rsbuild/shared": "0.0.20",
68
- "@rsbuild/plugin-babel": "0.0.20"
54
+ "@rsbuild/babel-preset": "0.0.22",
55
+ "@rsbuild/plugin-babel": "0.0.22",
56
+ "@rsbuild/core": "0.0.22",
57
+ "@rsbuild/plugin-css-minimizer": "0.0.22",
58
+ "@rsbuild/shared": "0.0.22"
69
59
  },
70
60
  "devDependencies": {
71
61
  "@types/lodash": "^4.14.200",
@@ -73,7 +63,7 @@
73
63
  "react": "^18.2.0",
74
64
  "react-dom": "^18.2.0",
75
65
  "typescript": "^5.2.2",
76
- "@rsbuild/test-helper": "0.0.20"
66
+ "@rsbuild/test-helper": "0.0.22"
77
67
  },
78
68
  "engines": {
79
69
  "node": ">=14.0.0"
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '../types';
2
- export declare const pluginFallback: () => RsbuildPlugin;
@@ -1,51 +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.modifyWebpackChain((chain, { isProd }) => {
30
- const rsbuildConfig = api.getNormalizedConfig();
31
- if (rsbuildConfig.output.enableAssetFallback) {
32
- const distDir = (0, import_shared.getDistPath)(rsbuildConfig.output, "media");
33
- const filename = (0, import_shared.getFilename)(rsbuildConfig.output, "media", isProd);
34
- chain.output.merge({
35
- assetModuleFilename: (0, import_path.join)(distDir, filename)
36
- });
37
- }
38
- });
39
- api.modifyWebpackConfig((config) => {
40
- const rsbuildConfig = api.getNormalizedConfig();
41
- if (!rsbuildConfig.output.enableAssetFallback || !config.module) {
42
- return;
43
- }
44
- config.module.rules = (0, import_shared.resourceRuleFallback)(config.module.rules);
45
- });
46
- }
47
- });
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- pluginFallback
51
- });