@rsbuild/webpack 0.0.0-next-20231103091827

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 (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/compiled/ansi-escapes/index.d.ts +248 -0
  4. package/compiled/ansi-escapes/index.js +1 -0
  5. package/compiled/ansi-escapes/license +9 -0
  6. package/compiled/ansi-escapes/package.json +1 -0
  7. package/compiled/ansi-escapes/type-fest/index.d.ts +2 -0
  8. package/compiled/babel-plugin-lodash/index.d.ts +1 -0
  9. package/compiled/babel-plugin-lodash/index.js +1 -0
  10. package/compiled/babel-plugin-lodash/license +44 -0
  11. package/compiled/babel-plugin-lodash/package.json +1 -0
  12. package/compiled/babel-plugin-transform-react-remove-prop-types/index.d.ts +1 -0
  13. package/compiled/babel-plugin-transform-react-remove-prop-types/index.js +1 -0
  14. package/compiled/babel-plugin-transform-react-remove-prop-types/license +22 -0
  15. package/compiled/babel-plugin-transform-react-remove-prop-types/package.json +1 -0
  16. package/compiled/cli-truncate/index.d.ts +96 -0
  17. package/compiled/cli-truncate/index.js +1 -0
  18. package/compiled/cli-truncate/license +9 -0
  19. package/compiled/cli-truncate/package.json +1 -0
  20. package/compiled/copy-webpack-plugin/index.d.ts +1 -0
  21. package/compiled/copy-webpack-plugin/index.js +22 -0
  22. package/compiled/copy-webpack-plugin/license +20 -0
  23. package/compiled/copy-webpack-plugin/package.json +1 -0
  24. package/compiled/patch-console/build/index.d.ts +4 -0
  25. package/compiled/patch-console/index.js +1 -0
  26. package/compiled/patch-console/package.json +1 -0
  27. package/compiled/schema-utils3/index.d.ts +1 -0
  28. package/compiled/schema-utils3/index.js +3 -0
  29. package/compiled/schema-utils3/license +20 -0
  30. package/compiled/schema-utils3/package.json +1 -0
  31. package/compiled/tapable/index.js +1 -0
  32. package/compiled/tapable/license +21 -0
  33. package/compiled/tapable/package.json +1 -0
  34. package/compiled/tapable/tapable.d.ts +116 -0
  35. package/compiled/webpack-manifest-plugin/index.js +1 -0
  36. package/compiled/webpack-manifest-plugin/license +21 -0
  37. package/compiled/webpack-manifest-plugin/package.json +1 -0
  38. package/compiled/webpack-manifest-plugin/types/helpers.d.ts +23 -0
  39. package/compiled/webpack-manifest-plugin/types/hooks.d.ts +24 -0
  40. package/compiled/webpack-manifest-plugin/types/index.d.ts +30 -0
  41. package/compiled/webpack-sources/index.d.ts +1 -0
  42. package/compiled/webpack-sources/index.js +1 -0
  43. package/compiled/webpack-sources/license +21 -0
  44. package/compiled/webpack-sources/package.json +1 -0
  45. package/dist/config/defaults.d.ts +3 -0
  46. package/dist/config/defaults.js +52 -0
  47. package/dist/config/normalize.d.ts +7 -0
  48. package/dist/config/normalize.js +33 -0
  49. package/dist/core/build.d.ts +20 -0
  50. package/dist/core/build.js +80 -0
  51. package/dist/core/createCompiler.d.ts +8 -0
  52. package/dist/core/createCompiler.js +68 -0
  53. package/dist/core/createContext.d.ts +13 -0
  54. package/dist/core/createContext.js +56 -0
  55. package/dist/core/devMiddleware.d.ts +5 -0
  56. package/dist/core/devMiddleware.js +73 -0
  57. package/dist/core/initConfigs.d.ts +14 -0
  58. package/dist/core/initConfigs.js +76 -0
  59. package/dist/core/initHooks.d.ts +19 -0
  60. package/dist/core/initHooks.js +44 -0
  61. package/dist/core/initPlugins.d.ts +9 -0
  62. package/dist/core/initPlugins.js +83 -0
  63. package/dist/core/inspectConfig.d.ts +20 -0
  64. package/dist/core/inspectConfig.js +81 -0
  65. package/dist/core/startDevServer.d.ts +5 -0
  66. package/dist/core/startDevServer.js +75 -0
  67. package/dist/core/webpackConfig.d.ts +9 -0
  68. package/dist/core/webpackConfig.js +164 -0
  69. package/dist/exports/webpack.d.ts +2 -0
  70. package/dist/exports/webpack.js +35 -0
  71. package/dist/index.d.ts +6 -0
  72. package/dist/index.js +34 -0
  73. package/dist/plugins/babel.d.ts +3 -0
  74. package/dist/plugins/babel.js +171 -0
  75. package/dist/plugins/basic.d.ts +5 -0
  76. package/dist/plugins/basic.js +60 -0
  77. package/dist/plugins/copy.d.ts +2 -0
  78. package/dist/plugins/copy.js +69 -0
  79. package/dist/plugins/css.d.ts +23 -0
  80. package/dist/plugins/css.js +123 -0
  81. package/dist/plugins/fallback.d.ts +2 -0
  82. package/dist/plugins/fallback.js +51 -0
  83. package/dist/plugins/hmr.d.ts +2 -0
  84. package/dist/plugins/hmr.js +41 -0
  85. package/dist/plugins/lazyCompilation.d.ts +2 -0
  86. package/dist/plugins/lazyCompilation.js +43 -0
  87. package/dist/plugins/less.d.ts +6 -0
  88. package/dist/plugins/less.js +65 -0
  89. package/dist/plugins/manifest.d.ts +2 -0
  90. package/dist/plugins/manifest.js +58 -0
  91. package/dist/plugins/minimize.d.ts +2 -0
  92. package/dist/plugins/minimize.js +64 -0
  93. package/dist/plugins/moduleScopes.d.ts +5 -0
  94. package/dist/plugins/moduleScopes.js +85 -0
  95. package/dist/plugins/output.d.ts +2 -0
  96. package/dist/plugins/output.js +66 -0
  97. package/dist/plugins/progress.d.ts +2 -0
  98. package/dist/plugins/progress.js +57 -0
  99. package/dist/plugins/react.d.ts +2 -0
  100. package/dist/plugins/react.js +96 -0
  101. package/dist/plugins/resolve.d.ts +2 -0
  102. package/dist/plugins/resolve.js +88 -0
  103. package/dist/plugins/sass.d.ts +2 -0
  104. package/dist/plugins/sass.js +76 -0
  105. package/dist/plugins/sri.d.ts +2 -0
  106. package/dist/plugins/sri.js +43 -0
  107. package/dist/plugins/tsLoader.d.ts +2 -0
  108. package/dist/plugins/tsLoader.js +103 -0
  109. package/dist/provider.d.ts +9 -0
  110. package/dist/provider.js +104 -0
  111. package/dist/shared/fs.d.ts +1 -0
  112. package/dist/shared/fs.js +38 -0
  113. package/dist/shared/index.d.ts +1 -0
  114. package/dist/shared/index.js +22 -0
  115. package/dist/shared/plugin.d.ts +5 -0
  116. package/dist/shared/plugin.js +111 -0
  117. package/dist/types/config/index.d.ts +30 -0
  118. package/dist/types/config/index.js +26 -0
  119. package/dist/types/config/security.d.ts +9 -0
  120. package/dist/types/config/security.js +16 -0
  121. package/dist/types/config/source.d.ts +26 -0
  122. package/dist/types/config/source.js +16 -0
  123. package/dist/types/config/tools.d.ts +52 -0
  124. package/dist/types/config/tools.js +16 -0
  125. package/dist/types/context.d.ts +17 -0
  126. package/dist/types/context.js +16 -0
  127. package/dist/types/hooks.d.ts +24 -0
  128. package/dist/types/hooks.js +16 -0
  129. package/dist/types/index.d.ts +5 -0
  130. package/dist/types/index.js +30 -0
  131. package/dist/types/plugin.d.ts +10 -0
  132. package/dist/types/plugin.js +16 -0
  133. package/dist/types/thirdParty/css.d.ts +7 -0
  134. package/dist/types/thirdParty/css.js +16 -0
  135. package/dist/types/thirdParty/index.d.ts +9 -0
  136. package/dist/types/thirdParty/index.js +16 -0
  137. package/dist/webpackPlugins/ModuleScopePlugin.d.ts +16 -0
  138. package/dist/webpackPlugins/ModuleScopePlugin.js +111 -0
  139. package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.d.ts +13 -0
  140. package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.js +102 -0
  141. package/dist/webpackPlugins/ProgressPlugin/helpers/bar.d.ts +5 -0
  142. package/dist/webpackPlugins/ProgressPlugin/helpers/bar.js +143 -0
  143. package/dist/webpackPlugins/ProgressPlugin/helpers/bus.d.ts +17 -0
  144. package/dist/webpackPlugins/ProgressPlugin/helpers/bus.js +105 -0
  145. package/dist/webpackPlugins/ProgressPlugin/helpers/index.d.ts +4 -0
  146. package/dist/webpackPlugins/ProgressPlugin/helpers/index.js +28 -0
  147. package/dist/webpackPlugins/ProgressPlugin/helpers/log.d.ts +8 -0
  148. package/dist/webpackPlugins/ProgressPlugin/helpers/log.js +62 -0
  149. package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.d.ts +15 -0
  150. package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.js +56 -0
  151. package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.d.ts +7 -0
  152. package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.js +52 -0
  153. package/dist/webpackPlugins/ProgressPlugin/helpers/type.d.ts +25 -0
  154. package/dist/webpackPlugins/ProgressPlugin/helpers/type.js +16 -0
  155. package/dist/webpackPlugins/ProgressPlugin/helpers/utils.d.ts +1 -0
  156. package/dist/webpackPlugins/ProgressPlugin/helpers/utils.js +30 -0
  157. package/package.json +88 -0
  158. package/static/ModuleFilenameHelpers.js +2 -0
@@ -0,0 +1,57 @@
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 progress_exports = {};
30
+ __export(progress_exports, {
31
+ pluginProgress: () => pluginProgress
32
+ });
33
+ module.exports = __toCommonJS(progress_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ const pluginProgress = () => ({
36
+ name: "plugin-progress",
37
+ setup(api) {
38
+ api.modifyWebpackChain(async (chain, { target, CHAIN_ID }) => {
39
+ const config = api.getNormalizedConfig();
40
+ const options = config.dev.progressBar;
41
+ if (!options) {
42
+ return;
43
+ }
44
+ const { ProgressPlugin } = await Promise.resolve().then(() => __toESM(require("../webpackPlugins/ProgressPlugin/ProgressPlugin")));
45
+ chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
46
+ {
47
+ id: import_shared.TARGET_ID_MAP[target],
48
+ ...options === true ? {} : options
49
+ }
50
+ ]);
51
+ });
52
+ }
53
+ });
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ pluginProgress
57
+ });
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginReactWebpack: () => RsbuildPlugin;
@@ -0,0 +1,96 @@
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 react_exports = {};
30
+ __export(react_exports, {
31
+ pluginReactWebpack: () => pluginReactWebpack
32
+ });
33
+ module.exports = __toCommonJS(react_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ const pluginReactWebpack = () => ({
36
+ name: "plugin-react-webpack",
37
+ setup(api) {
38
+ api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {
39
+ const babelConfig = {
40
+ tools: {
41
+ babel(_, { addPresets, addPlugins }) {
42
+ const isNewJsx = (0, import_shared.isBeyondReact17)(api.context.rootPath);
43
+ const presetReactOptions = {
44
+ development: !(0, import_shared.isProd)(),
45
+ // Will use the native built-in instead of trying to polyfill
46
+ useBuiltIns: true,
47
+ useSpread: false,
48
+ runtime: isNewJsx ? "automatic" : "classic"
49
+ };
50
+ addPresets([
51
+ [require.resolve("@babel/preset-react"), presetReactOptions]
52
+ ]);
53
+ if ((0, import_shared.isProd)()) {
54
+ addPlugins([
55
+ [
56
+ require.resolve("babel-plugin-transform-react-remove-prop-types"),
57
+ { removeImport: true }
58
+ ]
59
+ ]);
60
+ }
61
+ }
62
+ }
63
+ };
64
+ return mergeRsbuildConfig(babelConfig, config);
65
+ });
66
+ api.modifyWebpackChain(async (chain, utils) => {
67
+ const config = api.getNormalizedConfig();
68
+ if (!(0, import_shared.isUsingHMR)(config, utils)) {
69
+ return;
70
+ }
71
+ const { CHAIN_ID } = utils;
72
+ const { default: ReactFastRefreshPlugin } = await Promise.resolve().then(() => __toESM(require("@pmmmwh/react-refresh-webpack-plugin")));
73
+ const useTsLoader = Boolean(config.tools.tsLoader);
74
+ const rule = useTsLoader ? chain.module.rule(CHAIN_ID.RULE.TS) : chain.module.rule(CHAIN_ID.RULE.JS);
75
+ if (rule.uses.get(CHAIN_ID.USE.BABEL)) {
76
+ rule.use(CHAIN_ID.USE.BABEL).tap((options) => ({
77
+ ...options,
78
+ plugins: [
79
+ ...options.plugins || [],
80
+ [require.resolve("react-refresh/babel"), { skipEnvCheck: true }]
81
+ ]
82
+ }));
83
+ }
84
+ chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactFastRefreshPlugin, [
85
+ {
86
+ overlay: false,
87
+ exclude: [/node_modules/]
88
+ }
89
+ ]);
90
+ });
91
+ }
92
+ });
93
+ // Annotate the CommonJS export names for ESM import in node:
94
+ 0 && (module.exports = {
95
+ pluginReactWebpack
96
+ });
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginResolve: () => RsbuildPlugin;
@@ -0,0 +1,88 @@
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 resolve_exports = {};
30
+ __export(resolve_exports, {
31
+ pluginResolve: () => pluginResolve
32
+ });
33
+ module.exports = __toCommonJS(resolve_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ var import_path = __toESM(require("path"));
36
+ async function applyTsConfigPathsPlugin({
37
+ chain,
38
+ CHAIN_ID,
39
+ cwd,
40
+ mainFields,
41
+ extensions
42
+ }) {
43
+ const { TsconfigPathsPlugin } = await Promise.resolve().then(() => __toESM(require("tsconfig-paths-webpack-plugin")));
44
+ chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
45
+ {
46
+ configFile: import_path.default.resolve(cwd, import_shared.TS_CONFIG_FILE),
47
+ extensions,
48
+ // https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
49
+ mainFields
50
+ }
51
+ ]);
52
+ }
53
+ const getMainFields = (chain, target) => {
54
+ const mainFields = chain.resolve.mainFields.values();
55
+ if (mainFields.length) {
56
+ return mainFields;
57
+ }
58
+ if ((0, import_shared.isWebTarget)(target)) {
59
+ return ["browser", "module", "main"];
60
+ }
61
+ return ["module", "main"];
62
+ };
63
+ const pluginResolve = () => ({
64
+ name: "plugin-resolve",
65
+ setup(api) {
66
+ (0, import_shared.applyResolvePlugin)(api);
67
+ api.modifyWebpackChain(async (chain, { CHAIN_ID, target }) => {
68
+ const config = api.getNormalizedConfig();
69
+ const isTsProject = Boolean(api.context.tsconfigPath);
70
+ if (config.source.compileJsDataURI) {
71
+ chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).resolve.set("fullySpecified", false);
72
+ }
73
+ if (isTsProject && config.source.aliasStrategy === "prefer-tsconfig") {
74
+ await applyTsConfigPathsPlugin({
75
+ chain,
76
+ CHAIN_ID,
77
+ cwd: api.context.rootPath,
78
+ mainFields: getMainFields(chain, target),
79
+ extensions: chain.resolve.extensions.values()
80
+ });
81
+ }
82
+ });
83
+ }
84
+ });
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ pluginResolve
88
+ });
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare function pluginSass(): RsbuildPlugin;
@@ -0,0 +1,76 @@
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 sass_exports = {};
30
+ __export(sass_exports, {
31
+ pluginSass: () => pluginSass
32
+ });
33
+ module.exports = __toCommonJS(sass_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ function pluginSass() {
36
+ return {
37
+ name: "plugin-sass",
38
+ async setup(api) {
39
+ api.onAfterCreateCompiler(({ compiler }) => {
40
+ (0, import_shared.patchCompilerGlobalLocation)(compiler);
41
+ });
42
+ api.modifyBundlerChain(async (chain, utils) => {
43
+ const config = api.getNormalizedConfig();
44
+ const { applyBaseCSSRule } = await Promise.resolve().then(() => __toESM(require("./css")));
45
+ const { options, excludes } = await (0, import_shared.getSassLoaderOptions)(
46
+ config.tools.sass,
47
+ // source-maps required for loaders preceding resolve-url-loader
48
+ true
49
+ );
50
+ const rule = chain.module.rule(utils.CHAIN_ID.RULE.SASS).test(import_shared.SASS_REGEX);
51
+ excludes.forEach((item) => {
52
+ rule.exclude.add(item);
53
+ });
54
+ await applyBaseCSSRule({
55
+ rule,
56
+ utils,
57
+ config,
58
+ context: api.context,
59
+ // postcss-loader, resolve-url-loader, sass-loader
60
+ importLoaders: 3
61
+ });
62
+ rule.use(utils.CHAIN_ID.USE.RESOLVE_URL_LOADER_FOR_SASS).loader(utils.getCompiledPath("resolve-url-loader")).options({
63
+ join: await (0, import_shared.getResolveUrlJoinFn)(),
64
+ // 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
65
+ // it has performance regression issues in some scenarios,
66
+ // so we need to disable the sourceMap option.
67
+ sourceMap: false
68
+ }).end().use(utils.CHAIN_ID.USE.SASS).loader(utils.getCompiledPath("sass-loader")).options(options);
69
+ });
70
+ }
71
+ };
72
+ }
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ pluginSass
76
+ });
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginSRI: () => RsbuildPlugin;
@@ -0,0 +1,43 @@
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 sri_exports = {};
20
+ __export(sri_exports, {
21
+ pluginSRI: () => pluginSRI
22
+ });
23
+ module.exports = __toCommonJS(sri_exports);
24
+ var import_webpack_subresource_integrity = require("webpack-subresource-integrity");
25
+ const pluginSRI = () => ({
26
+ name: "plugin-sri",
27
+ setup(api) {
28
+ api.modifyWebpackChain((chain, { CHAIN_ID }) => {
29
+ const subresourceIntegrityOptions = api.getNormalizedConfig().security.sri;
30
+ if (!subresourceIntegrityOptions) {
31
+ return;
32
+ }
33
+ chain.output.crossOriginLoading("anonymous");
34
+ chain.plugin(CHAIN_ID.PLUGIN.SUBRESOURCE_INTEGRITY).use(import_webpack_subresource_integrity.SubresourceIntegrityPlugin, [
35
+ typeof subresourceIntegrityOptions === "object" ? subresourceIntegrityOptions : void 0
36
+ ]);
37
+ });
38
+ }
39
+ });
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ pluginSRI
43
+ });
@@ -0,0 +1,2 @@
1
+ import type { RsbuildPlugin } from '../types';
2
+ export declare const pluginTsLoader: () => RsbuildPlugin;
@@ -0,0 +1,103 @@
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 tsLoader_exports = {};
30
+ __export(tsLoader_exports, {
31
+ pluginTsLoader: () => pluginTsLoader
32
+ });
33
+ module.exports = __toCommonJS(tsLoader_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ var import_plugin_babel = require("@rsbuild/plugin-babel");
36
+ var import_web = require("@rsbuild/babel-preset/web");
37
+ var import_babel = require("./babel");
38
+ const pluginTsLoader = () => {
39
+ return {
40
+ name: "plugin-ts-loader",
41
+ setup(api) {
42
+ api.modifyWebpackChain(async (chain, { target, CHAIN_ID }) => {
43
+ const config = api.getNormalizedConfig();
44
+ if (!config.tools.tsLoader) {
45
+ return;
46
+ }
47
+ const { rootPath } = api.context;
48
+ const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
49
+ rootPath,
50
+ config,
51
+ target
52
+ );
53
+ const baseBabelConfig = (0, import_web.getBabelConfigForWeb)({
54
+ presetEnv: {
55
+ targets: browserslist,
56
+ useBuiltIns: (0, import_babel.getUseBuiltIns)(config)
57
+ }
58
+ });
59
+ const babelUtils = (0, import_plugin_babel.getBabelUtils)(baseBabelConfig);
60
+ const babelLoaderOptions = (0, import_shared.mergeChainedOptions)(
61
+ baseBabelConfig,
62
+ config.tools.babel,
63
+ babelUtils
64
+ );
65
+ const includes = [];
66
+ const excludes = [];
67
+ const tsLoaderUtils = {
68
+ addIncludes(items) {
69
+ includes.push(...(0, import_shared.castArray)(items));
70
+ },
71
+ addExcludes(items) {
72
+ excludes.push(...(0, import_shared.castArray)(items));
73
+ }
74
+ };
75
+ const tsLoaderOptions = (0, import_shared.mergeChainedOptions)(
76
+ {
77
+ compilerOptions: {
78
+ target: "esnext",
79
+ module: "esnext"
80
+ },
81
+ transpileOnly: true,
82
+ allowTsInNodeModules: true
83
+ },
84
+ config.tools.tsLoader,
85
+ tsLoaderUtils
86
+ );
87
+ const rule = chain.module.rule(CHAIN_ID.RULE.TS);
88
+ (0, import_shared.applyScriptCondition)({
89
+ rule,
90
+ config,
91
+ context: api.context,
92
+ includes,
93
+ excludes
94
+ });
95
+ rule.test(import_shared.TS_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelLoaderOptions).end().use(CHAIN_ID.USE.TS).loader(require.resolve("ts-loader")).options(tsLoaderOptions);
96
+ });
97
+ }
98
+ };
99
+ };
100
+ // Annotate the CommonJS export names for ESM import in node:
101
+ 0 && (module.exports = {
102
+ pluginTsLoader
103
+ });
@@ -0,0 +1,9 @@
1
+ import { type RsbuildProvider } from '@rsbuild/shared';
2
+ import { RsbuildConfig, NormalizedConfig, WebpackConfig } from './types';
3
+ import type { Compiler, MultiCompiler } from 'webpack';
4
+ export type WebpackProvider = RsbuildProvider<RsbuildConfig, WebpackConfig, NormalizedConfig, Compiler | MultiCompiler>;
5
+ export declare function webpackProvider({
6
+ rsbuildConfig: originalRsbuildConfig
7
+ }: {
8
+ rsbuildConfig: RsbuildConfig;
9
+ }): WebpackProvider;
@@ -0,0 +1,104 @@
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 provider_exports = {};
30
+ __export(provider_exports, {
31
+ webpackProvider: () => webpackProvider
32
+ });
33
+ module.exports = __toCommonJS(provider_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ var import_createContext = require("./core/createContext");
36
+ var import_plugin = require("./shared/plugin");
37
+ var import_initConfigs = require("./core/initConfigs");
38
+ var import_initPlugins = require("./core/initPlugins");
39
+ function webpackProvider({
40
+ rsbuildConfig: originalRsbuildConfig
41
+ }) {
42
+ const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(originalRsbuildConfig);
43
+ return async ({ pluginStore, rsbuildOptions, plugins }) => {
44
+ const context = await (0, import_createContext.createContext)(rsbuildOptions, rsbuildConfig);
45
+ const pluginAPI = (0, import_initPlugins.getPluginAPI)({ context, pluginStore });
46
+ context.pluginAPI = pluginAPI;
47
+ return {
48
+ bundler: "webpack",
49
+ pluginAPI,
50
+ publicContext: (0, import_shared.createPublicContext)(context),
51
+ async applyDefaultPlugins() {
52
+ pluginStore.addPlugins(await (0, import_plugin.applyDefaultPlugins)(plugins));
53
+ },
54
+ async initConfigs() {
55
+ const { webpackConfigs } = await (0, import_initConfigs.initConfigs)({
56
+ context,
57
+ pluginStore,
58
+ rsbuildOptions
59
+ });
60
+ return webpackConfigs;
61
+ },
62
+ async createCompiler() {
63
+ const { createCompiler } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
64
+ const { webpackConfigs } = await (0, import_initConfigs.initConfigs)({
65
+ context,
66
+ pluginStore,
67
+ rsbuildOptions
68
+ });
69
+ return createCompiler({ context, webpackConfigs });
70
+ },
71
+ async startDevServer(options) {
72
+ const { startDevServer } = await Promise.resolve().then(() => __toESM(require("./core/startDevServer")));
73
+ return startDevServer(
74
+ { context, pluginStore, rsbuildOptions },
75
+ options
76
+ );
77
+ },
78
+ async preview() {
79
+ return (0, import_shared.startProdServer)(context, context.config);
80
+ },
81
+ async build(options) {
82
+ const { build: buildImpl, webpackBuild } = await Promise.resolve().then(() => __toESM(require("./core/build")));
83
+ return buildImpl(
84
+ { context, pluginStore, rsbuildOptions },
85
+ options,
86
+ webpackBuild
87
+ );
88
+ },
89
+ async inspectConfig(inspectOptions) {
90
+ const { inspectConfig } = await Promise.resolve().then(() => __toESM(require("./core/inspectConfig")));
91
+ return await inspectConfig({
92
+ context,
93
+ pluginStore,
94
+ rsbuildOptions,
95
+ inspectOptions
96
+ });
97
+ }
98
+ };
99
+ };
100
+ }
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ webpackProvider
104
+ });
@@ -0,0 +1 @@
1
+ export declare const getCompiledPath: (packageName: string) => string;
@@ -0,0 +1,38 @@
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 fs_exports = {};
20
+ __export(fs_exports, {
21
+ getCompiledPath: () => getCompiledPath
22
+ });
23
+ module.exports = __toCommonJS(fs_exports);
24
+ var import_path = require("path");
25
+ var import_shared = require("@rsbuild/shared");
26
+ var import_fs_extra = require("@rsbuild/shared/fs-extra");
27
+ const getCompiledPath = (packageName) => {
28
+ const providerCompilerPath = (0, import_path.join)(__dirname, "../../compiled", packageName);
29
+ if (import_fs_extra.fs.existsSync(providerCompilerPath)) {
30
+ return providerCompilerPath;
31
+ } else {
32
+ return (0, import_shared.getSharedPkgCompiledPath)(packageName);
33
+ }
34
+ };
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ getCompiledPath
38
+ });
@@ -0,0 +1 @@
1
+ export * from './fs';
@@ -0,0 +1,22 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var shared_exports = {};
17
+ module.exports = __toCommonJS(shared_exports);
18
+ __reExport(shared_exports, require("./fs"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./fs")
22
+ });