@rslib/core 0.10.0 → 0.10.2
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/compiled/rslog/index.d.ts +2 -2
- package/compiled/rslog/index.js +260 -309
- package/compiled/rslog/package.json +1 -1
- package/dist/index.js +1736 -1735
- package/dist/libCssExtractLoader.js +23 -27
- package/dist-types/css/const.d.ts +5 -0
- package/dist-types/css/cssConfig.d.ts +2 -12
- package/dist-types/css/libCssExtractLoader.d.ts +1 -6
- package/dist-types/css/utils.d.ts +13 -2
- package/dist-types/index.d.ts +5 -5
- package/dist-types/utils/color.d.ts +2 -0
- package/dist-types/utils/helper.d.ts +0 -2
- package/package.json +5 -5
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import node_path, { extname } from "node:path";
|
|
2
|
+
const BASE_URI = 'webpack://';
|
|
3
|
+
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
4
|
+
const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
|
|
5
|
+
const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
4
6
|
const DTS_EXTENSIONS = [
|
|
5
7
|
'd.ts',
|
|
6
8
|
'd.mts',
|
|
@@ -31,7 +33,6 @@ const CSS_EXTENSIONS = [
|
|
|
31
33
|
new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
32
34
|
new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
33
35
|
new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
|
|
34
|
-
createRequire(import.meta.url);
|
|
35
36
|
const CSS_MODULE_REG = /\.module\.\w+$/i;
|
|
36
37
|
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
|
|
37
38
|
function parsePathQueryFragment(str) {
|
|
@@ -42,8 +43,8 @@ function parsePathQueryFragment(str) {
|
|
|
42
43
|
fragment: match?.[3] || ''
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
const filename =
|
|
46
|
+
function isCssModulesFile(filepath, auto) {
|
|
47
|
+
const filename = node_path.basename(filepath);
|
|
47
48
|
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
48
49
|
if (auto instanceof RegExp) return auto.test(filepath);
|
|
49
50
|
if ('function' == typeof auto) {
|
|
@@ -52,19 +53,14 @@ function cssConfig_isCssModulesFile(filepath, auto) {
|
|
|
52
53
|
}
|
|
53
54
|
return false;
|
|
54
55
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const css_libCssExtractLoader_AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
58
|
-
const css_libCssExtractLoader_ABSOLUTE_PUBLIC_PATH = `${css_libCssExtractLoader_BASE_URI}/mini-css-extract-plugin/`;
|
|
59
|
-
const css_libCssExtractLoader_SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
60
|
-
const libCssExtractLoader_LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
61
|
-
function libCssExtractLoader_stringifyLocal(value) {
|
|
56
|
+
const LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
57
|
+
function stringifyLocal(value) {
|
|
62
58
|
return 'function' == typeof value ? value.toString() : JSON.stringify(value);
|
|
63
59
|
}
|
|
64
|
-
const
|
|
60
|
+
const libCssExtractLoader_loader = function(content) {
|
|
65
61
|
if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) return content;
|
|
66
62
|
};
|
|
67
|
-
const
|
|
63
|
+
const pitch = function(request, _, _data) {
|
|
68
64
|
if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) {
|
|
69
65
|
const e = new Error("use type 'css' and `CssExtractRspackPlugin` together, please set `experiments.css` to `false` or set `{ type: \"javascript/auto\" }` for rules with `CssExtractRspackPlugin` in your rspack config (now `CssExtractRspackPlugin` does nothing).");
|
|
70
66
|
e.stack = void 0;
|
|
@@ -82,11 +78,11 @@ const libCssExtractLoader_pitch = function(request, _, _data) {
|
|
|
82
78
|
let { publicPath } = this._compilation.outputOptions;
|
|
83
79
|
if ('string' == typeof options.publicPath) publicPath = options.publicPath;
|
|
84
80
|
else if ('function' == typeof options.publicPath) publicPath = options.publicPath(this.resourcePath, this.rootContext);
|
|
85
|
-
if ('auto' === publicPath) publicPath =
|
|
81
|
+
if ('auto' === publicPath) publicPath = AUTO_PUBLIC_PATH;
|
|
86
82
|
let publicPathForExtract;
|
|
87
83
|
if ('string' == typeof publicPath) {
|
|
88
84
|
const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
|
|
89
|
-
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${
|
|
85
|
+
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}`;
|
|
90
86
|
} else publicPathForExtract = publicPath;
|
|
91
87
|
const handleExports = (originalExports)=>{
|
|
92
88
|
let locals;
|
|
@@ -139,7 +135,7 @@ const libCssExtractLoader_pitch = function(request, _, _data) {
|
|
|
139
135
|
];
|
|
140
136
|
}
|
|
141
137
|
}());
|
|
142
|
-
const localsString = identifiers.map(([id, key])=>`\nvar ${id} = ${
|
|
138
|
+
const localsString = identifiers.map(([id, key])=>`\nvar ${id} = ${stringifyLocal(locals[key])};`).join('');
|
|
143
139
|
const exportsString = `export { ${identifiers.map(([id, key])=>`${id} as ${JSON.stringify(key)}`).join(', ')} }`;
|
|
144
140
|
const defaultExport = void 0 !== options.defaultExport ? options.defaultExport : false;
|
|
145
141
|
return defaultExport ? `${localsString}\n${exportsString}\nexport default { ${identifiers.map(([id, key])=>`${JSON.stringify(key)}: ${id}`).join(', ')} }\n` : `${localsString}\n${exportsString}\n`;
|
|
@@ -149,20 +145,20 @@ const libCssExtractLoader_pitch = function(request, _, _data) {
|
|
|
149
145
|
if (esModule) return '\nexport {};';
|
|
150
146
|
return '';
|
|
151
147
|
}();
|
|
152
|
-
let resultSource = `// extracted by ${
|
|
148
|
+
let resultSource = `// extracted by ${LOADER_NAME}`;
|
|
153
149
|
let importCssFiles = '';
|
|
154
150
|
function getRelativePath(from, to) {
|
|
155
|
-
let relativePath =
|
|
156
|
-
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !
|
|
151
|
+
let relativePath = node_path.relative(from, to);
|
|
152
|
+
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !node_path.isAbsolute(relativePath)) relativePath = `./${relativePath}`;
|
|
157
153
|
return relativePath;
|
|
158
154
|
}
|
|
159
155
|
const m = new Map();
|
|
160
156
|
for (const { content, filepath, sourceMap } of dependencies){
|
|
161
157
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
162
|
-
const ext =
|
|
158
|
+
const ext = extname(distFilepath);
|
|
163
159
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
164
|
-
if (
|
|
165
|
-
const cssFilename =
|
|
160
|
+
if (isCssModulesFile(filepath, auto)) distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
161
|
+
const cssFilename = node_path.basename(distFilepath);
|
|
166
162
|
if (content.trim()) {
|
|
167
163
|
m.get(distFilepath) ? m.set(distFilepath, `${m.get(distFilepath) + content}\n`) : m.set(distFilepath, `${content}\n`);
|
|
168
164
|
importCssFiles += '\n';
|
|
@@ -187,11 +183,11 @@ const libCssExtractLoader_pitch = function(request, _, _data) {
|
|
|
187
183
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
188
184
|
layer: options.layer,
|
|
189
185
|
publicPath: publicPathForExtract,
|
|
190
|
-
baseUri: `${
|
|
186
|
+
baseUri: `${BASE_URI}/`
|
|
191
187
|
}, (error, exports)=>{
|
|
192
188
|
if (error) return void callback(error);
|
|
193
189
|
handleExports(exports);
|
|
194
190
|
});
|
|
195
191
|
};
|
|
196
|
-
const
|
|
197
|
-
export {
|
|
192
|
+
const libCssExtractLoader = libCssExtractLoader_loader;
|
|
193
|
+
export { libCssExtractLoader as default, pitch };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const BASE_URI = "webpack://";
|
|
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: string;
|
|
5
|
+
export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentConfig } from '@rsbuild/core';
|
|
2
|
+
import { type CssLoaderOptionsAuto } from './utils';
|
|
2
3
|
export declare const RSLIB_CSS_ENTRY_FLAG = "__rslib_css__";
|
|
3
|
-
export type CssLoaderOptionsAuto = CSSLoaderOptions['modules'] extends infer T ? T extends {
|
|
4
|
-
auto?: any;
|
|
5
|
-
} ? T['auto'] : never : never;
|
|
6
|
-
export declare function isCssFile(filepath: string): boolean;
|
|
7
|
-
export declare function parsePathQueryFragment(str: string): {
|
|
8
|
-
path: string;
|
|
9
|
-
query: string;
|
|
10
|
-
fragment: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
13
|
-
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
4
|
type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
|
|
15
5
|
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectPath: (request: string) => Promise<string | undefined>, issuer: string): Promise<false | void>;
|
|
16
6
|
export declare const composeCssConfig: (rootDir: string | null, auto: CssLoaderOptionsAuto, bundle?: boolean, banner?: string, footer?: string) => EnvironmentConfig;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { Rspack } from '@rsbuild/core';
|
|
2
|
-
import { type CssLoaderOptionsAuto } from './
|
|
3
|
-
export declare const BASE_URI = "webpack://";
|
|
4
|
-
export declare const MODULE_TYPE = "css/mini-extract";
|
|
5
|
-
export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
6
|
-
export declare const ABSOLUTE_PUBLIC_PATH: string;
|
|
7
|
-
export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
2
|
+
import { type CssLoaderOptionsAuto } from './utils';
|
|
8
3
|
export interface CssExtractRspackLoaderOptions {
|
|
9
4
|
publicPath?: string | ((resourcePath: string, context: string) => string);
|
|
10
5
|
emit?: boolean;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import type { CSSLoaderOptions } from '@rsbuild/core';
|
|
2
|
+
export type CssLoaderOptionsAuto = CSSLoaderOptions['modules'] extends infer T ? T extends {
|
|
3
|
+
auto?: any;
|
|
4
|
+
} ? T['auto'] : never : never;
|
|
1
5
|
/**
|
|
2
6
|
* This function is copied from
|
|
3
7
|
* https://github.com/webpack-contrib/mini-css-extract-plugin/blob/3effaa0319bad5cc1bf0ae760553bf7abcbc35a4/src/utils.js#L169
|
|
4
8
|
* linted by biome
|
|
5
9
|
*/
|
|
6
|
-
declare function getUndoPath(filename: string, outputPathArg: string, enforceRelative: boolean): string;
|
|
7
|
-
export
|
|
10
|
+
export declare function getUndoPath(filename: string, outputPathArg: string, enforceRelative: boolean): string;
|
|
11
|
+
export declare function isCssFile(filepath: string): boolean;
|
|
12
|
+
export declare function parsePathQueryFragment(str: string): {
|
|
13
|
+
path: string;
|
|
14
|
+
query: string;
|
|
15
|
+
fragment: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
18
|
+
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { prepareCli } from './cli/prepare';
|
|
2
|
-
export { runCli } from './cli/commands';
|
|
3
1
|
export { build } from './cli/build';
|
|
2
|
+
export { runCli } from './cli/commands';
|
|
4
3
|
export { inspect } from './cli/inspect';
|
|
5
4
|
export { startMFDevServer } from './cli/mf';
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
5
|
+
export { prepareCli } from './cli/prepare';
|
|
6
|
+
export { composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, defineConfig, loadConfig, } from './config';
|
|
8
7
|
export type * from './types';
|
|
8
|
+
export { logger } from './utils/logger';
|
|
9
9
|
export declare const version: string;
|
|
10
|
-
export { rspack, type Rspack } from '@rsbuild/core';
|
|
11
10
|
export * as rsbuild from '@rsbuild/core';
|
|
11
|
+
export { type Rspack, rspack } from '@rsbuild/core';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RsbuildPlugins } from '@rsbuild/core';
|
|
2
|
-
import color from '../../compiled/picocolors';
|
|
3
2
|
import type { Format, LibConfig, PkgJson } from '../types';
|
|
4
3
|
/**
|
|
5
4
|
* Node.js built-in modules.
|
|
@@ -21,5 +20,4 @@ export declare function debounce<T extends (...args: any[]) => void>(func: T, wa
|
|
|
21
20
|
*/
|
|
22
21
|
export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
|
|
23
22
|
export declare const isIntermediateOutputFormat: (format: Format) => boolean;
|
|
24
|
-
export { color };
|
|
25
23
|
export declare function normalizeSlash(p: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "1.4.0-beta.
|
|
39
|
+
"@rsbuild/core": "1.4.0-beta.4",
|
|
40
40
|
"tinyglobby": "^0.2.14",
|
|
41
|
-
"rsbuild-plugin-dts": "0.10.
|
|
41
|
+
"rsbuild-plugin-dts": "0.10.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@module-federation/rsbuild-plugin": "^0.15.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.3.3",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.2",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.
|
|
54
|
-
"rslog": "^1.2.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.10.0",
|
|
54
|
+
"rslog": "^1.2.7",
|
|
55
55
|
"tsconfck": "3.1.6",
|
|
56
56
|
"typescript": "^5.8.3",
|
|
57
57
|
"@rslib/tsconfig": "0.0.1"
|