@rslib/core 0.1.5 → 0.2.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/chokidar/index.d.ts +24 -6
- package/compiled/chokidar/index.js +16 -13
- package/compiled/chokidar/package.json +1 -1
- package/dist/index.js +228 -180
- package/dist/libCssExtractLoader.js +25 -9
- package/dist-types/asset/assetConfig.d.ts +2 -2
- package/dist-types/cli/build.d.ts +1 -1
- package/dist-types/cli/mf.d.ts +2 -1
- package/dist-types/config.d.ts +12 -9
- package/dist-types/css/LibCssExtractPlugin.d.ts +9 -0
- package/dist-types/css/cssConfig.d.ts +2 -2
- package/dist-types/css/libCssExtractLoader.d.ts +6 -0
- package/dist-types/css/utils.d.ts +7 -0
- package/dist-types/plugins/EntryChunkPlugin.d.ts +2 -2
- package/dist-types/types/config.d.ts +6 -6
- package/dist-types/types/utils.d.ts +3 -0
- package/dist-types/utils/syntax.d.ts +2 -2
- package/package.json +8 -7
- package/dist-types/css/RemoveCssExtractAssetPlugin.d.ts +0 -11
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
const
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
2
|
+
const BASE_URI = 'webpack://';
|
|
3
|
+
const MODULE_TYPE = 'css/mini-extract';
|
|
4
|
+
const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
5
|
+
const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
|
|
6
|
+
const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
7
|
+
const LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
3
8
|
function stringifyLocal(value) {
|
|
4
9
|
return 'function' == typeof value ? value.toString() : JSON.stringify(value);
|
|
5
10
|
}
|
|
@@ -18,6 +23,15 @@ const pitch = function(request, _, _data) {
|
|
|
18
23
|
const callback = this.async();
|
|
19
24
|
const filepath = this.resourcePath;
|
|
20
25
|
const rootDir = options.rootDir ?? this.rootContext;
|
|
26
|
+
let { publicPath } = this._compilation.outputOptions;
|
|
27
|
+
if ('string' == typeof options.publicPath) publicPath = options.publicPath;
|
|
28
|
+
else if ('function' == typeof options.publicPath) publicPath = options.publicPath(this.resourcePath, this.rootContext);
|
|
29
|
+
if ('auto' === publicPath) publicPath = AUTO_PUBLIC_PATH;
|
|
30
|
+
let publicPathForExtract;
|
|
31
|
+
if ('string' == typeof publicPath) {
|
|
32
|
+
const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
|
|
33
|
+
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}`;
|
|
34
|
+
} else publicPathForExtract = publicPath;
|
|
21
35
|
const handleExports = (originalExports)=>{
|
|
22
36
|
let locals;
|
|
23
37
|
let namedExport;
|
|
@@ -79,20 +93,20 @@ const pitch = function(request, _, _data) {
|
|
|
79
93
|
if (esModule) return '\nexport {};';
|
|
80
94
|
return '';
|
|
81
95
|
}();
|
|
82
|
-
let resultSource = `// extracted by ${
|
|
96
|
+
let resultSource = `// extracted by ${LOADER_NAME}`;
|
|
83
97
|
let importCssFiles = '';
|
|
84
98
|
function getRelativePath(from, to) {
|
|
85
|
-
let relativePath =
|
|
86
|
-
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}`;
|
|
87
101
|
return relativePath;
|
|
88
102
|
}
|
|
89
103
|
const m = new Map();
|
|
90
104
|
for (const { content, filepath } of dependencies){
|
|
91
105
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
92
|
-
const ext = (0,
|
|
106
|
+
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(distFilepath);
|
|
93
107
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
94
108
|
distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
95
|
-
const cssFilename =
|
|
109
|
+
const cssFilename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(distFilepath);
|
|
96
110
|
if (content.trim()) {
|
|
97
111
|
m.get(distFilepath) ? m.set(distFilepath, `${m.get(distFilepath) + content}\n`) : m.set(distFilepath, `${content}\n`);
|
|
98
112
|
importCssFiles += '\n';
|
|
@@ -105,7 +119,9 @@ const pitch = function(request, _, _data) {
|
|
|
105
119
|
callback(null, resultSource, void 0);
|
|
106
120
|
};
|
|
107
121
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
108
|
-
layer: options.layer
|
|
122
|
+
layer: options.layer,
|
|
123
|
+
publicPath: publicPathForExtract,
|
|
124
|
+
baseUri: `${BASE_URI}/`
|
|
109
125
|
}, (error, exports)=>{
|
|
110
126
|
if (error) {
|
|
111
127
|
callback(error);
|
|
@@ -115,4 +131,4 @@ const pitch = function(request, _, _data) {
|
|
|
115
131
|
});
|
|
116
132
|
};
|
|
117
133
|
const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
|
|
118
|
-
export { libCssExtractLoader_rslib_entry_ as default, pitch };
|
|
134
|
+
export { ABSOLUTE_PUBLIC_PATH, AUTO_PUBLIC_PATH, BASE_URI, MODULE_TYPE, SINGLE_DOT_PATH_SEGMENT, libCssExtractLoader_rslib_entry_ as default, pitch };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentConfig } from '@rsbuild/core';
|
|
2
2
|
import type { Format } from '../types';
|
|
3
|
-
export declare const composeAssetConfig: (bundle: boolean, format: Format) =>
|
|
3
|
+
export declare const composeAssetConfig: (bundle: boolean, format: Format) => EnvironmentConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import type { RslibConfig } from '../types/config';
|
|
3
3
|
import type { BuildOptions } from './commands';
|
|
4
|
-
export declare function build(config: RslibConfig, options?: Pick<BuildOptions, 'lib' | 'watch'>): Promise<RsbuildInstance>;
|
|
4
|
+
export declare function build(config: RslibConfig, options?: Pick<BuildOptions, 'lib' | 'watch' | 'root'>): Promise<RsbuildInstance>;
|
package/dist-types/cli/mf.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import type { RslibConfig } from '../types';
|
|
3
|
-
|
|
3
|
+
import type { CommonOptions } from './commands';
|
|
4
|
+
export declare function startMFDevServer(config: RslibConfig, options?: Pick<CommonOptions, 'lib'>): Promise<RsbuildInstance | undefined>;
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type EnvironmentConfig
|
|
2
|
-
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
1
|
+
import { type EnvironmentConfig } from '@rsbuild/core';
|
|
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.
|
|
5
5
|
* It accepts a Rslib config object, or a function that returns a config.
|
|
@@ -20,14 +20,17 @@ export declare const composeAutoExternalConfig: (options: {
|
|
|
20
20
|
format: Format;
|
|
21
21
|
autoExternal?: AutoExternal;
|
|
22
22
|
pkgJson?: PkgJson;
|
|
23
|
-
userExternals?: NonNullable<
|
|
24
|
-
}) =>
|
|
25
|
-
export declare function composeMinifyConfig(config: LibConfig):
|
|
26
|
-
export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter):
|
|
27
|
-
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<
|
|
28
|
-
export declare function createConstantRsbuildConfig(): Promise<
|
|
23
|
+
userExternals?: NonNullable<EnvironmentConfig["output"]>["externals"];
|
|
24
|
+
}) => EnvironmentConfig;
|
|
25
|
+
export declare function composeMinifyConfig(config: LibConfig): EnvironmentConfig;
|
|
26
|
+
export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter): EnvironmentConfig;
|
|
27
|
+
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
|
|
28
|
+
export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
|
|
29
29
|
export declare const composeModuleImportWarn: (request: string) => string;
|
|
30
30
|
export declare const appendEntryQuery: (entry: RsbuildConfigEntry) => RsbuildConfigEntry;
|
|
31
31
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
|
|
32
|
-
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<
|
|
32
|
+
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<{
|
|
33
|
+
environments: Record<string, EnvironmentConfig>;
|
|
34
|
+
environmentWithInfos: RequireKey<RsbuildConfigWithLibInfo, 'id'>[];
|
|
35
|
+
}>;
|
|
33
36
|
export declare const pruneEnvironments: (environments: Record<string, EnvironmentConfig>, libs?: string[]) => Record<string, EnvironmentConfig>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Rspack } from '@rsbuild/core';
|
|
2
|
+
type Options = Record<string, unknown>;
|
|
3
|
+
declare class LibCssExtractPlugin implements Rspack.RspackPluginInstance {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
options: Options;
|
|
6
|
+
constructor(options?: Options);
|
|
7
|
+
apply(compiler: Rspack.Compiler): void;
|
|
8
|
+
}
|
|
9
|
+
export { LibCssExtractPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSLoaderOptions,
|
|
1
|
+
import type { CSSLoaderOptions, EnvironmentConfig } from '@rsbuild/core';
|
|
2
2
|
export declare const RSLIB_CSS_ENTRY_FLAG = "__rslib_css__";
|
|
3
3
|
export type CssLoaderOptionsAuto = CSSLoaderOptions['modules'] extends infer T ? T extends {
|
|
4
4
|
auto?: any;
|
|
@@ -13,5 +13,5 @@ export declare function isCssModulesFile(filepath: string, auto: CssLoaderOption
|
|
|
13
13
|
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
14
|
type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
|
|
15
15
|
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, isStyleRedirect: boolean): void | false;
|
|
16
|
-
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) =>
|
|
16
|
+
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => EnvironmentConfig;
|
|
17
17
|
export {};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
export declare const BASE_URI = "webpack://";
|
|
3
|
+
export declare const MODULE_TYPE = "css/mini-extract";
|
|
4
|
+
export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
5
|
+
export declare const ABSOLUTE_PUBLIC_PATH: string;
|
|
6
|
+
export declare const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
2
7
|
export interface CssExtractRspackLoaderOptions {
|
|
8
|
+
publicPath?: string | ((resourcePath: string, context: string) => string);
|
|
3
9
|
emit?: boolean;
|
|
4
10
|
esModule?: boolean;
|
|
5
11
|
layer?: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function is copied from
|
|
3
|
+
* https://github.com/webpack-contrib/mini-css-extract-plugin/blob/3effaa0319bad5cc1bf0ae760553bf7abcbc35a4/src/utils.js#L169
|
|
4
|
+
* linted by biome
|
|
5
|
+
*/
|
|
6
|
+
declare function getUndoPath(filename: string, outputPathArg: string, enforceRelative: boolean): string;
|
|
7
|
+
export { getUndoPath };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EnvironmentConfig } from '@rsbuild/core';
|
|
2
2
|
export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, }: {
|
|
3
3
|
enabledImportMetaUrlShim: boolean;
|
|
4
|
-
}) =>
|
|
4
|
+
}) => EnvironmentConfig;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
1
|
+
import type { EnvironmentConfig, RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
2
2
|
import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
|
|
3
3
|
import type { GetAsyncFunctionFromUnion } from './utils';
|
|
4
4
|
export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
|
|
@@ -8,12 +8,12 @@ export type EcmaScriptVersion = FixedEcmaVersions | LatestEcmaVersions;
|
|
|
8
8
|
export type RsbuildConfigWithLibInfo = {
|
|
9
9
|
id?: string;
|
|
10
10
|
format: Format;
|
|
11
|
-
config:
|
|
11
|
+
config: EnvironmentConfig;
|
|
12
12
|
};
|
|
13
|
-
export type RsbuildConfigEntry = NonNullable<NonNullable<
|
|
13
|
+
export type RsbuildConfigEntry = NonNullable<NonNullable<EnvironmentConfig['source']>['entry']>;
|
|
14
14
|
export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
|
|
15
15
|
export type RspackResolver = GetAsyncFunctionFromUnion<ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>>;
|
|
16
|
-
export type RsbuildConfigOutputTarget = NonNullable<
|
|
16
|
+
export type RsbuildConfigOutputTarget = NonNullable<EnvironmentConfig['output']>['target'];
|
|
17
17
|
export type Syntax = EcmaScriptVersion | string[];
|
|
18
18
|
export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
|
|
19
19
|
autoExtension?: boolean;
|
|
@@ -57,7 +57,7 @@ export type Redirect = {
|
|
|
57
57
|
/** Whether to redirect the import path of the style file. */
|
|
58
58
|
style?: boolean;
|
|
59
59
|
};
|
|
60
|
-
export interface LibConfig extends
|
|
60
|
+
export interface LibConfig extends EnvironmentConfig {
|
|
61
61
|
/**
|
|
62
62
|
* The unique identifier of the library.
|
|
63
63
|
* @defaultValue `undefined`
|
|
@@ -150,7 +150,7 @@ export interface LibConfig extends RsbuildConfig {
|
|
|
150
150
|
*/
|
|
151
151
|
umdName?: string;
|
|
152
152
|
}
|
|
153
|
-
export type LibOnlyConfig = Omit<LibConfig, keyof
|
|
153
|
+
export type LibOnlyConfig = Omit<LibConfig, keyof EnvironmentConfig>;
|
|
154
154
|
export interface RslibConfig extends RsbuildConfig {
|
|
155
155
|
lib: LibConfig[];
|
|
156
156
|
}
|
|
@@ -9,5 +9,8 @@ export type PkgJson = {
|
|
|
9
9
|
export type DeepRequired<T> = Required<{
|
|
10
10
|
[K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
|
|
11
11
|
}>;
|
|
12
|
+
export type RequireKey<T, K extends keyof T> = T & {
|
|
13
|
+
[P in K]-?: T[P];
|
|
14
|
+
};
|
|
12
15
|
export type ExcludesFalse = <T>(x: T | false | undefined | null) => x is T;
|
|
13
16
|
export type GetAsyncFunctionFromUnion<T> = T extends (...args: any[]) => Promise<any> ? T : never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EnvironmentConfig, Rspack } from '@rsbuild/core';
|
|
2
2
|
import type { FixedEcmaVersions, LatestEcmaVersions, RsbuildConfigOutputTarget, Syntax } from '../types/config';
|
|
3
3
|
export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOutputTarget>, string[]>;
|
|
4
4
|
/**
|
|
@@ -10,4 +10,4 @@ export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOut
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const ESX_TO_BROWSERSLIST: Record<FixedEcmaVersions, Record<string, string | string[]>> & Record<LatestEcmaVersions, (target: RsbuildConfigOutputTarget) => string[]>;
|
|
12
12
|
export declare function transformSyntaxToRspackTarget(syntax: Syntax): Rspack.Configuration['target'];
|
|
13
|
-
export declare function transformSyntaxToBrowserslist(syntax: Syntax, target: NonNullable<
|
|
13
|
+
export declare function transformSyntaxToBrowserslist(syntax: Syntax, target: NonNullable<EnvironmentConfig['output']>['target']): NonNullable<NonNullable<EnvironmentConfig['output']>['overrideBrowserslist']>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,23 +32,24 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.1.
|
|
35
|
+
"@rsbuild/core": "~1.1.13",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.1
|
|
37
|
+
"rsbuild-plugin-dts": "0.2.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
+
"@module-federation/rsbuild-plugin": "^0.8.5",
|
|
40
41
|
"@types/fs-extra": "^11.0.4",
|
|
41
|
-
"chokidar": "^4.0.
|
|
42
|
+
"chokidar": "^4.0.3",
|
|
42
43
|
"commander": "^12.1.0",
|
|
43
44
|
"fs-extra": "^11.2.0",
|
|
44
|
-
"memfs": "^4.15.
|
|
45
|
+
"memfs": "^4.15.1",
|
|
45
46
|
"picocolors": "1.1.1",
|
|
46
47
|
"prebundle": "1.2.5",
|
|
47
48
|
"rsbuild-plugin-publint": "^0.2.1",
|
|
48
|
-
"rslib": "npm:@rslib/core@0.
|
|
49
|
+
"rslib": "npm:@rslib/core@0.2.0",
|
|
49
50
|
"rslog": "^1.2.3",
|
|
50
51
|
"tsconfck": "3.1.4",
|
|
51
|
-
"typescript": "^5.
|
|
52
|
+
"typescript": "^5.7.2",
|
|
52
53
|
"@rslib/tsconfig": "0.0.1"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Rspack } from '@rsbuild/core';
|
|
2
|
-
type Options = {
|
|
3
|
-
include: RegExp;
|
|
4
|
-
};
|
|
5
|
-
declare class RemoveCssExtractAssetPlugin implements Rspack.RspackPluginInstance {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
options: Options;
|
|
8
|
-
constructor(options: Options);
|
|
9
|
-
apply(compiler: Rspack.Compiler): void;
|
|
10
|
-
}
|
|
11
|
-
export { RemoveCssExtractAssetPlugin };
|