@rsbuild/core 0.6.14 → 0.7.0-beta.0

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 (90) hide show
  1. package/compiled/css-loader/api.js +85 -0
  2. package/compiled/css-loader/getUrl.js +26 -0
  3. package/compiled/css-loader/index.d.ts +1 -0
  4. package/compiled/css-loader/index.js +2187 -0
  5. package/compiled/css-loader/license +20 -0
  6. package/compiled/css-loader/noSourceMaps.js +5 -0
  7. package/compiled/css-loader/package.json +1 -0
  8. package/compiled/css-loader/sourceMaps.js +16 -0
  9. package/compiled/http-compression/index.js +2 -2
  10. package/compiled/http-compression/package.json +1 -1
  11. package/compiled/less-loader/index.d.ts +1 -0
  12. package/compiled/less-loader/index.js +414 -0
  13. package/compiled/less-loader/license +20 -0
  14. package/compiled/less-loader/package.json +1 -0
  15. package/compiled/postcss-load-config/292.index.js +2533 -0
  16. package/compiled/postcss-load-config/344.index.js +21 -0
  17. package/compiled/postcss-load-config/index.d.ts +1 -0
  18. package/compiled/postcss-load-config/index.js +1201 -0
  19. package/compiled/postcss-load-config/license +20 -0
  20. package/compiled/postcss-load-config/package.json +1 -0
  21. package/compiled/postcss-loader/index.d.ts +1 -0
  22. package/compiled/postcss-loader/index.js +200173 -0
  23. package/compiled/postcss-loader/license +20 -0
  24. package/compiled/postcss-loader/package.json +1 -0
  25. package/compiled/postcss-value-parser/index.d.ts +1 -0
  26. package/compiled/postcss-value-parser/index.js +624 -0
  27. package/compiled/postcss-value-parser/license +22 -0
  28. package/compiled/postcss-value-parser/package.json +1 -0
  29. package/compiled/resolve-url-loader/index.d.ts +1 -0
  30. package/compiled/resolve-url-loader/index.js +5719 -0
  31. package/compiled/resolve-url-loader/license +21 -0
  32. package/compiled/resolve-url-loader/package.json +1 -0
  33. package/compiled/style-loader/index.d.ts +1 -0
  34. package/compiled/style-loader/index.js +513 -0
  35. package/compiled/style-loader/license +20 -0
  36. package/compiled/style-loader/package.json +1 -0
  37. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  38. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  39. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  40. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  41. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  42. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  43. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  44. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  45. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  46. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  47. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  48. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  49. package/dist/cli/commands.js +1 -1
  50. package/dist/cli/prepare.js +1 -1
  51. package/dist/config.js +0 -1
  52. package/dist/createContext.js +1 -1
  53. package/dist/index.js +1 -1
  54. package/dist/internal.d.ts +2 -2
  55. package/dist/internal.js +8 -8
  56. package/dist/{htmlUtils.d.ts → pluginHelper.d.ts} +4 -1
  57. package/dist/pluginHelper.js +66 -0
  58. package/dist/plugins/css.d.ts +19 -0
  59. package/dist/plugins/css.js +257 -0
  60. package/dist/plugins/index.d.ts +4 -0
  61. package/dist/plugins/index.js +4 -0
  62. package/dist/{provider/plugins → plugins}/less.d.ts +1 -1
  63. package/dist/{provider/plugins → plugins}/less.js +45 -10
  64. package/dist/plugins/manifest.js +1 -1
  65. package/dist/{provider/plugins → plugins}/output.d.ts +1 -1
  66. package/dist/{provider/plugins → plugins}/output.js +21 -14
  67. package/dist/plugins/performance.js +5 -11
  68. package/dist/plugins/resourceHints.js +17 -22
  69. package/dist/plugins/sass.d.ts +18 -0
  70. package/dist/{provider/plugins → plugins}/sass.js +83 -12
  71. package/dist/provider/plugins/swc.d.ts +0 -2
  72. package/dist/provider/plugins/swc.js +1 -3
  73. package/dist/provider/provider.js +4 -4
  74. package/dist/provider/rspackConfig.js +2 -2
  75. package/dist/rspack/HtmlAppIconPlugin.js +2 -2
  76. package/dist/rspack/HtmlBasicPlugin.js +2 -2
  77. package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
  78. package/dist/rspack/ignoreCssLoader.d.ts +2 -0
  79. package/dist/{htmlUtils.js → rspack/ignoreCssLoader.js} +10 -21
  80. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +3 -3
  81. package/package.json +13 -4
  82. package/dist/provider/css-modules-typescript-pre-loader/index.d.ts +0 -6
  83. package/dist/provider/css-modules-typescript-pre-loader/index.js +0 -84
  84. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.d.ts +0 -11
  85. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.js +0 -66
  86. package/dist/provider/plugins/css.d.ts +0 -17
  87. package/dist/provider/plugins/css.js +0 -202
  88. package/dist/provider/plugins/sass.d.ts +0 -2
  89. package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +0 -6
  90. package/dist/rspack/RemoveCssSourcemapPlugin.js +0 -55
