@rspack/core 0.5.9 → 0.6.0-canary-f5973db-20240409131230
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.
- package/dist/Compilation.d.ts +3 -8
- package/dist/Compilation.js +6 -10
- package/dist/Compiler.d.ts +3 -8
- package/dist/Compiler.js +165 -144
- package/dist/ContextModuleFactory.d.ts +4 -8
- package/dist/ContextModuleFactory.js +26 -3
- package/dist/ExecuteModulePlugin.js +2 -2
- package/dist/Module.d.ts +20 -1
- package/dist/Module.js +1 -0
- package/dist/NormalModuleFactory.d.ts +8 -23
- package/dist/NormalModuleFactory.js +6 -4
- package/dist/Stats.js +2 -2
- package/dist/builtin-plugin/APIPlugin.d.ts +10 -0
- package/dist/builtin-plugin/APIPlugin.js +6 -0
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +10 -0
- package/dist/builtin-plugin/CssModulesPlugin.js +6 -0
- package/dist/builtin-plugin/EntryPlugin.d.ts +1 -0
- package/dist/builtin-plugin/EntryPlugin.js +3 -2
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +3 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +2 -1
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -0
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +222 -0
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +2 -0
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.js +38 -0
- package/dist/builtin-plugin/css-extract/index.d.ts +22 -0
- package/dist/builtin-plugin/css-extract/index.js +109 -0
- package/dist/builtin-plugin/css-extract/loader-options.json +32 -0
- package/dist/builtin-plugin/css-extract/loader.d.ts +15 -0
- package/dist/builtin-plugin/css-extract/loader.js +191 -0
- package/dist/builtin-plugin/css-extract/plugin-options.json +79 -0
- package/dist/builtin-plugin/css-extract/utils.d.ts +5 -0
- package/dist/builtin-plugin/css-extract/utils.js +51 -0
- package/dist/builtin-plugin/index.d.ts +4 -6
- package/dist/builtin-plugin/index.js +3 -15
- package/dist/config/adapter.js +58 -8
- package/dist/config/adapterRuleUse.d.ts +2 -2
- package/dist/config/defaults.js +65 -35
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +9 -1
- package/dist/config/zod.d.ts +706 -23
- package/dist/config/zod.js +47 -4
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- package/dist/exports.d.ts +67 -11
- package/dist/exports.js +7 -1
- package/dist/lib/EntryOptionPlugin.js +1 -1
- package/dist/lib/NormalModuleReplacementPlugin.d.ts +19 -0
- package/dist/lib/NormalModuleReplacementPlugin.js +75 -0
- package/dist/lite-tapable/index.d.ts +25 -0
- package/dist/lite-tapable/index.js +70 -1
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -21
- package/dist/util/comparators.d.ts +1 -1
- package/package.json +10 -7
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Mini CSS Extract Plugin Loader options",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"publicPath": {
|
|
7
|
+
"anyOf": [
|
|
8
|
+
{
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"instanceof": "Function"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"description": "Specifies a custom public path for the external resources like images, files, etc inside CSS.",
|
|
16
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#publicpath"
|
|
17
|
+
},
|
|
18
|
+
"emit": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"description": "If true, emits a file (writes a file to the filesystem). If false, the plugin will extract the CSS but will not emit the file",
|
|
21
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#emit"
|
|
22
|
+
},
|
|
23
|
+
"esModule": {
|
|
24
|
+
"type": "boolean",
|
|
25
|
+
"description": "Generates JS modules that use the ES modules syntax.",
|
|
26
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#esmodule"
|
|
27
|
+
},
|
|
28
|
+
"layer": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LoaderDefinition } from "../..";
|
|
2
|
+
export declare const MODULE_TYPE = "css/mini-extract";
|
|
3
|
+
export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
4
|
+
export declare const ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/";
|
|
5
|
+
export declare const BASE_URI = "webpack://";
|
|
6
|
+
export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
7
|
+
export interface LoaderOptions {
|
|
8
|
+
publicPath?: string | ((resourcePath: string, context: string) => string);
|
|
9
|
+
emit?: boolean;
|
|
10
|
+
esModule?: boolean;
|
|
11
|
+
layer?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const loader: LoaderDefinition;
|
|
14
|
+
export declare const pitch: LoaderDefinition["pitch"];
|
|
15
|
+
export default loader;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.pitch = exports.SINGLE_DOT_PATH_SEGMENT = exports.BASE_URI = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = void 0;
|
|
7
|
+
const loader_options_json_1 = __importDefault(require("./loader-options.json"));
|
|
8
|
+
const index_1 = require("./index");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
exports.MODULE_TYPE = "css/mini-extract";
|
|
12
|
+
exports.AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
13
|
+
exports.ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/";
|
|
14
|
+
exports.BASE_URI = "webpack://";
|
|
15
|
+
exports.SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
16
|
+
const SERIALIZE_SEP = "__RSPACK_CSS_EXTRACT_SEP__";
|
|
17
|
+
function hotLoader(content, context) {
|
|
18
|
+
const accept = context.locals
|
|
19
|
+
? ""
|
|
20
|
+
: "module.hot.accept(undefined, cssReload);";
|
|
21
|
+
return `${content}
|
|
22
|
+
if(module.hot) {
|
|
23
|
+
// ${Date.now()}
|
|
24
|
+
var cssReload = require(${(0, utils_1.stringifyRequest)(context.loaderContext, path_1.default.join(__dirname, "./hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({
|
|
25
|
+
...context.options,
|
|
26
|
+
locals: !!context.locals
|
|
27
|
+
})});
|
|
28
|
+
module.hot.dispose(cssReload);
|
|
29
|
+
${accept}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
const loader = function loader(content) {
|
|
34
|
+
if (this._compiler &&
|
|
35
|
+
this._compiler.options &&
|
|
36
|
+
this._compiler.options.experiments &&
|
|
37
|
+
this._compiler.options.experiments.css) {
|
|
38
|
+
return content;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const pitch = function (request, _, data) {
|
|
42
|
+
if (this._compiler &&
|
|
43
|
+
this._compiler.options &&
|
|
44
|
+
this._compiler.options.experiments &&
|
|
45
|
+
this._compiler.options.experiments.css) {
|
|
46
|
+
let e = new Error("You can't use `experiments.css` and `css-extract-rspack-plugin` together, please set `experiments.css` to `false`");
|
|
47
|
+
e.stack = undefined;
|
|
48
|
+
this.emitWarning(e);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (this._compiler &&
|
|
52
|
+
this._compiler.options &&
|
|
53
|
+
this._compiler.options.experiments &&
|
|
54
|
+
this._compiler.options.experiments.rspackFuture &&
|
|
55
|
+
this._compiler.options.experiments.rspackFuture.newTreeshaking === false) {
|
|
56
|
+
this.emitError(new Error("Cannot use CssExtractRspackPlugin without newTreeshaking"));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const options = this.getOptions(loader_options_json_1.default);
|
|
60
|
+
const emit = typeof options.emit !== "undefined" ? options.emit : true;
|
|
61
|
+
const callback = this.async();
|
|
62
|
+
const filepath = this.resourcePath;
|
|
63
|
+
let { publicPath } =
|
|
64
|
+
/** @type {Compilation} */
|
|
65
|
+
this._compilation.outputOptions;
|
|
66
|
+
if (typeof options.publicPath === "string") {
|
|
67
|
+
// eslint-disable-next-line prefer-destructuring
|
|
68
|
+
publicPath = options.publicPath;
|
|
69
|
+
}
|
|
70
|
+
else if (typeof options.publicPath === "function") {
|
|
71
|
+
publicPath = options.publicPath(this.resourcePath, this.rootContext);
|
|
72
|
+
}
|
|
73
|
+
if (publicPath === "auto") {
|
|
74
|
+
publicPath = exports.AUTO_PUBLIC_PATH;
|
|
75
|
+
}
|
|
76
|
+
let publicPathForExtract;
|
|
77
|
+
if (typeof publicPath === "string") {
|
|
78
|
+
const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
|
|
79
|
+
publicPathForExtract = isAbsolutePublicPath
|
|
80
|
+
? publicPath
|
|
81
|
+
: `${exports.ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, exports.SINGLE_DOT_PATH_SEGMENT)}`;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
publicPathForExtract = publicPath;
|
|
85
|
+
}
|
|
86
|
+
const handleExports = (originalExports) => {
|
|
87
|
+
/** @type {Locals | undefined} */
|
|
88
|
+
let locals;
|
|
89
|
+
let namedExport;
|
|
90
|
+
const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
|
|
91
|
+
let dependencies = [];
|
|
92
|
+
try {
|
|
93
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
94
|
+
const exports = originalExports.__esModule
|
|
95
|
+
? originalExports.default
|
|
96
|
+
: originalExports;
|
|
97
|
+
namedExport =
|
|
98
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
99
|
+
originalExports.__esModule &&
|
|
100
|
+
(!originalExports.default || !("locals" in originalExports.default));
|
|
101
|
+
if (namedExport) {
|
|
102
|
+
Object.keys(originalExports).forEach(key => {
|
|
103
|
+
if (key !== "default") {
|
|
104
|
+
if (!locals) {
|
|
105
|
+
locals = {};
|
|
106
|
+
}
|
|
107
|
+
/** @type {Locals} */ locals[key] = originalExports[key];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
locals = exports && exports.locals;
|
|
113
|
+
}
|
|
114
|
+
if (Array.isArray(exports) && emit) {
|
|
115
|
+
const identifierCountMap = new Map();
|
|
116
|
+
dependencies = exports
|
|
117
|
+
.map(([id, content, media, sourceMap, supports, layer]) => {
|
|
118
|
+
let identifier = id;
|
|
119
|
+
let context = this.rootContext;
|
|
120
|
+
const count = identifierCountMap.get(identifier) || 0;
|
|
121
|
+
identifierCountMap.set(identifier, count + 1);
|
|
122
|
+
return {
|
|
123
|
+
identifier,
|
|
124
|
+
context,
|
|
125
|
+
content,
|
|
126
|
+
media,
|
|
127
|
+
supports,
|
|
128
|
+
layer,
|
|
129
|
+
identifierIndex: count,
|
|
130
|
+
sourceMap: sourceMap
|
|
131
|
+
? JSON.stringify(sourceMap)
|
|
132
|
+
: // eslint-disable-next-line no-undefined
|
|
133
|
+
undefined,
|
|
134
|
+
filepath
|
|
135
|
+
};
|
|
136
|
+
})
|
|
137
|
+
.filter(item => item !== null);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (e) {
|
|
141
|
+
callback(e);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const result = locals
|
|
145
|
+
? namedExport
|
|
146
|
+
? Object.keys(locals)
|
|
147
|
+
.map(key => `\nexport var ${key} = ${(0, utils_1.stringifyLocal)(
|
|
148
|
+
/** @type {Locals} */ locals[key])};`)
|
|
149
|
+
.join("")
|
|
150
|
+
: `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};`
|
|
151
|
+
: esModule
|
|
152
|
+
? `\nexport {};`
|
|
153
|
+
: "";
|
|
154
|
+
let resultSource = `// extracted by ${index_1.CssExtractRspackPlugin.pluginName}`;
|
|
155
|
+
// only attempt hotreloading if the css is actually used for something other than hash values
|
|
156
|
+
resultSource +=
|
|
157
|
+
this.hot && emit
|
|
158
|
+
? hotLoader(result, { loaderContext: this, options, locals: locals })
|
|
159
|
+
: result;
|
|
160
|
+
const additionalData = { ...data };
|
|
161
|
+
if (dependencies.length > 0) {
|
|
162
|
+
additionalData[index_1.CssExtractRspackPlugin.pluginName] = dependencies
|
|
163
|
+
.map(dep => {
|
|
164
|
+
return [
|
|
165
|
+
dep.identifier,
|
|
166
|
+
dep.content,
|
|
167
|
+
dep.context,
|
|
168
|
+
dep.media,
|
|
169
|
+
dep.supports,
|
|
170
|
+
dep.sourceMap,
|
|
171
|
+
dep.identifierIndex,
|
|
172
|
+
dep.filepath
|
|
173
|
+
].join(SERIALIZE_SEP);
|
|
174
|
+
})
|
|
175
|
+
.join(SERIALIZE_SEP);
|
|
176
|
+
}
|
|
177
|
+
callback(null, resultSource, undefined, additionalData);
|
|
178
|
+
};
|
|
179
|
+
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
180
|
+
publicPath: /** @type {string} */ publicPathForExtract,
|
|
181
|
+
baseUri: `${exports.BASE_URI}/`
|
|
182
|
+
}, (error, exports) => {
|
|
183
|
+
if (error) {
|
|
184
|
+
callback(error);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
handleExports(exports);
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
exports.pitch = pitch;
|
|
191
|
+
exports.default = loader;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Mini CSS Extract Plugin options",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"additionalProperties": false,
|
|
5
|
+
"properties": {
|
|
6
|
+
"filename": {
|
|
7
|
+
"anyOf": [
|
|
8
|
+
{
|
|
9
|
+
"type": "string",
|
|
10
|
+
"absolutePath": false,
|
|
11
|
+
"minLength": 1
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"instanceof": "Function"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"description": "This option determines the name of each output CSS file.",
|
|
18
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#filename"
|
|
19
|
+
},
|
|
20
|
+
"chunkFilename": {
|
|
21
|
+
"anyOf": [
|
|
22
|
+
{
|
|
23
|
+
"type": "string",
|
|
24
|
+
"absolutePath": false,
|
|
25
|
+
"minLength": 1
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"instanceof": "Function"
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"description": "This option determines the name of non-entry chunk files.",
|
|
32
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#chunkfilename"
|
|
33
|
+
},
|
|
34
|
+
"experimentalUseImportModule": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Enable the experimental importModule approach instead of using child compilers. This uses less memory and is faster.",
|
|
37
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#experimentaluseimportmodule"
|
|
38
|
+
},
|
|
39
|
+
"ignoreOrder": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "Remove Order Warnings.",
|
|
42
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#ignoreorder"
|
|
43
|
+
},
|
|
44
|
+
"insert": {
|
|
45
|
+
"description": "Inserts the `link` tag at the given position for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.",
|
|
46
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#insert",
|
|
47
|
+
"anyOf": [
|
|
48
|
+
{
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"instanceof": "Function"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"attributes": {
|
|
57
|
+
"description": "Adds custom attributes to the `link` tag for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.",
|
|
58
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#attributes",
|
|
59
|
+
"type": "object"
|
|
60
|
+
},
|
|
61
|
+
"linkType": {
|
|
62
|
+
"anyOf": [
|
|
63
|
+
{
|
|
64
|
+
"enum": ["text/css"]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "boolean"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"description": "This option allows loading asynchronous chunks with a custom link type",
|
|
71
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#linktype"
|
|
72
|
+
},
|
|
73
|
+
"runtime": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "Enabled/Disables runtime generation. CSS will be still extracted and can be used for a custom loading methods.",
|
|
76
|
+
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#noRuntime"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LoaderContext } from "../..";
|
|
2
|
+
export declare function isAbsolutePath(str: string): boolean;
|
|
3
|
+
export declare function isRelativePath(str: string): boolean;
|
|
4
|
+
export declare function stringifyRequest(loaderContext: LoaderContext, request: string): string;
|
|
5
|
+
export declare function stringifyLocal(value: any): any;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stringifyLocal = exports.stringifyRequest = exports.isRelativePath = exports.isAbsolutePath = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
function isAbsolutePath(str) {
|
|
9
|
+
return path_1.default.posix.isAbsolute(str) || path_1.default.win32.isAbsolute(str);
|
|
10
|
+
}
|
|
11
|
+
exports.isAbsolutePath = isAbsolutePath;
|
|
12
|
+
const RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
|
|
13
|
+
function isRelativePath(str) {
|
|
14
|
+
return RELATIVE_PATH_REGEXP.test(str);
|
|
15
|
+
}
|
|
16
|
+
exports.isRelativePath = isRelativePath;
|
|
17
|
+
function stringifyRequest(loaderContext, request) {
|
|
18
|
+
if (typeof loaderContext.utils !== "undefined" &&
|
|
19
|
+
typeof loaderContext.utils.contextify === "function") {
|
|
20
|
+
return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
|
|
21
|
+
}
|
|
22
|
+
const splitted = request.split("!");
|
|
23
|
+
const { context } = loaderContext;
|
|
24
|
+
return JSON.stringify(splitted
|
|
25
|
+
.map(part => {
|
|
26
|
+
// First, separate singlePath from query, because the query might contain paths again
|
|
27
|
+
const splittedPart = part.match(/^(.*?)(\?.*)/);
|
|
28
|
+
const query = splittedPart ? splittedPart[2] : "";
|
|
29
|
+
let singlePath = splittedPart ? splittedPart[1] : part;
|
|
30
|
+
if (isAbsolutePath(singlePath) && context) {
|
|
31
|
+
singlePath = path_1.default.relative(context, singlePath);
|
|
32
|
+
if (isAbsolutePath(singlePath)) {
|
|
33
|
+
// If singlePath still matches an absolute path, singlePath was on a different drive than context.
|
|
34
|
+
// In this case, we leave the path platform-specific without replacing any separators.
|
|
35
|
+
// @see https://github.com/webpack/loader-utils/pull/14
|
|
36
|
+
return singlePath + query;
|
|
37
|
+
}
|
|
38
|
+
if (isRelativePath(singlePath) === false) {
|
|
39
|
+
// Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
|
|
40
|
+
singlePath = `./${singlePath}`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return singlePath.replace(/\\/g, "/") + query;
|
|
44
|
+
})
|
|
45
|
+
.join("!"));
|
|
46
|
+
}
|
|
47
|
+
exports.stringifyRequest = stringifyRequest;
|
|
48
|
+
function stringifyLocal(value) {
|
|
49
|
+
return typeof value === "function" ? value.toString() : JSON.stringify(value);
|
|
50
|
+
}
|
|
51
|
+
exports.stringifyLocal = stringifyLocal;
|
|
@@ -46,19 +46,17 @@ export * from "./FlagDependencyUsagePlugin";
|
|
|
46
46
|
export * from "./MangleExportsPlugin";
|
|
47
47
|
export * from "./BundlerInfoRspackPlugin";
|
|
48
48
|
export * from "./ModuleConcatenationPlugin";
|
|
49
|
+
export * from "./CssModulesPlugin";
|
|
50
|
+
export * from "./APIPlugin";
|
|
49
51
|
export * from "./HtmlRspackPlugin";
|
|
50
52
|
export * from "./CopyRspackPlugin";
|
|
51
53
|
export * from "./SwcJsMinimizerPlugin";
|
|
52
54
|
export * from "./SwcCssMinimizerPlugin";
|
|
53
55
|
export * from "./JsLoaderRspackPlugin";
|
|
54
|
-
|
|
56
|
+
export * from "./css-extract";
|
|
57
|
+
import { RawBuiltins } from "@rspack/binding";
|
|
55
58
|
import { RspackOptionsNormalized } from "..";
|
|
56
|
-
type BuiltinsCssConfig = {
|
|
57
|
-
modules?: Partial<RawCssModulesConfig>;
|
|
58
|
-
namedExports?: boolean;
|
|
59
|
-
};
|
|
60
59
|
export interface Builtins {
|
|
61
|
-
css?: BuiltinsCssConfig;
|
|
62
60
|
treeShaking?: boolean | "module";
|
|
63
61
|
}
|
|
64
62
|
export declare function deprecated_resolveBuiltins(builtins: Builtins, options: RspackOptionsNormalized): RawBuiltins;
|
|
@@ -64,11 +64,14 @@ __exportStar(require("./FlagDependencyUsagePlugin"), exports);
|
|
|
64
64
|
__exportStar(require("./MangleExportsPlugin"), exports);
|
|
65
65
|
__exportStar(require("./BundlerInfoRspackPlugin"), exports);
|
|
66
66
|
__exportStar(require("./ModuleConcatenationPlugin"), exports);
|
|
67
|
+
__exportStar(require("./CssModulesPlugin"), exports);
|
|
68
|
+
__exportStar(require("./APIPlugin"), exports);
|
|
67
69
|
__exportStar(require("./HtmlRspackPlugin"), exports);
|
|
68
70
|
__exportStar(require("./CopyRspackPlugin"), exports);
|
|
69
71
|
__exportStar(require("./SwcJsMinimizerPlugin"), exports);
|
|
70
72
|
__exportStar(require("./SwcCssMinimizerPlugin"), exports);
|
|
71
73
|
__exportStar(require("./JsLoaderRspackPlugin"), exports);
|
|
74
|
+
__exportStar(require("./css-extract"), exports);
|
|
72
75
|
function resolveTreeShaking(treeShaking, production) {
|
|
73
76
|
return treeShaking !== undefined
|
|
74
77
|
? treeShaking.toString()
|
|
@@ -77,23 +80,8 @@ function resolveTreeShaking(treeShaking, production) {
|
|
|
77
80
|
: "false";
|
|
78
81
|
}
|
|
79
82
|
function deprecated_resolveBuiltins(builtins, options) {
|
|
80
|
-
var _a, _b;
|
|
81
83
|
const production = options.mode === "production" || !options.mode;
|
|
82
84
|
return {
|
|
83
|
-
// TODO: discuss with webpack, this should move to css generator options
|
|
84
|
-
css: options.experiments.css
|
|
85
|
-
? {
|
|
86
|
-
modules: {
|
|
87
|
-
localsConvention: "asIs",
|
|
88
|
-
localIdentName: production
|
|
89
|
-
? "[hash]"
|
|
90
|
-
: "[path][name][ext]__[local]",
|
|
91
|
-
exportsOnly: false,
|
|
92
|
-
...(_a = builtins.css) === null || _a === void 0 ? void 0 : _a.modules
|
|
93
|
-
},
|
|
94
|
-
namedExports: (_b = builtins.css) === null || _b === void 0 ? void 0 : _b.namedExports
|
|
95
|
-
}
|
|
96
|
-
: undefined,
|
|
97
85
|
treeShaking: resolveTreeShaking(builtins.treeShaking, production)
|
|
98
86
|
};
|
|
99
87
|
}
|
package/dist/config/adapter.js
CHANGED
|
@@ -336,8 +336,7 @@ const getRawModuleRule = (rule, path, options) => {
|
|
|
336
336
|
if (rule.resourceQuery && !tryMatch(query, rule.resourceQuery)) {
|
|
337
337
|
return false;
|
|
338
338
|
}
|
|
339
|
-
if (rule.resourceFragment &&
|
|
340
|
-
!tryMatch(fragment, rule.resourceFragment)) {
|
|
339
|
+
if (rule.resourceFragment && !tryMatch(fragment, rule.resourceFragment)) {
|
|
341
340
|
return false;
|
|
342
341
|
}
|
|
343
342
|
return true;
|
|
@@ -409,9 +408,26 @@ function getRawParserOptions(parser, type) {
|
|
|
409
408
|
javascript: getRawJavascriptParserOptions(parser)
|
|
410
409
|
};
|
|
411
410
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
411
|
+
else if (type === "css") {
|
|
412
|
+
return {
|
|
413
|
+
type: "css",
|
|
414
|
+
css: getRawCssParserOptions(parser)
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
else if (type === "css/auto") {
|
|
418
|
+
return {
|
|
419
|
+
type: "css/auto",
|
|
420
|
+
cssAuto: getRawCssParserOptions(parser)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
else if (type === "css/module") {
|
|
424
|
+
return {
|
|
425
|
+
type: "css/module",
|
|
426
|
+
cssModule: getRawCssParserOptions(parser)
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
// FIXME: shouldn't depend on module type, for example: `rules: [{ test: /\.css/, generator: {..} }]` will error
|
|
430
|
+
throw new Error(`unreachable: unknow module type: ${type}`);
|
|
415
431
|
}
|
|
416
432
|
function getRawJavascriptParserOptions(parser) {
|
|
417
433
|
var _a, _b, _c, _d, _e;
|
|
@@ -444,6 +460,11 @@ function getRawAssetParserDataUrl(dataUrlCondition) {
|
|
|
444
460
|
}
|
|
445
461
|
throw new Error(`unreachable: AssetParserDataUrl type should be one of "options", but got ${dataUrlCondition}`);
|
|
446
462
|
}
|
|
463
|
+
function getRawCssParserOptions(parser) {
|
|
464
|
+
return {
|
|
465
|
+
namedExports: parser.namedExports
|
|
466
|
+
};
|
|
467
|
+
}
|
|
447
468
|
function getRawGeneratorOptions(generator, type) {
|
|
448
469
|
if (type === "asset") {
|
|
449
470
|
return {
|
|
@@ -467,9 +488,25 @@ function getRawGeneratorOptions(generator, type) {
|
|
|
467
488
|
: undefined
|
|
468
489
|
};
|
|
469
490
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
491
|
+
if (type === "css") {
|
|
492
|
+
return {
|
|
493
|
+
type: "css",
|
|
494
|
+
css: getRawCssGeneratorOptions(generator)
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
if (type === "css/auto") {
|
|
498
|
+
return {
|
|
499
|
+
type: "css/auto",
|
|
500
|
+
cssAuto: getRawCssAutoOrModuleGeneratorOptions(generator)
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
if (type === "css/module") {
|
|
504
|
+
return {
|
|
505
|
+
type: "css/module",
|
|
506
|
+
cssModule: getRawCssAutoOrModuleGeneratorOptions(generator)
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
throw new Error(`unreachable: unknow module type: ${type}`);
|
|
473
510
|
}
|
|
474
511
|
function getRawAssetGeneratorOptions(options) {
|
|
475
512
|
return {
|
|
@@ -503,6 +540,19 @@ function getRawAssetGeneratorDataUrl(dataUrl) {
|
|
|
503
540
|
}
|
|
504
541
|
throw new Error(`unreachable: AssetGeneratorDataUrl type should be one of "options", "function", but got ${dataUrl}`);
|
|
505
542
|
}
|
|
543
|
+
function getRawCssGeneratorOptions(options) {
|
|
544
|
+
return {
|
|
545
|
+
exportsConvention: options.exportsConvention,
|
|
546
|
+
exportsOnly: options.exportsOnly
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function getRawCssAutoOrModuleGeneratorOptions(options) {
|
|
550
|
+
return {
|
|
551
|
+
localIdentName: options.localIdentName,
|
|
552
|
+
exportsConvention: options.exportsConvention,
|
|
553
|
+
exportsOnly: options.exportsOnly
|
|
554
|
+
};
|
|
555
|
+
}
|
|
506
556
|
function getRawOptimization(optimization) {
|
|
507
557
|
(0, assert_1.default)(!(0, util_1.isNil)(optimization.removeAvailableModules) &&
|
|
508
558
|
!(0, util_1.isNil)(optimization.sideEffects) &&
|
|
@@ -96,8 +96,8 @@ export interface LoaderContext<OptionsType = {}> {
|
|
|
96
96
|
getMissingDependencies(): string[];
|
|
97
97
|
addBuildDependency(file: string): void;
|
|
98
98
|
importModule(request: string, options: {
|
|
99
|
-
publicPath
|
|
100
|
-
baseUri
|
|
99
|
+
publicPath?: string;
|
|
100
|
+
baseUri?: string;
|
|
101
101
|
}, callback: (err?: Error, res?: any) => void): void;
|
|
102
102
|
fs: any;
|
|
103
103
|
utils: {
|