@rslib/core 0.0.18 → 0.1.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.
@@ -9,7 +9,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
9
9
  function stringifyLocal(value) {
10
10
  return 'function' == typeof value ? value.toString() : JSON.stringify(value);
11
11
  }
12
- const libCssExtractLoader_loader = function(content) {
12
+ const libCssExtractLoader_rslib_entry_loader = function(content) {
13
13
  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;
14
14
  };
15
15
  const pitch = function(request, _, _data) {
@@ -121,5 +121,5 @@ const pitch = function(request, _, _data) {
121
121
  handleExports(exports);
122
122
  });
123
123
  };
124
- /* ESM default export */ const libCssExtractLoader = libCssExtractLoader_loader;
125
- export { libCssExtractLoader as default, pitch };
124
+ /* ESM default export */ const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
125
+ export { libCssExtractLoader_rslib_entry_ as default, pitch };
@@ -0,0 +1,4 @@
1
+ import { type RsbuildInstance } from '@rsbuild/core';
2
+ import type { RslibConfig } from '../types/config';
3
+ import type { BuildOptions } from './commands';
4
+ export declare function build(config: RslibConfig, options?: Pick<BuildOptions, 'lib' | 'watch'>): Promise<RsbuildInstance>;
@@ -1,5 +1,6 @@
1
- import { type RsbuildMode } from '@rsbuild/core';
1
+ import type { RsbuildMode } from '@rsbuild/core';
2
2
  export type CommonOptions = {
3
+ root?: string;
3
4
  config?: string;
4
5
  envMode?: string;
5
6
  lib?: string[];
@@ -8,8 +9,8 @@ export type BuildOptions = CommonOptions & {
8
9
  watch?: boolean;
9
10
  };
10
11
  export type InspectOptions = CommonOptions & {
11
- mode: RsbuildMode;
12
- output: string;
12
+ mode?: RsbuildMode;
13
+ output?: string;
13
14
  verbose?: boolean;
14
15
  };
15
16
  export declare function runCli(): void;
@@ -0,0 +1,6 @@
1
+ import type { RslibConfig } from '../types';
2
+ import type { CommonOptions } from './commands';
3
+ export declare function loadRslibConfig(options: CommonOptions): Promise<{
4
+ content: RslibConfig;
5
+ filePath: string;
6
+ }>;
@@ -0,0 +1,4 @@
1
+ import { type RsbuildInstance } from '@rsbuild/core';
2
+ import type { RslibConfig } from '../types/config';
3
+ import type { InspectOptions } from './commands';
4
+ export declare function inspect(config: RslibConfig, options?: Pick<InspectOptions, 'lib' | 'mode' | 'output' | 'verbose'>): Promise<RsbuildInstance>;
@@ -1,3 +1,3 @@
1
1
  import type { RsbuildInstance } from '@rsbuild/core';
2
- import type { RslibConfig } from './types';
2
+ import type { RslibConfig } from '../types';
3
3
  export declare function startMFDevServer(config: RslibConfig): Promise<RsbuildInstance | undefined>;
@@ -0,0 +1,7 @@
1
+ export declare function watchFilesForRestart(files: string[], restart: () => Promise<void>): Promise<void>;
2
+ type Cleaner = () => Promise<unknown> | unknown;
3
+ /**
4
+ * Add a cleaner to handle side effects
5
+ */
6
+ export declare const onBeforeRestart: (cleaner: Cleaner) => void;
7
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { type EnvironmentConfig, type RsbuildConfig } from '@rsbuild/core';
2
- import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
2
+ import type { AutoExternal, BannerAndFooter, 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.
@@ -12,7 +12,10 @@ export declare function loadConfig({ cwd, path, envMode, }: {
12
12
  cwd?: string;
13
13
  path?: string;
14
14
  envMode?: string;
15
- }): Promise<RslibConfig>;
15
+ }): Promise<{
16
+ content: RslibConfig;
17
+ filePath: string;
18
+ }>;
16
19
  export declare const composeAutoExternalConfig: (options: {
17
20
  autoExternal: AutoExternal;
18
21
  pkgJson?: PkgJson;
@@ -23,9 +26,7 @@ export declare function composeBannerFooterConfig(banner: BannerAndFooter, foote
23
26
  export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<RsbuildConfig['source']>['decorators']>['version']): RsbuildConfig;
24
27
  export declare function createConstantRsbuildConfig(): Promise<RsbuildConfig>;
25
28
  export declare const composeModuleImportWarn: (request: string) => string;
26
- export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig, path?: string): Promise<{
27
- format: Format;
28
- config: RsbuildConfig;
29
- }[]>;
29
+ export declare const appendEntryQuery: (entry: RsbuildConfigEntry) => RsbuildConfigEntry;
30
+ export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
30
31
  export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<Record<string, EnvironmentConfig>>;
31
32
  export declare const pruneEnvironments: (environments: Record<string, EnvironmentConfig>, libs?: string[]) => Record<string, EnvironmentConfig>;
@@ -1,6 +1,10 @@
1
1
  export declare const DEFAULT_CONFIG_NAME = "rslib.config";
2
2
  export declare const DEFAULT_CONFIG_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
3
3
  export declare const SWC_HELPERS = "@swc/helpers";
4
+ export declare const RSLIB_ENTRY_QUERY = "__rslib_entry__";
5
+ export declare const SHEBANG_PREFIX = "#!";
6
+ export declare const SHEBANG_REGEX: RegExp;
7
+ export declare const REACT_DIRECTIVE_REGEX: RegExp;
4
8
  export declare const JS_EXTENSIONS: string[];
5
9
  export declare const CSS_EXTENSIONS: string[];
6
10
  export declare const ENTRY_EXTENSIONS: string[];
@@ -1,11 +1,11 @@
1
- import type { Compiler, RspackPluginInstance } from '@rspack/core';
1
+ import type { Rspack } from '@rsbuild/core';
2
2
  type Options = {
3
3
  include: RegExp;
4
4
  };
5
- declare class RemoveCssExtractAssetPlugin implements RspackPluginInstance {
5
+ declare class RemoveCssExtractAssetPlugin implements Rspack.RspackPluginInstance {
6
6
  readonly name: string;
7
7
  options: Options;
8
8
  constructor(options: Options);
9
- apply(compiler: Compiler): void;
9
+ apply(compiler: Rspack.Compiler): void;
10
10
  }
11
11
  export { RemoveCssExtractAssetPlugin };
@@ -1,4 +1,4 @@
1
- import type { LoaderDefinition } from '@rspack/core';
1
+ import type { Rspack } from '@rsbuild/core';
2
2
  export interface CssExtractRspackLoaderOptions {
3
3
  emit?: boolean;
4
4
  esModule?: boolean;
@@ -6,6 +6,6 @@ export interface CssExtractRspackLoaderOptions {
6
6
  defaultExport?: boolean;
7
7
  rootDir?: string;
8
8
  }
9
- declare const loader: LoaderDefinition;
10
- export declare const pitch: LoaderDefinition['pitch'];
9
+ declare const loader: Rspack.LoaderDefinition;
10
+ export declare const pitch: Rspack.LoaderDefinition['pitch'];
11
11
  export default loader;
@@ -1,7 +1,9 @@
1
1
  export { prepareCli } from './cli/prepare';
2
2
  export { runCli } from './cli/commands';
3
+ export { build } from './cli/build';
4
+ export { inspect } from './cli/inspect';
5
+ export { startMFDevServer } from './cli/mf';
3
6
  export { defineConfig, loadConfig, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, } from './config';
4
- export { build } from './build';
5
7
  export { logger } from './utils/logger';
6
8
  export type * from './types';
7
9
  export declare const version: string;
@@ -0,0 +1,4 @@
1
+ import { type RsbuildConfig } from '@rsbuild/core';
2
+ export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, }: {
3
+ enabledImportMetaUrlShim: boolean;
4
+ }) => RsbuildConfig;
@@ -0,0 +1,3 @@
1
+ import type { Rspack } from '@rsbuild/core';
2
+ declare const loader: Rspack.LoaderDefinition;
3
+ export default loader;
@@ -1,3 +1,4 @@
1
1
  import { type RsbuildPlugin } from '@rsbuild/core';
2
+ export declare const importMetaUrlShim = "const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {\n return typeof document === 'undefined'\n ? new (require('url'.replace('', '')).URL)('file:' + __filename).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href;\n})();\n";
2
3
  export declare const pluginCjsImportMetaUrlShim: () => RsbuildPlugin;
3
4
  export declare const pluginEsmRequireShim: () => RsbuildPlugin;
@@ -4,6 +4,13 @@ export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
4
4
  export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
5
5
  export type LatestEcmaVersions = 'es2024' | 'esnext';
6
6
  export type EcmaScriptVersion = FixedEcmaVersions | LatestEcmaVersions;
7
+ export type RsbuildConfigWithLibInfo = {
8
+ id?: string;
9
+ format: Format;
10
+ config: RsbuildConfig;
11
+ };
12
+ export type RsbuildConfigEntry = NonNullable<NonNullable<RsbuildConfig['source']>['entry']>;
13
+ export type RsbuildConfigEntryItem = RsbuildConfigEntry[string];
7
14
  export type RsbuildConfigOutputTarget = NonNullable<RsbuildConfig['output']>['target'];
8
15
  export type Syntax = EcmaScriptVersion | string[];
9
16
  export type Dts = (Pick<PluginDtsOptions, 'bundle' | 'distPath' | 'abortOnError' | 'build'> & {
@@ -34,56 +41,70 @@ export type Redirect = {
34
41
  style?: boolean;
35
42
  };
36
43
  export interface LibConfig extends RsbuildConfig {
44
+ /**
45
+ * The unique identifier of the library.
46
+ * @defaultValue `undefined`
47
+ * @see {@link https://lib.rsbuild.dev/config/lib/id}
48
+ */
49
+ id?: string;
37
50
  /**
38
51
  * Output format for the generated JavaScript files.
39
- * @default undefined
52
+ * @defaultValue `undefined`
53
+ * @see {@link https://lib.rsbuild.dev/config/lib/format}
40
54
  */
41
55
  format?: Format;
42
56
  /**
43
57
  * Whether to bundle the library.
44
- * @default true
58
+ * @defaultValue `true`
59
+ * @see {@link https://lib.rsbuild.dev/config/lib/bundle}
45
60
  */
46
61
  bundle?: boolean;
47
62
  /**
48
- * Whether to automatically set the file extension based on the `format` option in the JavaScript output files.
49
- * @default true
63
+ * Whether to automatically set the file extension based on {@link format} option in the JavaScript output files.
64
+ * @defaultValue `true`
65
+ * @see {@link https://lib.rsbuild.dev/config/lib/auto-extension}
50
66
  */
51
67
  autoExtension?: boolean;
52
68
  /**
53
69
  * Whether to automatically externalize dependencies of different dependency types and do not bundle them.
54
- * @default true
70
+ * @defaultValue `true`
71
+ * @see {@link https://lib.rsbuild.dev/config/lib/auto-external}
55
72
  */
56
73
  autoExternal?: AutoExternal;
57
74
  /**
58
- * Configure the redirect of the import paths, applicable when `bundle: false`.
59
- * @default {}
75
+ * Configure the redirect of the import paths, applicable {@link bundle} is set to `false`.
76
+ * @defaultValue `{}`
77
+ * @see {@link https://lib.rsbuild.dev/config/lib/redirect}
60
78
  */
61
79
  redirect?: Redirect;
62
80
  /**
63
81
  * Configure the syntax to which JavaScript and CSS will be downgraded.
64
- * Support ECMAScript version and browserslist query.
65
- * @default 'esnext'
82
+ * @defaultValue `'esnext'`
83
+ * @see {@link https://lib.rsbuild.dev/config/lib/syntax}
66
84
  */
67
85
  syntax?: Syntax;
68
86
  /**
69
87
  * Whether to import SWC helper functions from `@swc/helpers` instead of inlining them.
70
- * @default false
88
+ * @defaultValue `false`
89
+ * @see {@link https://lib.rsbuild.dev/config/lib/external-helpers}
71
90
  */
72
91
  externalHelpers?: boolean;
73
92
  /**
74
93
  * Inject content into the top of each JS, CSS or DTS file.
75
- * @default {}
94
+ * @defaultValue `{}`
95
+ * @see {@link https://lib.rsbuild.dev/config/lib/banner}
76
96
  */
77
97
  banner?: BannerAndFooter;
78
98
  /**
79
99
  * Inject content into the bottom of each JS, CSS or DTS file.
80
- * @default {}
100
+ * @defaultValue `{}`
101
+ * @see {@link https://lib.rsbuild.dev/config/lib/footer}
81
102
  */
82
103
  footer?: BannerAndFooter;
83
104
  /**
84
105
  * Configure the shims for CommonJS and ESM output.
85
106
  *
86
- * @default
107
+ * @defaultValue
87
108
  * ```js
88
109
  * const defaultShims = {
89
110
  * cjs: {
@@ -96,16 +117,19 @@ export interface LibConfig extends RsbuildConfig {
96
117
  * },
97
118
  * };
98
119
  * ```
120
+ * @see {@link https://lib.rsbuild.dev/config/lib/shims}
99
121
  */
100
122
  shims?: Shims;
101
123
  /**
102
124
  * Configure the generation of the TypeScript declaration files.
103
- * @default false
125
+ * @defaultValue `false`
126
+ * @see {@link https://lib.rsbuild.dev/config/lib/dts}
104
127
  */
105
128
  dts?: Dts;
106
129
  /**
107
130
  * The export name of the UMD bundle.
108
- * @default undefined
131
+ * @defaultValue `undefined`
132
+ * @see {@link https://lib.rsbuild.dev/config/lib/umd-name}
109
133
  */
110
134
  umdName?: string;
111
135
  }
@@ -6,3 +6,7 @@ export type PkgJson = {
6
6
  devDependencies?: Record<string, string>;
7
7
  optionalDependencies?: Record<string, string>;
8
8
  };
9
+ export type DeepRequired<T> = Required<{
10
+ [K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
11
+ }>;
12
+ export type ExcludesFalse = <T>(x: T | false | undefined | null) => x is T;
@@ -1,3 +1,4 @@
1
+ import type { RsbuildPlugins } from '@rsbuild/core';
1
2
  import color from 'picocolors';
2
3
  import type { LibConfig, PkgJson } from '../types';
3
4
  /**
@@ -6,11 +7,17 @@ import type { LibConfig, PkgJson } from '../types';
6
7
  */
7
8
  export declare const nodeBuiltInModules: Array<string | RegExp>;
8
9
  export declare function calcLongestCommonPath(absPaths: string[]): Promise<string | null>;
10
+ export declare function getAbsolutePath(base: string, filepath: string): string;
9
11
  export declare const readPackageJson: (rootPath: string) => undefined | PkgJson;
10
12
  export declare const isObject: (obj: unknown) => obj is Record<string, any>;
11
13
  export declare const isEmptyObject: (obj: object) => boolean;
12
14
  export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
13
15
  export declare function omit<T extends object, U extends keyof T>(obj: T, keysObj: Record<U, boolean>): Omit<T, keyof U>;
14
- export declare function isPluginIncluded(config: LibConfig, pluginName: string): boolean;
16
+ export declare function isPluginIncluded(pluginName: string, plugins?: RsbuildPlugins): boolean;
15
17
  export declare function checkMFPlugin(config: LibConfig): boolean;
18
+ export declare function debounce<T extends (...args: any[]) => void>(func: T, wait: number): (...args: Parameters<T>) => void;
19
+ /**
20
+ * Check if running in a TTY context
21
+ */
22
+ export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
16
23
  export { color };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.0.18",
3
+ "version": "0.1.1",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://lib.rsbuild.dev",
6
6
  "bugs": {
@@ -32,19 +32,19 @@
32
32
  "compiled"
33
33
  ],
34
34
  "dependencies": {
35
- "@rsbuild/core": "~1.1.0",
35
+ "@rsbuild/core": "~1.1.6",
36
36
  "tinyglobby": "^0.2.10",
37
- "rsbuild-plugin-dts": "0.0.18"
37
+ "rsbuild-plugin-dts": "0.1.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@rspack/core": "1.0.8",
41
40
  "@types/fs-extra": "^11.0.4",
41
+ "chokidar": "^4.0.1",
42
42
  "commander": "^12.1.0",
43
43
  "fs-extra": "^11.2.0",
44
44
  "memfs": "^4.14.0",
45
45
  "picocolors": "1.1.1",
46
46
  "prebundle": "1.2.5",
47
- "rslib": "npm:@rslib/core@0.0.17",
47
+ "rslib": "npm:@rslib/core@0.1.0",
48
48
  "rslog": "^1.2.3",
49
49
  "tsconfck": "3.1.4",
50
50
  "typescript": "^5.6.3",
@@ -1,4 +0,0 @@
1
- import { type RsbuildInstance } from '@rsbuild/core';
2
- import type { BuildOptions } from './cli/commands';
3
- import type { RslibConfig } from './types/config';
4
- export declare function build(config: RslibConfig, options?: BuildOptions): Promise<RsbuildInstance>;