@rslib/core 0.0.0-next-20240927040621

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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/bin/rslib.js +14 -0
  4. package/compiled/commander/index.d.ts +971 -0
  5. package/compiled/commander/index.js +3805 -0
  6. package/compiled/commander/license +22 -0
  7. package/compiled/commander/package.json +1 -0
  8. package/compiled/fast-glob/index.d.ts +237 -0
  9. package/compiled/fast-glob/index.js +7309 -0
  10. package/compiled/fast-glob/license +21 -0
  11. package/compiled/fast-glob/package.json +1 -0
  12. package/compiled/picocolors/index.d.ts +56 -0
  13. package/compiled/picocolors/index.js +150 -0
  14. package/compiled/picocolors/license +15 -0
  15. package/compiled/picocolors/package.json +1 -0
  16. package/compiled/rslog/index.d.ts +66 -0
  17. package/compiled/rslog/index.js +334 -0
  18. package/compiled/rslog/license +21 -0
  19. package/compiled/rslog/package.json +1 -0
  20. package/dist/index.js +1894 -0
  21. package/dist-types/build.d.ts +4 -0
  22. package/dist-types/cli/commands.d.ts +14 -0
  23. package/dist-types/cli/prepare.d.ts +1 -0
  24. package/dist-types/config.d.ts +30 -0
  25. package/dist-types/constant.d.ts +8 -0
  26. package/dist-types/index.d.ts +7 -0
  27. package/dist-types/plugins/cjsShim.d.ts +2 -0
  28. package/dist-types/types/config/index.d.ts +45 -0
  29. package/dist-types/types/index.d.ts +2 -0
  30. package/dist-types/types/utils.d.ts +6 -0
  31. package/dist-types/utils/extension.d.ts +10 -0
  32. package/dist-types/utils/helper.d.ts +14 -0
  33. package/dist-types/utils/logger.d.ts +5 -0
  34. package/dist-types/utils/syntax.d.ts +13 -0
  35. package/dist-types/utils/tsconfig.d.ts +3 -0
  36. package/package.json +77 -0
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,14 @@
1
+ import type { RsbuildMode } from '@rsbuild/core';
2
+ export type CommonOptions = {
3
+ config?: string;
4
+ envMode?: string;
5
+ };
6
+ export type BuildOptions = CommonOptions & {
7
+ watch?: boolean;
8
+ };
9
+ export type InspectOptions = CommonOptions & {
10
+ mode: RsbuildMode;
11
+ output: string;
12
+ verbose?: boolean;
13
+ };
14
+ export declare function runCli(): void;
@@ -0,0 +1 @@
1
+ export declare function prepareCli(): void;
@@ -0,0 +1,30 @@
1
+ import { type RsbuildConfig, type RsbuildInstance } from '@rsbuild/core';
2
+ import type { AutoExternal, BannerAndFooter, Format, PkgJson, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
3
+ /**
4
+ * This function helps you to autocomplete configuration types.
5
+ * It accepts a Rslib config object, or a function that returns a config.
6
+ */
7
+ export declare function defineConfig(config: RslibConfig): RslibConfig;
8
+ export declare function defineConfig(config: RslibConfigSyncFn): RslibConfigSyncFn;
9
+ export declare function defineConfig(config: RslibConfigAsyncFn): RslibConfigAsyncFn;
10
+ export declare function defineConfig(config: RslibConfigExport): RslibConfigExport;
11
+ export declare function loadConfig({ cwd, path, envMode, }: {
12
+ cwd?: string;
13
+ path?: string;
14
+ envMode?: string;
15
+ }): Promise<RslibConfig>;
16
+ export declare const composeAutoExternalConfig: (options: {
17
+ autoExternal: AutoExternal;
18
+ pkgJson?: PkgJson;
19
+ userExternals?: NonNullable<RsbuildConfig["output"]>["externals"];
20
+ }) => RsbuildConfig;
21
+ export declare function composeMinifyConfig(minify: NonNullable<RsbuildConfig['output']>['minify']): RsbuildConfig;
22
+ export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter): RsbuildConfig;
23
+ export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<RsbuildConfig['source']>['decorators']>['version']): RsbuildConfig;
24
+ export declare function createConstantRsbuildConfig(): Promise<RsbuildConfig>;
25
+ export declare const composeModuleImportWarn: (request: string) => string;
26
+ export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig, path?: string): Promise<{
27
+ format: Format;
28
+ config: RsbuildConfig;
29
+ }[]>;
30
+ export declare function initRsbuild(rslibConfig: RslibConfig): Promise<RsbuildInstance>;
@@ -0,0 +1,8 @@
1
+ export declare const DEFAULT_CONFIG_NAME = "rslib.config";
2
+ export declare const DEFAULT_CONFIG_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
3
+ export declare const SWC_HELPERS = "@swc/helpers";
4
+ export declare const JS_EXTENSIONS: string[];
5
+ export declare const CSS_EXTENSIONS: string[];
6
+ export declare const ENTRY_EXTENSIONS: string[];
7
+ export declare const JS_EXTENSIONS_PATTERN: RegExp;
8
+ export declare const ENTRY_EXTENSIONS_PATTERN: RegExp;
@@ -0,0 +1,7 @@
1
+ export { prepareCli } from './cli/prepare';
2
+ export { runCli } from './cli/commands';
3
+ export { defineConfig, loadConfig } from './config';
4
+ export { build } from './build';
5
+ export { logger } from './utils/logger';
6
+ export type * from './types';
7
+ export declare const version: string;
@@ -0,0 +1,2 @@
1
+ import { type RsbuildPlugin } from '@rsbuild/core';
2
+ export declare const pluginCjsShim: () => RsbuildPlugin;
@@ -0,0 +1,45 @@
1
+ import type { RsbuildConfig } from '@rsbuild/core';
2
+ export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
3
+ export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
4
+ export type LatestEcmaVersions = 'es2024' | 'esnext';
5
+ export type EcmaScriptVersion = FixedEcmaVersions | LatestEcmaVersions;
6
+ export type RsbuildConfigOutputTarget = NonNullable<RsbuildConfig['output']>['target'];
7
+ export type Syntax = EcmaScriptVersion | string[];
8
+ export type Dts = {
9
+ bundle: boolean;
10
+ distPath?: string;
11
+ abortOnError?: boolean;
12
+ } | false;
13
+ export type AutoExternal = boolean | {
14
+ dependencies?: boolean;
15
+ devDependencies?: boolean;
16
+ peerDependencies?: boolean;
17
+ };
18
+ export type BannerAndFooter = {
19
+ js?: string;
20
+ css?: string;
21
+ dts?: string;
22
+ };
23
+ export interface LibConfig extends RsbuildConfig {
24
+ bundle?: boolean;
25
+ format?: Format;
26
+ autoExtension?: boolean;
27
+ autoExternal?: AutoExternal;
28
+ /** Support esX and browserslist query */
29
+ syntax?: Syntax;
30
+ externalHelpers?: boolean;
31
+ banner?: BannerAndFooter;
32
+ footer?: BannerAndFooter;
33
+ dts?: Dts;
34
+ }
35
+ export interface RslibConfig extends RsbuildConfig {
36
+ lib: LibConfig[];
37
+ }
38
+ export type ConfigParams = {
39
+ env: string;
40
+ command: string;
41
+ envMode?: string;
42
+ };
43
+ export type RslibConfigSyncFn = (env: ConfigParams) => RslibConfig;
44
+ export type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibConfig>;
45
+ export type RslibConfigExport = RslibConfig | RslibConfigSyncFn | RslibConfigAsyncFn;
@@ -0,0 +1,2 @@
1
+ export type * from './config';
2
+ export type * from './utils';
@@ -0,0 +1,6 @@
1
+ export type PkgJson = {
2
+ dependencies?: Record<string, string>;
3
+ peerDependencies?: Record<string, string>;
4
+ devDependencies?: Record<string, string>;
5
+ [key: string]: unknown;
6
+ };
@@ -0,0 +1,10 @@
1
+ import type { Format, PkgJson } from '../types';
2
+ export declare const getDefaultExtension: (options: {
3
+ format: Format;
4
+ pkgJson?: PkgJson;
5
+ autoExtension: boolean;
6
+ }) => {
7
+ jsExtension: string;
8
+ dtsExtension: string;
9
+ isModule?: boolean;
10
+ };
@@ -0,0 +1,14 @@
1
+ import color from 'picocolors';
2
+ import type { PkgJson } from '../types';
3
+ /**
4
+ * Node.js built-in modules.
5
+ * Copied from https://github.com/webpack/webpack/blob/dd44b206a9c50f4b4cb4d134e1a0bd0387b159a3/lib/node/NodeTargetPlugin.js#L12-L72
6
+ */
7
+ export declare const nodeBuiltInModules: Array<string | RegExp>;
8
+ export declare function calcLongestCommonPath(absPaths: string[]): Promise<string | null>;
9
+ export declare const readPackageJson: (rootPath: string) => undefined | PkgJson;
10
+ export declare const isObject: (obj: unknown) => obj is Record<string, any>;
11
+ export declare const isEmptyObject: (obj: object) => boolean;
12
+ export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
13
+ export declare function omit<T extends object, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Omit<T, U>;
14
+ export { color };
@@ -0,0 +1,5 @@
1
+ import { type Logger, logger } from 'rslog';
2
+ export declare const isDebug: () => boolean;
3
+ export declare const debug: (message: string | (() => string)) => void;
4
+ export { logger };
5
+ export type { Logger };
@@ -0,0 +1,13 @@
1
+ import type { RsbuildConfig, Rspack } from '@rsbuild/core';
2
+ import type { FixedEcmaVersions, LatestEcmaVersions, RsbuildConfigOutputTarget, Syntax } from '../types/config';
3
+ export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOutputTarget>, string[]>;
4
+ /**
5
+ * The esX to browserslist mapping is transformed from esbuild:
6
+ * https://github.com/evanw/esbuild/blob/main/internal/compat/js_table.go
7
+ * It does not completely align with the browserslist query of Rsbuild now:
8
+ * https://github.com/rspack-contrib/browserslist-to-es-version
9
+ * TODO: align with Rsbuild, we may should align with SWC
10
+ */
11
+ export declare const ESX_TO_BROWSERSLIST: Record<FixedEcmaVersions, Record<string, string | string[]>> & Record<LatestEcmaVersions, (target: RsbuildConfigOutputTarget) => string[]>;
12
+ export declare function transformSyntaxToRspackTarget(syntax: Syntax): Rspack.Configuration['target'];
13
+ export declare function transformSyntaxToBrowserslist(syntax: Syntax, target?: NonNullable<RsbuildConfig['output']>['target']): NonNullable<NonNullable<RsbuildConfig['output']>['overrideBrowserslist']>;
@@ -0,0 +1,3 @@
1
+ export declare function loadTsconfig(root: string, tsconfigPath?: string): Promise<{
2
+ compilerOptions?: Record<string, any>;
3
+ }>;
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@rslib/core",
3
+ "version": "0.0.0-next-20240927040621",
4
+ "description": "The Rspack-based library build tool.",
5
+ "homepage": "https://lib.rsbuild.dev",
6
+ "bugs": {
7
+ "url": "https://github.com/web-infra-dev/rslib/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/web-infra-dev/rslib",
12
+ "directory": "packages/core"
13
+ },
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist-types/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "main": "./dist/index.js",
24
+ "types": "./dist-types/index.d.ts",
25
+ "bin": {
26
+ "rslib": "./bin/rslib.js"
27
+ },
28
+ "files": [
29
+ "bin",
30
+ "dist",
31
+ "dist-types",
32
+ "compiled"
33
+ ],
34
+ "dependencies": {
35
+ "@rsbuild/core": "1.0.7",
36
+ "rsbuild-plugin-dts": "0.0.0-next-20240927040621"
37
+ },
38
+ "devDependencies": {
39
+ "@types/fs-extra": "^11.0.4",
40
+ "commander": "^12.1.0",
41
+ "fast-glob": "^3.3.2",
42
+ "fs-extra": "^11.2.0",
43
+ "memfs": "^4.12.0",
44
+ "picocolors": "1.1.0",
45
+ "prebundle": "1.2.2",
46
+ "rslib": "npm:@rslib/core@0.0.7",
47
+ "rslog": "^1.2.3",
48
+ "tsconfck": "3.1.3",
49
+ "typescript": "^5.6.2",
50
+ "@rslib/tsconfig": "0.0.1"
51
+ },
52
+ "peerDependencies": {
53
+ "@microsoft/api-extractor": "^7",
54
+ "typescript": "^5"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@microsoft/api-extractor": {
58
+ "optional": true
59
+ },
60
+ "typescript": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "engines": {
65
+ "node": ">=16.0.0"
66
+ },
67
+ "publishConfig": {
68
+ "access": "public",
69
+ "provenance": true,
70
+ "registry": "https://registry.npmjs.org/"
71
+ },
72
+ "scripts": {
73
+ "build": "rslib build",
74
+ "dev": "rslib build --watch",
75
+ "prebundle": "prebundle"
76
+ }
77
+ }