@@ -1,202 +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 css_exports = {};
30
- __export(css_exports, {
31
- applyBaseCSSRule: () => applyBaseCSSRule,
32
- applyCSSModuleRule: () => applyCSSModuleRule,
33
- enableNativeCss: () => enableNativeCss,
34
- pluginCss: () => pluginCss
35
- });
36
- module.exports = __toCommonJS(css_exports);
37
- var import_node_path = __toESM(require("node:path"));
38
- var import_shared = require("@rsbuild/shared");
39
- const enableNativeCss = (config) => !config.output.injectStyles;
40
- async function applyBaseCSSRule({
41
- rule,
42
- config,
43
- context,
44
- utils: { target, isProd, isServer, isWebWorker, CHAIN_ID },
45
- importLoaders = 1
46
- }) {
47
- const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);
48
- const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
49
- context.rootPath,
50
- config,
51
- target
52
- );
53
- if (!enableNativeCss(config)) {
54
- const localIdentName = (0, import_shared.getCssModuleLocalIdentName)(config, isProd);
55
- const cssLoaderOptions = (0, import_shared.getCssLoaderOptions)({
56
- config,
57
- importLoaders,
58
- isServer,
59
- isWebWorker,
60
- localIdentName
61
- });
62
- if (!isServer && !isWebWorker) {
63
- const styleLoaderOptions = (0, import_shared.mergeChainedOptions)({
64
- defaults: {},
65
- options: config.tools.styleLoader
66
- });
67
- rule.use(CHAIN_ID.USE.STYLE).loader((0, import_shared.getSharedPkgCompiledPath)("style-loader")).options(styleLoaderOptions).end();
68
- if (enableCSSModuleTS && cssLoaderOptions.modules) {
69
- rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(
70
- (0, import_shared.resolvePackage)(
71
- "@rsbuild/shared/css-modules-typescript-loader",
72
- __dirname
73
- )
74
- ).options({
75
- modules: cssLoaderOptions.modules
76
- }).end();
77
- }
78
- } else {
79
- rule.use(CHAIN_ID.USE.IGNORE_CSS).loader((0, import_shared.resolvePackage)("@rsbuild/shared/ignore-css-loader", __dirname)).end();
80
- }
81
- rule.use(CHAIN_ID.USE.CSS).loader((0, import_shared.getSharedPkgCompiledPath)("css-loader")).options(cssLoaderOptions).end();
82
- } else {
83
- if (!isServer && !isWebWorker && enableCSSModuleTS) {
84
- const { cssModules } = config.output;
85
- rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(import_node_path.default.resolve(__dirname, "../css-modules-typescript-pre-loader")).options({
86
- modules: {
87
- exportLocalsConvention: cssModules.exportLocalsConvention,
88
- auto: cssModules.auto
89
- }
90
- }).end();
91
- }
92
- rule.type("css");
93
- }
94
- if (!isServer && !isWebWorker) {
95
- const postcssLoaderOptions = await (0, import_shared.getPostcssLoaderOptions)({
96
- browserslist,
97
- config,
98
- root: context.rootPath
99
- });
100
- rule.use(CHAIN_ID.USE.POSTCSS).loader((0, import_shared.getSharedPkgCompiledPath)("postcss-loader")).options(postcssLoaderOptions).end();
101
- }
102
- rule.merge({ sideEffects: true });
103
- rule.resolve.preferRelative(true);
104
- }
105
- const applyCSSModuleRule = (rules, ruleTest, config) => {
106
- if (!rules || !enableNativeCss(config)) {
107
- return;
108
- }
109
- const ruleIndex = rules.findIndex(
110
- (r) => r && r !== "..." && r.test === ruleTest
111
- );
112
- if (ruleIndex === -1) {
113
- return;
114
- }
115
- const cssModulesAuto = config.output.cssModules.auto;
116
- if (!cssModulesAuto) {
117
- return;
118
- }
119
- const rule = rules[ruleIndex];
120
- const { test, type, ...rest } = rule;
121
- rules[ruleIndex] = {
122
- test: ruleTest,
123
- oneOf: [
124
- {
125
- ...rest,
126
- test: typeof cssModulesAuto !== "boolean" ? cssModulesAuto : (
127
- // auto: true
128
- import_shared.CSS_MODULES_REGEX
129
- ),
130
- type: "css/module"
131
- },
132
- {
133
- ...rest,
134
- type: "css"
135
- }
136
- ]
137
- };
138
- };
139
- const pluginCss = () => {
140
- return {
141
- name: "rsbuild:css",
142
- setup(api) {
143
- api.modifyBundlerChain(async (chain, utils) => {
144
- const config = api.getNormalizedConfig();
145
- const rule = chain.module.rule(utils.CHAIN_ID.RULE.CSS);
146
- rule.test(import_shared.CSS_REGEX);
147
- await applyBaseCSSRule({
148
- rule,
149
- utils,
150
- config,
151
- context: api.context
152
- });
153
- const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, utils.target);
154
- if (!config.output.sourceMap.css && enableExtractCSS) {
155
- const { RemoveCssSourcemapPlugin } = await Promise.resolve().then(() => __toESM(require("../../rspack/RemoveCssSourcemapPlugin")));
156
- chain.plugin("remove-css-sourcemap").use(RemoveCssSourcemapPlugin, []);
157
- }
158
- });
159
- api.modifyRspackConfig(
160
- async (rspackConfig, { isProd, isServer, isWebWorker }) => {
161
- var _a, _b;
162
- const config = api.getNormalizedConfig();
163
- if (!enableNativeCss(config)) {
164
- rspackConfig.experiments || (rspackConfig.experiments = {});
165
- rspackConfig.experiments.css = false;
166
- return;
167
- }
168
- let localIdentName = config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
169
- (isProd ? "[local]-[hash:6]" : "[path][name]__[local]-[hash:6]");
170
- if (localIdentName.includes(":base64")) {
171
- import_shared.logger.warn(
172
- `Custom hashDigest in output.cssModules.localIdentName is currently not supported when using Rspack, the 'base64' will be ignored.`
173
- );
174
- localIdentName = localIdentName.replace(":base64", "");
175
- }
176
- rspackConfig.module || (rspackConfig.module = {});
177
- (_a = rspackConfig.module).generator || (_a.generator = {});
178
- rspackConfig.module.generator["css/module"] = {
179
- exportsConvention: (0, import_shared.kebabCase)(
180
- config.output.cssModules.exportLocalsConvention
181
- ),
182
- localIdentName,
183
- exportsOnly: isServer || isWebWorker
184
- };
185
- (_b = rspackConfig.module).parser || (_b.parser = {});
186
- rspackConfig.module.parser["css/module"] = {
187
- namedExports: false
188
- };
189
- const rules = rspackConfig.module?.rules;
190
- applyCSSModuleRule(rules, import_shared.CSS_REGEX, config);
191
- }
192
- );
193
- }
194
- };
195
- };
196
- // Annotate the CommonJS export names for ESM import in node:
197
- 0 && (module.exports = {
198
- applyBaseCSSRule,
199
- applyCSSModuleRule,
200
- enableNativeCss,
201
- pluginCss
202
- });
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '../../types';
2
- export declare function pluginSass(): RsbuildPlugin;
@@ -1,6 +0,0 @@
1
- import type { Compiler } from '@rspack/core';
2
- export declare class RemoveCssSourcemapPlugin {
3
- name: string;
4
- constructor();
5
- apply(compiler: Compiler): void;
6
- }
@@ -1,55 +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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => {
21
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
22
- return value;
23
- };
24
- var RemoveCssSourcemapPlugin_exports = {};
25
- __export(RemoveCssSourcemapPlugin_exports, {
26
- RemoveCssSourcemapPlugin: () => RemoveCssSourcemapPlugin
27
- });
28
- module.exports = __toCommonJS(RemoveCssSourcemapPlugin_exports);
29
- class RemoveCssSourcemapPlugin {
30
- constructor() {
31
- __publicField(this, "name");
32
- this.name = "RemoveCssSourcemapPlugin";
33
- }
34
- apply(compiler) {
35
- compiler.hooks.compilation.tap(this.name, (compilation) => {
36
- compilation.hooks.processAssets.tap(
37
- {
38
- name: this.name,
39
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
40
- },
41
- () => {
42
- for (const name of Object.keys(compilation.assets)) {
43
- if (name.endsWith(".css.map")) {
44
- compilation.deleteAsset(name);
45
- }
46
- }
47
- }
48
- );
49
- });
50
- }
51
- }
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- RemoveCssSourcemapPlugin
55
- });