@rslib/core 0.1.3 → 0.1.5
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/entryModuleLoader.js +1 -1
- package/dist/index.js +170 -469
- package/dist/libCssExtractLoader.js +2 -9
- package/dist-types/asset/assetConfig.d.ts +3 -0
- package/dist-types/config.d.ts +3 -2
- package/dist-types/css/cssConfig.d.ts +1 -1
- package/dist-types/package.json +1 -0
- package/dist-types/types/{config/index.d.ts → config.d.ts} +21 -4
- package/dist-types/types/utils.d.ts +1 -0
- package/dist-types/utils/helper.d.ts +4 -2
- package/package.json +7 -6
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
2
|
-
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/web-infra-dev/rspack/blob/0a89e433a9f8596a7c6c4326542f168b5982d2da/packages/rspack/src/builtin-plugin/css-extract/loader.ts
|
|
5
|
-
* 1. remove hmr/webpack runtime
|
|
6
|
-
* 2. add `this.emitFile` to emit css files
|
|
7
|
-
* 3. add `import './[name].css';`
|
|
8
|
-
*/ const PLUGIN_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
2
|
+
const PLUGIN_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
9
3
|
function stringifyLocal(value) {
|
|
10
4
|
return 'function' == typeof value ? value.toString() : JSON.stringify(value);
|
|
11
5
|
}
|
|
@@ -30,7 +24,6 @@ const pitch = function(request, _, _data) {
|
|
|
30
24
|
const esModule = void 0 === options.esModule || options.esModule;
|
|
31
25
|
let dependencies = [];
|
|
32
26
|
try {
|
|
33
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
34
27
|
const exports = originalExports.__esModule ? originalExports.default : originalExports;
|
|
35
28
|
namedExport = originalExports.__esModule && (!originalExports.default || !('locals' in originalExports.default));
|
|
36
29
|
if (namedExport) {
|
|
@@ -121,5 +114,5 @@ const pitch = function(request, _, _data) {
|
|
|
121
114
|
handleExports(exports);
|
|
122
115
|
});
|
|
123
116
|
};
|
|
124
|
-
|
|
117
|
+
const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
|
|
125
118
|
export { libCssExtractLoader_rslib_entry_ as default, pitch };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type EnvironmentConfig, type RsbuildConfig } from '@rsbuild/core';
|
|
2
|
-
import type { AutoExternal, BannerAndFooter, LibConfig, PkgJson, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
2
|
+
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, 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.
|
|
@@ -17,7 +17,8 @@ export declare function loadConfig({ cwd, path, envMode, }: {
|
|
|
17
17
|
filePath: string;
|
|
18
18
|
}>;
|
|
19
19
|
export declare const composeAutoExternalConfig: (options: {
|
|
20
|
-
|
|
20
|
+
format: Format;
|
|
21
|
+
autoExternal?: AutoExternal;
|
|
21
22
|
pkgJson?: PkgJson;
|
|
22
23
|
userExternals?: NonNullable<RsbuildConfig["output"]>["externals"];
|
|
23
24
|
}) => RsbuildConfig;
|
|
@@ -11,7 +11,7 @@ export declare function parsePathQueryFragment(str: string): {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
13
13
|
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
|
-
type ExternalCallback = (arg0?:
|
|
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
16
|
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => RsbuildConfig;
|
|
17
17
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"//":"This file is for making TypeScript work with moduleResolution node16+.","version":"1.0.0"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { RsbuildConfig } from '@rsbuild/core';
|
|
1
|
+
import type { RsbuildConfig, Rspack } from '@rsbuild/core';
|
|
2
2
|
import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
|
|
3
|
+
import type { GetAsyncFunctionFromUnion } from './utils';
|
|
3
4
|
export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
|
|
4
5
|
export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
|
|
5
6
|
export type LatestEcmaVersions = 'es2024' | 'esnext';
|
|
@@ -11,6 +12,7 @@ export type RsbuildConfigWithLibInfo = {
|
|
|
11
12
|
};
|
|
12
13
|
export type RsbuildConfigEntry = NonNullable<NonNullable<RsbuildConfig['source']>['entry']>;
|
|
13
14
|
export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
|
|
15
|
+
export type RspackResolver = GetAsyncFunctionFromUnion<ReturnType<NonNullable<Rspack.ExternalItemFunctionData['getResolve']>>>;
|
|
14
16
|
export type RsbuildConfigOutputTarget = NonNullable<RsbuildConfig['output']>['target'];
|
|
15
17
|
export type Syntax = EcmaScriptVersion | string[];
|
|
16
18
|
export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
|
|
@@ -37,7 +39,22 @@ export type Shims = {
|
|
|
37
39
|
require?: boolean;
|
|
38
40
|
};
|
|
39
41
|
};
|
|
42
|
+
export type JsRedirect = {
|
|
43
|
+
/**
|
|
44
|
+
* Whether to automatically redirect the import paths of JavaScript output files.
|
|
45
|
+
* @defaultValue `true`
|
|
46
|
+
*/
|
|
47
|
+
path?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to automatically add the file extension to import paths based on the JavaScript output files.
|
|
50
|
+
* @defaultValue `true`
|
|
51
|
+
*/
|
|
52
|
+
extension?: boolean;
|
|
53
|
+
};
|
|
40
54
|
export type Redirect = {
|
|
55
|
+
/** Controls the redirect of the import paths of output JavaScript files. */
|
|
56
|
+
js?: JsRedirect;
|
|
57
|
+
/** Whether to redirect the import path of the style file. */
|
|
41
58
|
style?: boolean;
|
|
42
59
|
};
|
|
43
60
|
export interface LibConfig extends RsbuildConfig {
|
|
@@ -67,7 +84,7 @@ export interface LibConfig extends RsbuildConfig {
|
|
|
67
84
|
autoExtension?: boolean;
|
|
68
85
|
/**
|
|
69
86
|
* Whether to automatically externalize dependencies of different dependency types and do not bundle them.
|
|
70
|
-
* @defaultValue `true`
|
|
87
|
+
* @defaultValue `true` when {@link format} is `cjs` or `esm`, `false` when {@link format} is `umd` or `mf`.
|
|
71
88
|
* @see {@link https://lib.rsbuild.dev/config/lib/auto-external}
|
|
72
89
|
*/
|
|
73
90
|
autoExternal?: AutoExternal;
|
|
@@ -90,13 +107,13 @@ export interface LibConfig extends RsbuildConfig {
|
|
|
90
107
|
*/
|
|
91
108
|
externalHelpers?: boolean;
|
|
92
109
|
/**
|
|
93
|
-
* Inject content into the top of each
|
|
110
|
+
* Inject content into the top of each JavaScript, CSS or DTS file.
|
|
94
111
|
* @defaultValue `{}`
|
|
95
112
|
* @see {@link https://lib.rsbuild.dev/config/lib/banner}
|
|
96
113
|
*/
|
|
97
114
|
banner?: BannerAndFooter;
|
|
98
115
|
/**
|
|
99
|
-
* Inject content into the bottom of each
|
|
116
|
+
* Inject content into the bottom of each JavaScript, CSS or DTS file.
|
|
100
117
|
* @defaultValue `{}`
|
|
101
118
|
* @see {@link https://lib.rsbuild.dev/config/lib/footer}
|
|
102
119
|
*/
|
|
@@ -10,3 +10,4 @@ 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
12
|
export type ExcludesFalse = <T>(x: T | false | undefined | null) => x is T;
|
|
13
|
+
export type GetAsyncFunctionFromUnion<T> = T extends (...args: any[]) => Promise<any> ? T : never;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RsbuildPlugins } from '@rsbuild/core';
|
|
2
2
|
import color from 'picocolors';
|
|
3
|
-
import type { LibConfig, PkgJson } from '../types';
|
|
3
|
+
import type { Format, LibConfig, PkgJson } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Node.js built-in modules.
|
|
6
6
|
* Copied from https://github.com/webpack/webpack/blob/dd44b206a9c50f4b4cb4d134e1a0bd0387b159a3/lib/node/NodeTargetPlugin.js#L12-L72
|
|
@@ -14,10 +14,12 @@ export declare const isEmptyObject: (obj: object) => boolean;
|
|
|
14
14
|
export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
|
|
15
15
|
export declare function omit<T extends object, U extends keyof T>(obj: T, keysObj: Record<U, boolean>): Omit<T, keyof U>;
|
|
16
16
|
export declare function isPluginIncluded(pluginName: string, plugins?: RsbuildPlugins): boolean;
|
|
17
|
-
export declare function checkMFPlugin(config: LibConfig): boolean;
|
|
17
|
+
export declare function checkMFPlugin(config: LibConfig, sharedPlugins?: RsbuildPlugins): boolean;
|
|
18
18
|
export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
|
|
19
19
|
/**
|
|
20
20
|
* Check if running in a TTY context
|
|
21
21
|
*/
|
|
22
22
|
export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
|
|
23
|
+
export declare const isIntermediateOutputFormat: (format: Format) => boolean;
|
|
23
24
|
export { color };
|
|
25
|
+
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.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/web-infra-dev/rslib",
|
|
11
|
+
"url": "git+https://github.com/web-infra-dev/rslib.git",
|
|
12
12
|
"directory": "packages/core"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
@@ -32,19 +32,20 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.1.
|
|
35
|
+
"@rsbuild/core": "~1.1.10",
|
|
36
36
|
"tinyglobby": "^0.2.10",
|
|
37
|
-
"rsbuild-plugin-dts": "0.1.
|
|
37
|
+
"rsbuild-plugin-dts": "0.1.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/fs-extra": "^11.0.4",
|
|
41
41
|
"chokidar": "^4.0.1",
|
|
42
42
|
"commander": "^12.1.0",
|
|
43
43
|
"fs-extra": "^11.2.0",
|
|
44
|
-
"memfs": "^4.
|
|
44
|
+
"memfs": "^4.15.0",
|
|
45
45
|
"picocolors": "1.1.1",
|
|
46
46
|
"prebundle": "1.2.5",
|
|
47
|
-
"
|
|
47
|
+
"rsbuild-plugin-publint": "^0.2.1",
|
|
48
|
+
"rslib": "npm:@rslib/core@0.1.4",
|
|
48
49
|
"rslog": "^1.2.3",
|
|
49
50
|
"tsconfck": "3.1.4",
|
|
50
51
|
"typescript": "^5.6.3",
|