rolldown 1.0.0-beta.2-commit.5deb279 → 1.0.0-beta.21
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/bin/cli.mjs +2 -0
- package/dist/{cjs/cli.cjs → cli.cjs} +630 -603
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{esm/cli.mjs → cli.mjs} +605 -575
- package/dist/config.cjs +12 -0
- package/dist/config.d.cts +10 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.cjs +107 -0
- package/dist/experimental-index.d.cts +63 -0
- package/dist/experimental-index.d.mts +63 -0
- package/dist/experimental-index.mjs +82 -0
- package/dist/experimental-runtime-types.d.ts +52 -0
- package/dist/filter-index.cjs +105 -0
- package/dist/filter-index.d.cts +4 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -14
- package/dist/parallel-plugin-worker.d.cts +1 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -12
- package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
- package/dist/parallel-plugin.d.cts +14 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.d.cts +9 -0
- package/dist/parse-ast-index.d.mts +9 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding--Ro_HG7S.d.mts +1246 -0
- package/dist/shared/binding-DBnJxycu.d.cts +1246 -0
- package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
- package/dist/shared/define-config-LuFmoc43.d.cts +1204 -0
- package/dist/shared/define-config-WLh0sQOM.d.mts +1204 -0
- package/dist/shared/load-config-DUa6Uqtc.mjs +119 -0
- package/dist/shared/load-config-juy1xxPU.cjs +125 -0
- package/dist/shared/misc-BKp5iIef.cjs +67 -0
- package/dist/shared/misc-BN0nse6C.mjs +25 -0
- package/dist/shared/parse-ast-index-CVVmsBjK.cjs +738 -0
- package/dist/shared/parse-ast-index-DW8kbzjr.mjs +616 -0
- package/dist/shared/{prompt-Nfm4Xz36.mjs → prompt-C5jz26Zn.mjs} +247 -246
- package/dist/shared/{prompt-B7tq3GL9.cjs → prompt-QNI93ne7.cjs} +250 -250
- package/dist/shared/src-LzfUVOSn.mjs +4647 -0
- package/dist/shared/src-ajsKFM6g.cjs +4851 -0
- package/package.json +65 -67
- package/bin/cli.js +0 -2
- package/dist/cjs/experimental-index.cjs +0 -79
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parse-ast-index.cjs +0 -57
- package/dist/esm/experimental-index.mjs +0 -56
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -55
- package/dist/shared/binding-l7VLSKnB.mjs +0 -610
- package/dist/shared/binding-orkvONpS.cjs +0 -661
- package/dist/shared/src-CV5Vk_cS.cjs +0 -2828
- package/dist/shared/src-CwOjWVUb.mjs +0 -2647
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/build.js +0 -22
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/experimental.js +0 -13
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/index.js +0 -7
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -12
- package/dist/types/api/rolldown/rolldown-build.js +0 -43
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/index.js +0 -8
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watch-emitter.js +0 -69
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/api/watch/watcher.js +0 -66
- package/dist/types/binding.d.ts +0 -1327
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/alias-plugin.js +0 -4
- package/dist/types/builtin-plugin/constructors.d.ts +0 -20
- package/dist/types/builtin-plugin/constructors.js +0 -68
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/replace-plugin.js +0 -29
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/transform-plugin.js +0 -16
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/builtin-plugin/utils.js +0 -19
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/alias.js +0 -63
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/index.js +0 -127
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/normalize.js +0 -48
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/arguments/utils.js +0 -67
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/colors.js +0 -17
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/bundle.js +0 -203
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/commands/help.js +0 -88
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/index.js +0 -27
- package/dist/types/cli/load-config.d.ts +0 -3
- package/dist/types/cli/load-config.js +0 -95
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/cli/logger.js +0 -35
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin-context.js +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/constants/plugin.js +0 -69
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/experimental-index.js +0 -9
- package/dist/types/index.d.ts +0 -28
- package/dist/types/index.js +0 -7
- package/dist/types/log/logHandler.d.ts +0 -4
- package/dist/types/log/logHandler.js +0 -25
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logger.js +0 -107
- package/dist/types/log/logging.d.ts +0 -11
- package/dist/types/log/logging.js +0 -11
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/log/logs.js +0 -86
- package/dist/types/options/input-options.d.ts +0 -170
- package/dist/types/options/input-options.js +0 -1
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-input-options.js +0 -21
- package/dist/types/options/normalized-output-options.d.ts +0 -67
- package/dist/types/options/normalized-output-options.js +0 -99
- package/dist/types/options/output-options.d.ts +0 -86
- package/dist/types/options/output-options.js +0 -1
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/options/watch-options.js +0 -1
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin-worker.js +0 -31
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parallel-plugin.js +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -4
- package/dist/types/parse-ast-index.js +0 -73
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-build-hooks.js +0 -213
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-hook-filter.js +0 -39
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-output-hooks.js +0 -189
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -15
- package/dist/types/plugin/bindingify-plugin.js +0 -124
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/hook-filter.js +0 -1
- package/dist/types/plugin/index.d.ts +0 -126
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -15
- package/dist/types/plugin/minimal-plugin-context.js +0 -25
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/parallel-plugin.js +0 -6
- package/dist/types/plugin/plugin-context-data.d.ts +0 -16
- package/dist/types/plugin/plugin-context-data.js +0 -55
- package/dist/types/plugin/plugin-context.d.ts +0 -52
- package/dist/types/plugin/plugin-context.js +0 -108
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/plugin-driver.js +0 -88
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -17
- package/dist/types/plugin/transform-plugin-context.js +0 -37
- package/dist/types/types/assert.d.ts +0 -13
- package/dist/types/types/assert.js +0 -1
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/config-export.js +0 -1
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/misc.js +0 -1
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-info.js +0 -1
- package/dist/types/types/module-side-effects.d.ts +0 -10
- package/dist/types/types/module-side-effects.js +0 -1
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/output-bundle.js +0 -1
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-options.js +0 -1
- package/dist/types/types/rolldown-output.d.ts +0 -63
- package/dist/types/types/rolldown-output.js +0 -1
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/schema.js +0 -1
- package/dist/types/types/sourcemap.d.ts +0 -13
- package/dist/types/types/sourcemap.js +0 -16
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/types/utils.js +0 -1
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/asset-source.js +0 -8
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/async-flatten.js +0 -7
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-input-options.js +0 -225
- package/dist/types/utils/bindingify-output-options.d.ts +0 -3
- package/dist/types/utils/bindingify-output-options.js +0 -92
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/code-frame.js +0 -46
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/compose-js-plugins.js +0 -400
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler-option.js +0 -53
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/create-bundler.js +0 -15
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/define-config.js +0 -3
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/error.js +0 -65
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/initialize-parallel-plugins.js +0 -54
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/misc.js +0 -22
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-hook.js +0 -21
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-plugin-option.js +0 -35
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/normalize-string-or-regex.js +0 -14
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/plugin/index.js +0 -7
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-module-info.js +0 -19
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.js +0 -43
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-rendered-module.js +0 -10
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.js +0 -16
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.js +0 -29
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/transform-to-rollup-output.js +0 -165
- package/dist/types/utils/validator.d.ts +0 -7
- package/dist/types/utils/validator.js +0 -275
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BuiltinPlugin } from './constructors';
|
|
2
|
-
type AliasPluginAlias = {
|
|
3
|
-
find: string | RegExp;
|
|
4
|
-
replacement: string;
|
|
5
|
-
};
|
|
6
|
-
type AliasPluginConfig = {
|
|
7
|
-
entries: AliasPluginAlias[];
|
|
8
|
-
};
|
|
9
|
-
export declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
|
|
10
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type BindingBuiltinPluginName, BindingGlobImportPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingJsonPluginConfig, BindingBuildImportAnalysisPluginConfig, type BindingViteResolvePluginConfig, BindingModuleFederationPluginOption, BindingRemote } from '../binding';
|
|
2
|
-
export declare class BuiltinPlugin {
|
|
3
|
-
name: BindingBuiltinPluginName;
|
|
4
|
-
_options?: unknown | undefined;
|
|
5
|
-
constructor(name: BindingBuiltinPluginName, _options?: unknown | undefined);
|
|
6
|
-
}
|
|
7
|
-
export declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
|
|
8
|
-
export declare function dynamicImportVarsPlugin(): BuiltinPlugin;
|
|
9
|
-
export declare function importGlobPlugin(config?: BindingGlobImportPluginConfig): BuiltinPlugin;
|
|
10
|
-
export declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
|
|
11
|
-
export declare function wasmHelperPlugin(): BuiltinPlugin;
|
|
12
|
-
export declare function wasmFallbackPlugin(): BuiltinPlugin;
|
|
13
|
-
export declare function loadFallbackPlugin(): BuiltinPlugin;
|
|
14
|
-
export declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
|
|
15
|
-
export declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
|
|
16
|
-
export declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, 'runtime'>): BuiltinPlugin;
|
|
17
|
-
export type ModuleFederationPluginOption = Omit<BindingModuleFederationPluginOption, 'remotes'> & {
|
|
18
|
-
remotes?: Record<string, string | BindingRemote>;
|
|
19
|
-
};
|
|
20
|
-
export declare function moduleFederationPlugin(config: ModuleFederationPluginOption): BuiltinPlugin;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { makeBuiltinPluginCallable } from './utils';
|
|
2
|
-
export class BuiltinPlugin {
|
|
3
|
-
name;
|
|
4
|
-
_options;
|
|
5
|
-
constructor(name,
|
|
6
|
-
// NOTE: has `_` to avoid conflict with `options` hook
|
|
7
|
-
_options) {
|
|
8
|
-
this.name = name;
|
|
9
|
-
this._options = _options;
|
|
10
|
-
this.name = name;
|
|
11
|
-
this._options = _options;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export function modulePreloadPolyfillPlugin(config) {
|
|
15
|
-
return new BuiltinPlugin('builtin:module-preload-polyfill', config);
|
|
16
|
-
}
|
|
17
|
-
export function dynamicImportVarsPlugin() {
|
|
18
|
-
return new BuiltinPlugin('builtin:dynamic-import-vars');
|
|
19
|
-
}
|
|
20
|
-
export function importGlobPlugin(config) {
|
|
21
|
-
return new BuiltinPlugin('builtin:import-glob', config);
|
|
22
|
-
}
|
|
23
|
-
export function manifestPlugin(config) {
|
|
24
|
-
return new BuiltinPlugin('builtin:manifest', config);
|
|
25
|
-
}
|
|
26
|
-
export function wasmHelperPlugin() {
|
|
27
|
-
return new BuiltinPlugin('builtin:wasm-helper');
|
|
28
|
-
}
|
|
29
|
-
export function wasmFallbackPlugin() {
|
|
30
|
-
return new BuiltinPlugin('builtin:wasm-fallback');
|
|
31
|
-
}
|
|
32
|
-
export function loadFallbackPlugin() {
|
|
33
|
-
return new BuiltinPlugin('builtin:load-fallback');
|
|
34
|
-
}
|
|
35
|
-
export function jsonPlugin(config) {
|
|
36
|
-
return new BuiltinPlugin('builtin:json', config);
|
|
37
|
-
}
|
|
38
|
-
export function buildImportAnalysisPlugin(config) {
|
|
39
|
-
return new BuiltinPlugin('builtin:build-import-analysis', config);
|
|
40
|
-
}
|
|
41
|
-
export function viteResolvePlugin(config) {
|
|
42
|
-
const builtinPlugin = new BuiltinPlugin('builtin:vite-resolve', {
|
|
43
|
-
...config,
|
|
44
|
-
runtime: process.versions.deno
|
|
45
|
-
? 'deno'
|
|
46
|
-
: process.versions.bun
|
|
47
|
-
? 'bun'
|
|
48
|
-
: 'node',
|
|
49
|
-
});
|
|
50
|
-
return makeBuiltinPluginCallable(builtinPlugin);
|
|
51
|
-
}
|
|
52
|
-
export function moduleFederationPlugin(config) {
|
|
53
|
-
return new BuiltinPlugin('builtin:module-federation', {
|
|
54
|
-
...config,
|
|
55
|
-
remotes: config.remotes &&
|
|
56
|
-
Object.entries(config.remotes).map(([name, remote]) => {
|
|
57
|
-
if (typeof remote === 'string') {
|
|
58
|
-
const [entryGlobalName] = remote.split('@');
|
|
59
|
-
const entry = remote.replace(entryGlobalName + '@', '');
|
|
60
|
-
return { entry, name };
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
...remote,
|
|
64
|
-
name: remote.name ?? name,
|
|
65
|
-
};
|
|
66
|
-
}),
|
|
67
|
-
});
|
|
68
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BindingReplacePluginConfig } from '../binding';
|
|
2
|
-
import { BuiltinPlugin } from './constructors';
|
|
3
|
-
/**
|
|
4
|
-
* Replaces targeted strings in files while bundling.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* // Basic usage
|
|
8
|
-
* ```js
|
|
9
|
-
* replacePlugin({
|
|
10
|
-
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
11
|
-
* __buildDate__: () => JSON.stringify(new Date()),
|
|
12
|
-
* __buildVersion: 15
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
* @example
|
|
16
|
-
* // With options
|
|
17
|
-
* ```js
|
|
18
|
-
* replacePlugin({
|
|
19
|
-
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
20
|
-
* __buildDate__: () => JSON.stringify(new Date()),
|
|
21
|
-
* __buildVersion: 15
|
|
22
|
-
* }, {
|
|
23
|
-
* preventAssignment: false,
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
export declare function replacePlugin(values?: BindingReplacePluginConfig['values'], options?: Omit<BindingReplacePluginConfig, 'values'>): BuiltinPlugin;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { BuiltinPlugin } from './constructors';
|
|
2
|
-
/**
|
|
3
|
-
* Replaces targeted strings in files while bundling.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* // Basic usage
|
|
7
|
-
* ```js
|
|
8
|
-
* replacePlugin({
|
|
9
|
-
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
10
|
-
* __buildDate__: () => JSON.stringify(new Date()),
|
|
11
|
-
* __buildVersion: 15
|
|
12
|
-
* })
|
|
13
|
-
* ```
|
|
14
|
-
* @example
|
|
15
|
-
* // With options
|
|
16
|
-
* ```js
|
|
17
|
-
* replacePlugin({
|
|
18
|
-
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
19
|
-
* __buildDate__: () => JSON.stringify(new Date()),
|
|
20
|
-
* __buildVersion: 15
|
|
21
|
-
* }, {
|
|
22
|
-
* preventAssignment: false,
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
export function replacePlugin(values = {}, options = {}) {
|
|
28
|
-
return new BuiltinPlugin('builtin:replace', { ...options, values });
|
|
29
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BuiltinPlugin } from './constructors';
|
|
2
|
-
import { BindingTransformPluginConfig } from '../binding';
|
|
3
|
-
type TransformPattern = string | RegExp | (RegExp | string)[];
|
|
4
|
-
export type TransformPluginConfig = Omit<BindingTransformPluginConfig, 'include' | 'exclude'> & {
|
|
5
|
-
include?: TransformPattern;
|
|
6
|
-
exclude?: TransformPattern;
|
|
7
|
-
};
|
|
8
|
-
export declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
|
|
9
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BuiltinPlugin } from './constructors';
|
|
2
|
-
import { normalizedStringOrRegex } from '../utils/normalize-string-or-regex';
|
|
3
|
-
function normalizeEcmaTransformPluginConfig(config) {
|
|
4
|
-
if (!config) {
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|
|
7
|
-
let normalizedConfig = {
|
|
8
|
-
...config,
|
|
9
|
-
exclude: normalizedStringOrRegex(config.exclude),
|
|
10
|
-
include: normalizedStringOrRegex(config.include),
|
|
11
|
-
};
|
|
12
|
-
return normalizedConfig;
|
|
13
|
-
}
|
|
14
|
-
export function transformPlugin(config) {
|
|
15
|
-
return new BuiltinPlugin('builtin:transform', normalizeEcmaTransformPluginConfig(config));
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BindingBuiltinPlugin, BindingCallableBuiltinPlugin } from '../binding';
|
|
2
|
-
import { BuiltinPlugin } from './constructors';
|
|
3
|
-
type BindingCallableBuiltinPluginLike = {
|
|
4
|
-
[K in keyof BindingCallableBuiltinPlugin]: BindingCallableBuiltinPlugin[K];
|
|
5
|
-
};
|
|
6
|
-
export declare function makeBuiltinPluginCallable(plugin: BuiltinPlugin): BuiltinPlugin & BindingCallableBuiltinPluginLike;
|
|
7
|
-
export declare function bindingifyBuiltInPlugin(plugin: BuiltinPlugin): BindingBuiltinPlugin;
|
|
8
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BindingCallableBuiltinPlugin } from '../binding';
|
|
2
|
-
export function makeBuiltinPluginCallable(plugin) {
|
|
3
|
-
let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
|
|
4
|
-
const wrappedPlugin = plugin;
|
|
5
|
-
for (const key in callablePlugin) {
|
|
6
|
-
// @ts-expect-error
|
|
7
|
-
wrappedPlugin[key] = function (...args) {
|
|
8
|
-
// @ts-expect-error
|
|
9
|
-
return callablePlugin[key](...args);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
return wrappedPlugin;
|
|
13
|
-
}
|
|
14
|
-
export function bindingifyBuiltInPlugin(plugin) {
|
|
15
|
-
return {
|
|
16
|
-
__name: plugin.name,
|
|
17
|
-
options: plugin._options,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { InputCliOptions } from '../../options/input-options';
|
|
2
|
-
import type { OutputCliOptions } from '../../options/output-options';
|
|
3
|
-
export interface CliOptions extends InputCliOptions, OutputCliOptions {
|
|
4
|
-
config?: string | boolean;
|
|
5
|
-
help?: boolean;
|
|
6
|
-
version?: boolean;
|
|
7
|
-
watch?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface OptionConfig {
|
|
10
|
-
abbreviation?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
default?: string | boolean;
|
|
13
|
-
hint?: string;
|
|
14
|
-
reverse?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare const alias: Partial<Record<keyof CliOptions, OptionConfig>>;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
export const alias = {
|
|
2
|
-
config: {
|
|
3
|
-
abbreviation: 'c',
|
|
4
|
-
hint: 'filename',
|
|
5
|
-
},
|
|
6
|
-
help: {
|
|
7
|
-
abbreviation: 'h',
|
|
8
|
-
},
|
|
9
|
-
version: {
|
|
10
|
-
abbreviation: 'v',
|
|
11
|
-
},
|
|
12
|
-
watch: {
|
|
13
|
-
abbreviation: 'w',
|
|
14
|
-
},
|
|
15
|
-
dir: {
|
|
16
|
-
abbreviation: 'd',
|
|
17
|
-
},
|
|
18
|
-
file: {
|
|
19
|
-
abbreviation: 'o',
|
|
20
|
-
},
|
|
21
|
-
external: {
|
|
22
|
-
abbreviation: 'e',
|
|
23
|
-
},
|
|
24
|
-
format: {
|
|
25
|
-
abbreviation: 'f',
|
|
26
|
-
},
|
|
27
|
-
name: {
|
|
28
|
-
abbreviation: 'n',
|
|
29
|
-
},
|
|
30
|
-
globals: {
|
|
31
|
-
abbreviation: 'g',
|
|
32
|
-
},
|
|
33
|
-
sourcemap: {
|
|
34
|
-
abbreviation: 's',
|
|
35
|
-
default: true,
|
|
36
|
-
},
|
|
37
|
-
minify: {
|
|
38
|
-
abbreviation: 'm',
|
|
39
|
-
},
|
|
40
|
-
platform: {
|
|
41
|
-
abbreviation: 'p',
|
|
42
|
-
},
|
|
43
|
-
assetFileNames: {
|
|
44
|
-
hint: 'name',
|
|
45
|
-
},
|
|
46
|
-
chunkFileNames: {
|
|
47
|
-
hint: 'name',
|
|
48
|
-
},
|
|
49
|
-
entryFileNames: {
|
|
50
|
-
hint: 'name',
|
|
51
|
-
},
|
|
52
|
-
externalLiveBindings: {
|
|
53
|
-
default: true,
|
|
54
|
-
reverse: true,
|
|
55
|
-
},
|
|
56
|
-
treeshake: {
|
|
57
|
-
default: true,
|
|
58
|
-
reverse: true,
|
|
59
|
-
},
|
|
60
|
-
moduleTypes: {
|
|
61
|
-
hint: 'types',
|
|
62
|
-
},
|
|
63
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type NormalizedCliOptions } from './normalize';
|
|
2
|
-
import type { Schema } from '../../types/schema';
|
|
3
|
-
export declare const flattenedSchema: Record<string, Schema>;
|
|
4
|
-
export declare const options: {
|
|
5
|
-
[k: string]: {
|
|
6
|
-
type: 'boolean' | 'string';
|
|
7
|
-
multiple: boolean;
|
|
8
|
-
short?: string;
|
|
9
|
-
default?: boolean | string | string[];
|
|
10
|
-
hint?: string;
|
|
11
|
-
description: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export type ParseArgsOptions = typeof options;
|
|
15
|
-
export declare function parseCliArguments(): NormalizedCliOptions;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { alias } from './alias';
|
|
2
|
-
import { camelCaseToKebabCase, flattenSchema, getSchemaType, kebabCaseToCamelCase, } from './utils';
|
|
3
|
-
import { parseArgs } from 'node:util';
|
|
4
|
-
import { normalizeCliOptions } from './normalize';
|
|
5
|
-
import { logger } from '../logger';
|
|
6
|
-
import { getJsonSchema } from '../../utils/validator';
|
|
7
|
-
const objectSchema = getJsonSchema();
|
|
8
|
-
export const flattenedSchema = flattenSchema(objectSchema.properties);
|
|
9
|
-
export const options = Object.fromEntries(Object.entries(flattenedSchema).map(([key, schema]) => {
|
|
10
|
-
const config = Object.getOwnPropertyDescriptor(alias, key)?.value;
|
|
11
|
-
const type = getSchemaType(schema);
|
|
12
|
-
const result = {
|
|
13
|
-
type: type === 'boolean' ? 'boolean' : 'string',
|
|
14
|
-
// We only support comma separated mode right now.
|
|
15
|
-
// multiple: type === 'object' || type === 'array',
|
|
16
|
-
description: schema?.description ?? config?.description ?? '',
|
|
17
|
-
hint: config?.hint,
|
|
18
|
-
};
|
|
19
|
-
if (config && config?.abbreviation) {
|
|
20
|
-
result.short = config?.abbreviation;
|
|
21
|
-
}
|
|
22
|
-
if (config && config.reverse) {
|
|
23
|
-
if (result.description.startsWith('enable')) {
|
|
24
|
-
result.description = result.description.replace('enable', 'disable');
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
result.description = `disable ${result.description}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
key = camelCaseToKebabCase(key);
|
|
31
|
-
// add 'no-' prefix for need reverse options
|
|
32
|
-
return [config?.reverse ? `no-${key}` : key, result];
|
|
33
|
-
}));
|
|
34
|
-
export function parseCliArguments() {
|
|
35
|
-
const { values, tokens, positionals } = parseArgs({
|
|
36
|
-
options,
|
|
37
|
-
tokens: true,
|
|
38
|
-
allowPositionals: true,
|
|
39
|
-
// We can't use `strict` mode because we should handle the default config file name.
|
|
40
|
-
strict: false,
|
|
41
|
-
});
|
|
42
|
-
tokens
|
|
43
|
-
.filter((token) => token.kind === 'option')
|
|
44
|
-
.forEach((option) => {
|
|
45
|
-
let negative = false;
|
|
46
|
-
if (option.name.startsWith('no-')) {
|
|
47
|
-
// stripe `no-` prefix
|
|
48
|
-
const name = kebabCaseToCamelCase(option.name.substring(3));
|
|
49
|
-
if (name in flattenedSchema) {
|
|
50
|
-
// Remove the `no-` in values
|
|
51
|
-
delete values[option.name];
|
|
52
|
-
option.name = name;
|
|
53
|
-
negative = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
delete values[option.name]; // Strip the kebab-case options.
|
|
57
|
-
option.name = kebabCaseToCamelCase(option.name);
|
|
58
|
-
let originalType = flattenedSchema[option.name];
|
|
59
|
-
if (!originalType) {
|
|
60
|
-
logger.error(`Invalid option: ${option.rawName}. We will ignore this option.`);
|
|
61
|
-
// We will refuse to handle the invalid option, as it may cause unexpected behavior.
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
let type = getSchemaType(originalType);
|
|
65
|
-
if (type === 'string' && typeof option.value !== 'string') {
|
|
66
|
-
let opt = option;
|
|
67
|
-
// We should use the default value.
|
|
68
|
-
let defaultValue = Object.getOwnPropertyDescriptor(alias, opt.name)
|
|
69
|
-
?.value;
|
|
70
|
-
Object.defineProperty(values, opt.name, {
|
|
71
|
-
value: defaultValue.default ?? '',
|
|
72
|
-
enumerable: true,
|
|
73
|
-
configurable: true,
|
|
74
|
-
writable: true,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
else if (type === 'object' && typeof option.value === 'string') {
|
|
78
|
-
const [key, value] = option.value.split(',').map((x) => x.split('='))[0];
|
|
79
|
-
if (!values[option.name]) {
|
|
80
|
-
Object.defineProperty(values, option.name, {
|
|
81
|
-
value: {},
|
|
82
|
-
enumerable: true,
|
|
83
|
-
configurable: true,
|
|
84
|
-
writable: true,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
if (key && value) {
|
|
88
|
-
// TODO support multiple entries.
|
|
89
|
-
Object.defineProperty(values[option.name], key, {
|
|
90
|
-
value,
|
|
91
|
-
enumerable: true,
|
|
92
|
-
configurable: true,
|
|
93
|
-
writable: true,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else if (type === 'array' && typeof option.value === 'string') {
|
|
98
|
-
if (!values[option.name]) {
|
|
99
|
-
Object.defineProperty(values, option.name, {
|
|
100
|
-
value: [],
|
|
101
|
-
enumerable: true,
|
|
102
|
-
configurable: true,
|
|
103
|
-
writable: true,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
;
|
|
107
|
-
values[option.name].push(option.value);
|
|
108
|
-
}
|
|
109
|
-
else if (type === 'boolean') {
|
|
110
|
-
Object.defineProperty(values, option.name, {
|
|
111
|
-
value: !negative,
|
|
112
|
-
enumerable: true,
|
|
113
|
-
configurable: true,
|
|
114
|
-
writable: true,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
Object.defineProperty(values, option.name, {
|
|
119
|
-
value: option.value ?? '',
|
|
120
|
-
enumerable: true,
|
|
121
|
-
configurable: true,
|
|
122
|
-
writable: true,
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return normalizeCliOptions(values, positionals);
|
|
127
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CliOptions } from './alias';
|
|
2
|
-
import type { InputOptions } from '../../options/input-options';
|
|
3
|
-
import type { OutputOptions } from '../../options/output-options';
|
|
4
|
-
export interface NormalizedCliOptions {
|
|
5
|
-
input: InputOptions;
|
|
6
|
-
output: OutputOptions;
|
|
7
|
-
help: boolean;
|
|
8
|
-
config: string;
|
|
9
|
-
version: boolean;
|
|
10
|
-
watch: boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare function normalizeCliOptions(cliOptions: CliOptions, positionals: string[]): NormalizedCliOptions;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description This file is used for normalize the options.
|
|
3
|
-
* In CLI, the input options and output options are mixed together. We need to tell them apart.
|
|
4
|
-
*/
|
|
5
|
-
import { logger } from '../logger';
|
|
6
|
-
import { setNestedProperty } from './utils';
|
|
7
|
-
import { getInputCliKeys, getOutputCliKeys, validateCliOptions, } from '../../utils/validator';
|
|
8
|
-
export function normalizeCliOptions(cliOptions, positionals) {
|
|
9
|
-
const [data, errors] = validateCliOptions(cliOptions);
|
|
10
|
-
if (errors?.length) {
|
|
11
|
-
errors.forEach((error) => {
|
|
12
|
-
logger.error(`Invalid value for option ${error}. You can use \`rolldown -h\` to see the help.`);
|
|
13
|
-
});
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
const options = data ?? {};
|
|
17
|
-
const result = {
|
|
18
|
-
input: {},
|
|
19
|
-
output: {},
|
|
20
|
-
help: options.help ?? false,
|
|
21
|
-
version: options.version ?? false,
|
|
22
|
-
watch: options.watch ?? false,
|
|
23
|
-
};
|
|
24
|
-
if (typeof options.config === 'string') {
|
|
25
|
-
result.config = options.config;
|
|
26
|
-
}
|
|
27
|
-
const keysOfInput = getInputCliKeys();
|
|
28
|
-
const keysOfOutput = getOutputCliKeys();
|
|
29
|
-
const reservedKeys = ['help', 'version', 'config', 'watch'];
|
|
30
|
-
for (let [key, value] of Object.entries(options)) {
|
|
31
|
-
const keys = key.split('.');
|
|
32
|
-
const [primary] = keys;
|
|
33
|
-
if (keysOfInput.includes(primary)) {
|
|
34
|
-
setNestedProperty(result.input, key, value);
|
|
35
|
-
}
|
|
36
|
-
else if (keysOfOutput.includes(primary)) {
|
|
37
|
-
setNestedProperty(result.output, key, value);
|
|
38
|
-
}
|
|
39
|
-
else if (!reservedKeys.includes(key)) {
|
|
40
|
-
logger.error(`Unknown option: ${key}`);
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!result.config && positionals.length > 0) {
|
|
45
|
-
result.input.input = positionals;
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Schema } from '../../types/schema';
|
|
2
|
-
type SchemaType = 'string' | 'boolean' | 'object' | 'number' | 'array';
|
|
3
|
-
export declare function getSchemaType(schema: Schema): SchemaType;
|
|
4
|
-
export declare function flattenSchema(schema: Record<string, Schema>, base?: Record<string, Schema>, parent?: string): Record<string, Schema>;
|
|
5
|
-
export declare function setNestedProperty<T extends object, K>(obj: T, path: string, value: K): void;
|
|
6
|
-
export declare function camelCaseToKebabCase(str: string): string;
|
|
7
|
-
export declare function kebabCaseToCamelCase(str: string): string;
|
|
8
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const priority = [
|
|
2
|
-
'object',
|
|
3
|
-
'array',
|
|
4
|
-
'string',
|
|
5
|
-
'number',
|
|
6
|
-
'boolean',
|
|
7
|
-
];
|
|
8
|
-
export function getSchemaType(schema) {
|
|
9
|
-
if ('anyOf' in schema) {
|
|
10
|
-
const types = schema.anyOf.map(getSchemaType);
|
|
11
|
-
// Order: object > array > string > number > boolean
|
|
12
|
-
let result = priority.find((type) => types.includes(type));
|
|
13
|
-
if (result) {
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if ('type' in schema) {
|
|
18
|
-
return schema.type;
|
|
19
|
-
}
|
|
20
|
-
if ('const' in schema) {
|
|
21
|
-
return typeof schema.const;
|
|
22
|
-
}
|
|
23
|
-
return 'object';
|
|
24
|
-
}
|
|
25
|
-
export function flattenSchema(schema, base = {}, parent = '') {
|
|
26
|
-
if (schema === undefined) {
|
|
27
|
-
return base;
|
|
28
|
-
}
|
|
29
|
-
for (const [k, value] of Object.entries(schema)) {
|
|
30
|
-
const key = parent ? `${parent}.${k}` : k;
|
|
31
|
-
if (getSchemaType(value) === 'object') {
|
|
32
|
-
if ('properties' in value) {
|
|
33
|
-
flattenSchema(value.properties, base, key);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
base[key] = value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
base[key] = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return base;
|
|
44
|
-
}
|
|
45
|
-
export function setNestedProperty(obj, path, value) {
|
|
46
|
-
const keys = path.split('.');
|
|
47
|
-
let current = obj;
|
|
48
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
49
|
-
if (!current[keys[i]]) {
|
|
50
|
-
current[keys[i]] = {};
|
|
51
|
-
}
|
|
52
|
-
current = current[keys[i]];
|
|
53
|
-
}
|
|
54
|
-
const finalKey = keys[keys.length - 1];
|
|
55
|
-
Object.defineProperty(current, finalKey, {
|
|
56
|
-
value: value,
|
|
57
|
-
writable: true,
|
|
58
|
-
enumerable: true,
|
|
59
|
-
configurable: true,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
export function camelCaseToKebabCase(str) {
|
|
63
|
-
return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
64
|
-
}
|
|
65
|
-
export function kebabCaseToCamelCase(str) {
|
|
66
|
-
return str.replace(/-./g, (match) => match[1].toUpperCase());
|
|
67
|
-
}
|
package/dist/types/cli/colors.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { env } from 'node:process';
|
|
2
|
-
import { createColors } from 'colorette';
|
|
3
|
-
// @see https://no-color.org
|
|
4
|
-
// @see https://www.npmjs.com/package/chalk
|
|
5
|
-
const { bold, cyan, dim, gray, green, red, underline, yellow, } = createColors({
|
|
6
|
-
useColor: env.FORCE_COLOR !== '0' && !env.NO_COLOR,
|
|
7
|
-
});
|
|
8
|
-
export const colors = {
|
|
9
|
-
bold,
|
|
10
|
-
cyan,
|
|
11
|
-
dim,
|
|
12
|
-
gray,
|
|
13
|
-
green,
|
|
14
|
-
red,
|
|
15
|
-
underline,
|
|
16
|
-
yellow,
|
|
17
|
-
};
|