@rslib/core 0.2.2 → 0.3.1
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/commander/index.d.ts +88 -12
- package/compiled/commander/index.js +511 -151
- package/compiled/commander/package.json +1 -1
- package/dist/entryModuleLoader.js +3 -3
- package/dist/index.js +290 -215
- package/dist/libCssExtractLoader.js +5 -5
- package/dist-types/config.d.ts +3 -2
- package/dist-types/constant.d.ts +0 -3
- package/dist-types/css/cssConfig.d.ts +1 -1
- package/dist-types/plugins/EntryChunkPlugin.d.ts +2 -1
- package/dist-types/types/config.d.ts +95 -7
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
2
2
|
const BASE_URI = 'webpack://';
|
|
3
3
|
const MODULE_TYPE = 'css/mini-extract';
|
|
4
4
|
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
@@ -96,17 +96,17 @@ const pitch = function(request, _, _data) {
|
|
|
96
96
|
let resultSource = `// extracted by ${LOADER_NAME}`;
|
|
97
97
|
let importCssFiles = '';
|
|
98
98
|
function getRelativePath(from, to) {
|
|
99
|
-
let relativePath =
|
|
100
|
-
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !
|
|
99
|
+
let relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(from, to);
|
|
100
|
+
if (!relativePath.startsWith('./') && !relativePath.startsWith('../') && !__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(relativePath)) relativePath = `./${relativePath}`;
|
|
101
101
|
return relativePath;
|
|
102
102
|
}
|
|
103
103
|
const m = new Map();
|
|
104
104
|
for (const { content, filepath } of dependencies){
|
|
105
105
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
106
|
-
const ext = (0,
|
|
106
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(distFilepath);
|
|
107
107
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
108
108
|
distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
109
|
-
const cssFilename =
|
|
109
|
+
const cssFilename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(distFilepath);
|
|
110
110
|
if (content.trim()) {
|
|
111
111
|
m.get(distFilepath) ? m.set(distFilepath, `${m.get(distFilepath) + content}\n`) : m.set(distFilepath, `${content}\n`);
|
|
112
112
|
importCssFiles += '\n';
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EnvironmentConfig } from '@rsbuild/core';
|
|
1
|
+
import { type EnvironmentConfig, type RsbuildEntry } from '@rsbuild/core';
|
|
2
2
|
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RequireKey, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* This function helps you to autocomplete configuration types.
|
|
@@ -17,6 +17,7 @@ export declare function loadConfig({ cwd, path, envMode, }: {
|
|
|
17
17
|
filePath: string;
|
|
18
18
|
}>;
|
|
19
19
|
export declare const composeAutoExternalConfig: (options: {
|
|
20
|
+
bundle: boolean;
|
|
20
21
|
format: Format;
|
|
21
22
|
autoExternal?: AutoExternal;
|
|
22
23
|
pkgJson?: PkgJson;
|
|
@@ -27,7 +28,7 @@ export declare function composeBannerFooterConfig(banner: BannerAndFooter, foote
|
|
|
27
28
|
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
|
|
28
29
|
export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
|
|
29
30
|
export declare const composeModuleImportWarn: (request: string) => string;
|
|
30
|
-
export declare const appendEntryQuery: (
|
|
31
|
+
export declare const appendEntryQuery: (entries: RsbuildConfigEntry) => RsbuildEntry;
|
|
31
32
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
|
|
32
33
|
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<{
|
|
33
34
|
environments: Record<string, EnvironmentConfig>;
|
package/dist-types/constant.d.ts
CHANGED
|
@@ -5,9 +5,6 @@ export declare const RSLIB_ENTRY_QUERY = "__rslib_entry__";
|
|
|
5
5
|
export declare const SHEBANG_PREFIX = "#!";
|
|
6
6
|
export declare const SHEBANG_REGEX: RegExp;
|
|
7
7
|
export declare const REACT_DIRECTIVE_REGEX: RegExp;
|
|
8
|
-
export declare const JS_EXTENSIONS: string[];
|
|
9
|
-
export declare const CSS_EXTENSIONS: string[];
|
|
10
|
-
export declare const ENTRY_EXTENSIONS: string[];
|
|
11
8
|
export declare const JS_EXTENSIONS_PATTERN: RegExp;
|
|
12
9
|
export declare const CSS_EXTENSIONS_PATTERN: RegExp;
|
|
13
10
|
export declare const ENTRY_EXTENSIONS_PATTERN: RegExp;
|
|
@@ -12,6 +12,6 @@ export declare function parsePathQueryFragment(str: string): {
|
|
|
12
12
|
export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
13
13
|
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
14
|
type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
|
|
15
|
-
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto,
|
|
15
|
+
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectPath: (request: string) => Promise<string | undefined>): Promise<false | void>;
|
|
16
16
|
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => EnvironmentConfig;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EnvironmentConfig } from '@rsbuild/core';
|
|
2
|
-
export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, }: {
|
|
2
|
+
export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, contextToWatch, }: {
|
|
3
3
|
enabledImportMetaUrlShim: boolean;
|
|
4
|
+
contextToWatch: string | null;
|
|
4
5
|
}) => EnvironmentConfig;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { EnvironmentConfig, RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
2
|
-
import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
|
|
3
2
|
import type { GetAsyncFunctionFromUnion } from './utils';
|
|
4
3
|
export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
|
|
5
4
|
export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
|
|
@@ -15,14 +14,63 @@ export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
|
|
|
15
14
|
export type RspackResolver = GetAsyncFunctionFromUnion<ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>>;
|
|
16
15
|
export type RsbuildConfigOutputTarget = NonNullable<EnvironmentConfig['output']>['target'];
|
|
17
16
|
export type Syntax = EcmaScriptVersion | string[];
|
|
18
|
-
export type Dts =
|
|
17
|
+
export type Dts = {
|
|
18
|
+
/**
|
|
19
|
+
* Whether to bundle the DTS files.
|
|
20
|
+
* @defaultValue `false`
|
|
21
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsbundle}
|
|
22
|
+
*/
|
|
23
|
+
bundle?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The output directory of DTS files.
|
|
26
|
+
* @defaultValue {@link https://lib.rsbuild.dev/config/lib/dts#default-value}
|
|
27
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsdistpath}
|
|
28
|
+
*/
|
|
29
|
+
distPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to generate DTS files with building the project references.
|
|
32
|
+
* @defaultValue `false`
|
|
33
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsbuild}
|
|
34
|
+
*/
|
|
35
|
+
build?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether to abort the build process when an error occurs during DTS generation.
|
|
38
|
+
* @defaultValue `true`
|
|
39
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsabortonerror}
|
|
40
|
+
*/
|
|
41
|
+
abortOnError?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to automatically set the DTS file extension based on the {@link format} option.
|
|
44
|
+
* @defaultValue `false`
|
|
45
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/dts#dtsautoextension}
|
|
46
|
+
*/
|
|
19
47
|
autoExtension?: boolean;
|
|
20
|
-
}
|
|
48
|
+
} | boolean;
|
|
21
49
|
export type AutoExternal = boolean | {
|
|
50
|
+
/**
|
|
51
|
+
* Whether to automatically externalize dependencies of type `dependencies`.
|
|
52
|
+
* @defaultValue `true`
|
|
53
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/auto-external#autoexternaldependencies}
|
|
54
|
+
*/
|
|
22
55
|
dependencies?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether to automatically externalize dependencies of type `optionalDependencies`.
|
|
58
|
+
* @defaultValue `true`
|
|
59
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/auto-external#autoexternaloptionaldependencies}
|
|
60
|
+
*/
|
|
23
61
|
optionalDependencies?: boolean;
|
|
24
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Whether to automatically externalize dependencies of type `peerDependencies`.
|
|
64
|
+
* @defaultValue `true`
|
|
65
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/auto-external#autoexternalpeerdependencies}
|
|
66
|
+
*/
|
|
25
67
|
peerDependencies?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to automatically externalize dependencies of type `devDependencies`.
|
|
70
|
+
* @defaultValue `false`
|
|
71
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/auto-external#autoexternaldevdependencies}
|
|
72
|
+
*/
|
|
73
|
+
devDependencies?: boolean;
|
|
26
74
|
};
|
|
27
75
|
export type BannerAndFooter = {
|
|
28
76
|
js?: string;
|
|
@@ -30,12 +78,40 @@ export type BannerAndFooter = {
|
|
|
30
78
|
dts?: string;
|
|
31
79
|
};
|
|
32
80
|
export type Shims = {
|
|
81
|
+
/**
|
|
82
|
+
* Configure the shims for CommonJS output.
|
|
83
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/shims#shimscjs}
|
|
84
|
+
*/
|
|
33
85
|
cjs?: {
|
|
86
|
+
/**
|
|
87
|
+
* Whether to inject shims for the `import.meta.url` in CommonJS output.
|
|
88
|
+
* @defaultValue `true`
|
|
89
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/shims#shimscjsimportmetaurl}
|
|
90
|
+
*/
|
|
34
91
|
'import.meta.url'?: boolean;
|
|
35
92
|
};
|
|
93
|
+
/**
|
|
94
|
+
* Configure the shims for ESM output.
|
|
95
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/shims#shimsesm}
|
|
96
|
+
*/
|
|
36
97
|
esm?: {
|
|
98
|
+
/**
|
|
99
|
+
* Whether to inject shims for the global `__filename` of CommonJS in ESM output.
|
|
100
|
+
* @defaultValue `false`
|
|
101
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/shims#shimsesm__filename}
|
|
102
|
+
*/
|
|
37
103
|
__filename?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether to inject shims for the global `__dirname` of CommonJS in ESM output.
|
|
106
|
+
* @defaultValue `false`
|
|
107
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/shims#shimsesm__dirname}
|
|
108
|
+
*/
|
|
38
109
|
__dirname?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Whether to inject shims for the global `require` of CommonJS in ESM output.
|
|
112
|
+
* @defaultValue `false`
|
|
113
|
+
* @see {@link https://lib.rsbuild.dev/config/lib/shims#shimsesmrequire}
|
|
114
|
+
*/
|
|
39
115
|
require?: boolean;
|
|
40
116
|
};
|
|
41
117
|
};
|
|
@@ -46,7 +122,19 @@ export type JsRedirect = {
|
|
|
46
122
|
*/
|
|
47
123
|
path?: boolean;
|
|
48
124
|
/**
|
|
49
|
-
* Whether to automatically
|
|
125
|
+
* Whether to automatically redirect the file extension to import paths based on the JavaScript output files.
|
|
126
|
+
* @defaultValue `true`
|
|
127
|
+
*/
|
|
128
|
+
extension?: boolean;
|
|
129
|
+
};
|
|
130
|
+
export type StyleRedirect = {
|
|
131
|
+
/**
|
|
132
|
+
* Whether to automatically redirect the import paths of style output files.
|
|
133
|
+
* @defaultValue `true`
|
|
134
|
+
*/
|
|
135
|
+
path?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether to automatically redirect the file extension to import paths based on the style output files.
|
|
50
138
|
* @defaultValue `true`
|
|
51
139
|
*/
|
|
52
140
|
extension?: boolean;
|
|
@@ -54,8 +142,8 @@ export type JsRedirect = {
|
|
|
54
142
|
export type Redirect = {
|
|
55
143
|
/** Controls the redirect of the import paths of output JavaScript files. */
|
|
56
144
|
js?: JsRedirect;
|
|
57
|
-
/**
|
|
58
|
-
style?:
|
|
145
|
+
/** Controls the redirect of the import paths of output style files. */
|
|
146
|
+
style?: StyleRedirect;
|
|
59
147
|
};
|
|
60
148
|
export interface LibConfig extends EnvironmentConfig {
|
|
61
149
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,24 +32,24 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "
|
|
35
|
+
"@rsbuild/core": "1.2.0-beta.0",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.
|
|
37
|
+
"rsbuild-plugin-dts": "0.3.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@module-federation/rsbuild-plugin": "^0.8.
|
|
40
|
+
"@module-federation/rsbuild-plugin": "^0.8.8",
|
|
41
41
|
"@types/fs-extra": "^11.0.4",
|
|
42
42
|
"chokidar": "^4.0.3",
|
|
43
|
-
"commander": "^
|
|
43
|
+
"commander": "^13.0.0",
|
|
44
44
|
"fs-extra": "^11.2.0",
|
|
45
|
-
"memfs": "^4.15.
|
|
45
|
+
"memfs": "^4.15.3",
|
|
46
46
|
"picocolors": "1.1.1",
|
|
47
47
|
"prebundle": "1.2.5",
|
|
48
48
|
"rsbuild-plugin-publint": "^0.2.1",
|
|
49
|
-
"rslib": "npm:@rslib/core@0.
|
|
49
|
+
"rslib": "npm:@rslib/core@0.3.0",
|
|
50
50
|
"rslog": "^1.2.3",
|
|
51
51
|
"tsconfck": "3.1.4",
|
|
52
|
-
"typescript": "^5.7.
|
|
52
|
+
"typescript": "^5.7.3",
|
|
53
53
|
"@rslib/tsconfig": "0.0.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|