rolldown 1.0.0-beta.4-commit.d3748b6 → 1.0.0-beta.40
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/cli.d.mts +1 -0
- package/dist/cli.mjs +579 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.d.mts +147 -0
- package/dist/experimental-index.mjs +216 -0
- package/dist/experimental-runtime-types.d.ts +71 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +8 -16
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.d.mts +8 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding-BVXbXhPv.d.mts +1413 -0
- package/dist/shared/define-config-0kfJrpvQ.d.mts +1454 -0
- package/dist/shared/load-config-BJ274Wsp.mjs +117 -0
- package/dist/{esm/cli.mjs → shared/logger-CiCY7ucm.mjs} +107 -868
- package/dist/shared/misc-CQeo-AFx.mjs +22 -0
- package/dist/shared/parse-ast-index-C7EYXjEA.mjs +10974 -0
- package/dist/shared/{prompt-CxK9euq3.mjs → prompt-D2FxOcB5.mjs} +243 -245
- package/dist/shared/src-BH2eQDD9.mjs +4282 -0
- package/package.json +62 -76
- package/bin/cli.js +0 -2
- package/dist/cjs/cli.cjs +0 -1753
- package/dist/cjs/experimental-index.cjs +0 -85
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parallel-plugin-worker.cjs +0 -41
- package/dist/cjs/parallel-plugin.cjs +0 -9
- package/dist/cjs/parse-ast-index.cjs +0 -4
- package/dist/esm/experimental-index.mjs +0 -57
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -3
- package/dist/shared/chunk-qZFfknuJ.cjs +0 -40
- package/dist/shared/parse-ast-index-CyX8MVZE.mjs +0 -674
- package/dist/shared/parse-ast-index-D7XtMFo4.cjs +0 -719
- package/dist/shared/prompt-ZZScCEWI.cjs +0 -854
- package/dist/shared/src-CH716UxL.cjs +0 -3056
- package/dist/shared/src-CzSgWS0h.mjs +0 -2875
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -13
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/binding.d.ts +0 -1456
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/constructors.d.ts +0 -21
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/load-config.d.ts +0 -5
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/index.d.ts +0 -30
- package/dist/types/log/log-handler.d.ts +0 -4
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logging.d.ts +0 -12
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/options/generated/checks-options.d.ts +0 -57
- package/dist/types/options/input-options.d.ts +0 -177
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-output-options.d.ts +0 -70
- package/dist/types/options/output-options.d.ts +0 -182
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -5
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -16
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/index.d.ts +0 -134
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -23
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/plugin-context-data.d.ts +0 -17
- package/dist/types/plugin/plugin-context.d.ts +0 -67
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -28
- package/dist/types/types/assert.d.ts +0 -14
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-side-effects.d.ts +0 -12
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-output.d.ts +0 -66
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/sourcemap.d.ts +0 -14
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-output-options.d.ts +0 -5
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/resolved-external.d.ts +0 -4
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/validator.d.ts +0 -6
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingDynamicImportVarsPluginConfig, BindingEsmExternalRequirePluginConfig, BindingHmrUpdate, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingReactRefreshWrapperPluginConfig, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWasmHelperPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/binding-BVXbXhPv.mjs";
|
|
2
|
+
import { BuiltinPlugin, InputOptions, OutputOptions, StringOrRegExp, defineParallelPlugin } from "./shared/define-config-0kfJrpvQ.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/api/dev/dev-options.d.ts
|
|
5
|
+
interface DevWatchOptions {
|
|
6
|
+
/**
|
|
7
|
+
* If `true`, files are not written to disk.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
skipWrite?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* If `true`, use polling instead of native file system events for watching.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
usePolling?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Poll interval in milliseconds (only used when usePolling is true).
|
|
18
|
+
* @default 100
|
|
19
|
+
*/
|
|
20
|
+
pollInterval?: number;
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
useDebounce?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Debounce duration in milliseconds (only used when useDebounce is true).
|
|
28
|
+
* @default 10
|
|
29
|
+
*/
|
|
30
|
+
debounceDuration?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to compare file contents for poll-based watchers (only used when usePolling is true).
|
|
33
|
+
* When enabled, poll watchers will check file contents to determine if they actually changed.
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
compareContentsForPolling?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
|
|
39
|
+
* Controls how frequently the debouncer checks for events to process.
|
|
40
|
+
* When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
|
|
41
|
+
* @default undefined (auto-select)
|
|
42
|
+
*/
|
|
43
|
+
debounceTickRate?: number;
|
|
44
|
+
}
|
|
45
|
+
interface DevOptions {
|
|
46
|
+
onHmrUpdates?: (updates: BindingHmrUpdate[], changedFiles: string[]) => void | Promise<void>;
|
|
47
|
+
watch?: DevWatchOptions;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/api/dev/dev-engine.d.ts
|
|
51
|
+
declare class DevEngine {
|
|
52
|
+
#private;
|
|
53
|
+
static create(inputOptions: InputOptions, outputOptions?: OutputOptions, devOptions?: DevOptions): Promise<DevEngine>;
|
|
54
|
+
private constructor();
|
|
55
|
+
run(): Promise<void>;
|
|
56
|
+
ensureCurrentBuildFinish(): Promise<void>;
|
|
57
|
+
ensureLatestBuildOutput(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if a new build is scheduled.
|
|
60
|
+
*/
|
|
61
|
+
scheduleBuildIfStale(): Promise<"scheduled" | "alreadyScheduled" | undefined>;
|
|
62
|
+
invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrUpdate>;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/api/dev/index.d.ts
|
|
66
|
+
declare var dev: typeof DevEngine.create;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/api/experimental.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* This is an experimental API. It's behavior may change in the future.
|
|
71
|
+
*
|
|
72
|
+
* Calling this API will only execute the scan stage of rolldown.
|
|
73
|
+
*/
|
|
74
|
+
declare const scan: (input: InputOptions) => Promise<void>;
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/builtin-plugin/constructors.d.ts
|
|
77
|
+
declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
|
|
78
|
+
type DynamicImportVarsPluginConfig = Omit<BindingDynamicImportVarsPluginConfig, "include" | "exclude"> & {
|
|
79
|
+
include?: StringOrRegExp | StringOrRegExp[];
|
|
80
|
+
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
81
|
+
};
|
|
82
|
+
declare function dynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
|
|
83
|
+
declare function importGlobPlugin(config?: BindingImportGlobPluginConfig): BuiltinPlugin;
|
|
84
|
+
declare function reporterPlugin(config?: BindingReporterPluginConfig): BuiltinPlugin;
|
|
85
|
+
declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
|
|
86
|
+
declare function wasmHelperPlugin(config?: BindingWasmHelperPluginConfig): BuiltinPlugin;
|
|
87
|
+
declare function wasmFallbackPlugin(): BuiltinPlugin;
|
|
88
|
+
declare function loadFallbackPlugin(): BuiltinPlugin;
|
|
89
|
+
declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
|
|
90
|
+
declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
|
|
91
|
+
declare function viteResolvePlugin(config: BindingViteResolvePluginConfig): BuiltinPlugin;
|
|
92
|
+
declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
|
|
93
|
+
declare function assetPlugin(config?: BindingAssetPluginConfig): BuiltinPlugin;
|
|
94
|
+
declare function webWorkerPostPlugin(): BuiltinPlugin;
|
|
95
|
+
declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
|
|
96
|
+
type ReactRefreshWrapperPluginConfig = Omit<BindingReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
|
|
97
|
+
include?: StringOrRegExp | StringOrRegExp[];
|
|
98
|
+
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
99
|
+
};
|
|
100
|
+
declare function reactRefreshWrapperPlugin(config: ReactRefreshWrapperPluginConfig): BuiltinPlugin;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/builtin-plugin/alias-plugin.d.ts
|
|
103
|
+
type AliasPluginAlias = {
|
|
104
|
+
find: string | RegExp;
|
|
105
|
+
replacement: string;
|
|
106
|
+
};
|
|
107
|
+
type AliasPluginConfig = {
|
|
108
|
+
entries: AliasPluginAlias[];
|
|
109
|
+
};
|
|
110
|
+
declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/builtin-plugin/replace-plugin.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* Replaces targeted strings in files while bundling.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* // Basic usage
|
|
118
|
+
* ```js
|
|
119
|
+
* replacePlugin({
|
|
120
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
121
|
+
* __buildVersion: 15
|
|
122
|
+
* })
|
|
123
|
+
* ```
|
|
124
|
+
* @example
|
|
125
|
+
* // With options
|
|
126
|
+
* ```js
|
|
127
|
+
* replacePlugin({
|
|
128
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
129
|
+
* __buildVersion: 15
|
|
130
|
+
* }, {
|
|
131
|
+
* preventAssignment: false,
|
|
132
|
+
* })
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/builtin-plugin/transform-plugin.d.ts
|
|
138
|
+
type TransformPattern = string | RegExp | readonly (RegExp | string)[];
|
|
139
|
+
type TransformPluginConfig = Omit<BindingTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude"> & {
|
|
140
|
+
include?: TransformPattern;
|
|
141
|
+
exclude?: TransformPattern;
|
|
142
|
+
jsxRefreshInclude?: TransformPattern;
|
|
143
|
+
jsxRefreshExclude?: TransformPattern;
|
|
144
|
+
};
|
|
145
|
+
declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
|
|
146
|
+
//#endregion
|
|
147
|
+
export { DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, reactRefreshWrapperPlugin, replacePlugin, reporterPlugin, scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { BindingDevEngine, ResolverFactory, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/parse-ast-index-C7EYXjEA.mjs";
|
|
2
|
+
import { BuiltinPlugin, PluginDriver, RolldownBuild, createBundlerOptions, makeBuiltinPluginCallable, normalizedStringOrRegex } from "./shared/src-BH2eQDD9.mjs";
|
|
3
|
+
import "./shared/misc-CQeo-AFx.mjs";
|
|
4
|
+
import { logger } from "./shared/logger-CiCY7ucm.mjs";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
//#region src/api/dev/dev-engine.ts
|
|
8
|
+
var DevEngine = class DevEngine {
|
|
9
|
+
#inner;
|
|
10
|
+
#cachedBuildFinishPromise = null;
|
|
11
|
+
static async create(inputOptions, outputOptions = {}, devOptions = {}) {
|
|
12
|
+
inputOptions = await PluginDriver.callOptionsHook(inputOptions);
|
|
13
|
+
const options = await createBundlerOptions(inputOptions, outputOptions, false);
|
|
14
|
+
const bindingDevOptions = {
|
|
15
|
+
onHmrUpdates: devOptions.onHmrUpdates,
|
|
16
|
+
watch: devOptions.watch && {
|
|
17
|
+
skipWrite: devOptions.watch.skipWrite,
|
|
18
|
+
usePolling: devOptions.watch.usePolling,
|
|
19
|
+
pollInterval: devOptions.watch.pollInterval,
|
|
20
|
+
useDebounce: devOptions.watch.useDebounce,
|
|
21
|
+
debounceDuration: devOptions.watch.debounceDuration,
|
|
22
|
+
compareContentsForPolling: devOptions.watch.compareContentsForPolling,
|
|
23
|
+
debounceTickRate: devOptions.watch.debounceTickRate
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const inner = new BindingDevEngine(options.bundlerOptions, bindingDevOptions);
|
|
27
|
+
return new DevEngine(inner);
|
|
28
|
+
}
|
|
29
|
+
constructor(inner) {
|
|
30
|
+
this.#inner = inner;
|
|
31
|
+
}
|
|
32
|
+
async run() {
|
|
33
|
+
await this.#inner.run();
|
|
34
|
+
}
|
|
35
|
+
async ensureCurrentBuildFinish() {
|
|
36
|
+
if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;
|
|
37
|
+
const promise = this.#inner.ensureCurrentBuildFinish().then(() => {
|
|
38
|
+
this.#cachedBuildFinishPromise = null;
|
|
39
|
+
});
|
|
40
|
+
this.#cachedBuildFinishPromise = promise;
|
|
41
|
+
return promise;
|
|
42
|
+
}
|
|
43
|
+
async ensureLatestBuildOutput() {
|
|
44
|
+
await this.#inner.ensureLatestBuildOutput();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns true if a new build is scheduled.
|
|
48
|
+
*/
|
|
49
|
+
async scheduleBuildIfStale() {
|
|
50
|
+
const scheduled = await this.#inner.scheduleBuildIfStale();
|
|
51
|
+
if (scheduled) {
|
|
52
|
+
scheduled.wait().catch(() => {});
|
|
53
|
+
return scheduled.alreadyScheduled() ? "alreadyScheduled" : "scheduled";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async invalidate(file, firstInvalidatedBy) {
|
|
57
|
+
return this.#inner.invalidate(file, firstInvalidatedBy);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/api/dev/index.ts
|
|
63
|
+
var dev = DevEngine.create;
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/api/experimental.ts
|
|
67
|
+
/**
|
|
68
|
+
* This is an experimental API. It's behavior may change in the future.
|
|
69
|
+
*
|
|
70
|
+
* Calling this API will only execute the scan stage of rolldown.
|
|
71
|
+
*/
|
|
72
|
+
const scan = async (input) => {
|
|
73
|
+
const inputOptions = await PluginDriver.callOptionsHook(input);
|
|
74
|
+
const build = new RolldownBuild(inputOptions);
|
|
75
|
+
try {
|
|
76
|
+
await build.scan();
|
|
77
|
+
} finally {
|
|
78
|
+
await build.close();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/plugin/parallel-plugin.ts
|
|
84
|
+
function defineParallelPlugin(pluginPath) {
|
|
85
|
+
return (options) => {
|
|
86
|
+
return { _parallel: {
|
|
87
|
+
fileUrl: pathToFileURL(pluginPath).href,
|
|
88
|
+
options
|
|
89
|
+
} };
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/builtin-plugin/constructors.ts
|
|
95
|
+
function modulePreloadPolyfillPlugin(config) {
|
|
96
|
+
return new BuiltinPlugin("builtin:module-preload-polyfill", config);
|
|
97
|
+
}
|
|
98
|
+
function dynamicImportVarsPlugin(config) {
|
|
99
|
+
if (config) {
|
|
100
|
+
config.include = normalizedStringOrRegex(config.include);
|
|
101
|
+
config.exclude = normalizedStringOrRegex(config.exclude);
|
|
102
|
+
}
|
|
103
|
+
return new BuiltinPlugin("builtin:dynamic-import-vars", config);
|
|
104
|
+
}
|
|
105
|
+
function importGlobPlugin(config) {
|
|
106
|
+
return new BuiltinPlugin("builtin:import-glob", config);
|
|
107
|
+
}
|
|
108
|
+
function reporterPlugin(config) {
|
|
109
|
+
return new BuiltinPlugin("builtin:reporter", config);
|
|
110
|
+
}
|
|
111
|
+
function manifestPlugin(config) {
|
|
112
|
+
return new BuiltinPlugin("builtin:manifest", config);
|
|
113
|
+
}
|
|
114
|
+
function wasmHelperPlugin(config) {
|
|
115
|
+
return new BuiltinPlugin("builtin:wasm-helper", config);
|
|
116
|
+
}
|
|
117
|
+
function wasmFallbackPlugin() {
|
|
118
|
+
const builtinPlugin = new BuiltinPlugin("builtin:wasm-fallback");
|
|
119
|
+
return makeBuiltinPluginCallable(builtinPlugin);
|
|
120
|
+
}
|
|
121
|
+
function loadFallbackPlugin() {
|
|
122
|
+
return new BuiltinPlugin("builtin:load-fallback");
|
|
123
|
+
}
|
|
124
|
+
function jsonPlugin(config) {
|
|
125
|
+
const builtinPlugin = new BuiltinPlugin("builtin:json", config);
|
|
126
|
+
return makeBuiltinPluginCallable(builtinPlugin);
|
|
127
|
+
}
|
|
128
|
+
function buildImportAnalysisPlugin(config) {
|
|
129
|
+
return new BuiltinPlugin("builtin:build-import-analysis", config);
|
|
130
|
+
}
|
|
131
|
+
function viteResolvePlugin(config) {
|
|
132
|
+
const builtinPlugin = new BuiltinPlugin("builtin:vite-resolve", config);
|
|
133
|
+
return makeBuiltinPluginCallable(builtinPlugin);
|
|
134
|
+
}
|
|
135
|
+
function isolatedDeclarationPlugin(config) {
|
|
136
|
+
return new BuiltinPlugin("builtin:isolated-declaration", config);
|
|
137
|
+
}
|
|
138
|
+
function assetPlugin(config) {
|
|
139
|
+
return new BuiltinPlugin("builtin:asset", config);
|
|
140
|
+
}
|
|
141
|
+
function webWorkerPostPlugin() {
|
|
142
|
+
return new BuiltinPlugin("builtin:web-worker-post");
|
|
143
|
+
}
|
|
144
|
+
function esmExternalRequirePlugin(config) {
|
|
145
|
+
return new BuiltinPlugin("builtin:esm-external-require", config);
|
|
146
|
+
}
|
|
147
|
+
function reactRefreshWrapperPlugin(config) {
|
|
148
|
+
if (config) {
|
|
149
|
+
config.include = normalizedStringOrRegex(config.include);
|
|
150
|
+
config.exclude = normalizedStringOrRegex(config.exclude);
|
|
151
|
+
}
|
|
152
|
+
const builtinPlugin = new BuiltinPlugin("builtin:react-refresh-wrapper", config);
|
|
153
|
+
return makeBuiltinPluginCallable(builtinPlugin);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/builtin-plugin/alias-plugin.ts
|
|
158
|
+
function aliasPlugin(config) {
|
|
159
|
+
return new BuiltinPlugin("builtin:alias", config);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/builtin-plugin/replace-plugin.ts
|
|
164
|
+
/**
|
|
165
|
+
* Replaces targeted strings in files while bundling.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // Basic usage
|
|
169
|
+
* ```js
|
|
170
|
+
* replacePlugin({
|
|
171
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
172
|
+
* __buildVersion: 15
|
|
173
|
+
* })
|
|
174
|
+
* ```
|
|
175
|
+
* @example
|
|
176
|
+
* // With options
|
|
177
|
+
* ```js
|
|
178
|
+
* replacePlugin({
|
|
179
|
+
* 'process.env.NODE_ENV': JSON.stringify('production'),
|
|
180
|
+
* __buildVersion: 15
|
|
181
|
+
* }, {
|
|
182
|
+
* preventAssignment: false,
|
|
183
|
+
* })
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
function replacePlugin(values = {}, options = {}) {
|
|
187
|
+
let hasNonStringValues = false;
|
|
188
|
+
Object.keys(values).forEach((key) => {
|
|
189
|
+
const value = values[key];
|
|
190
|
+
if (typeof value !== "string") {
|
|
191
|
+
hasNonStringValues = true;
|
|
192
|
+
values[key] = String(value);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (hasNonStringValues) logger.warn("Some values provided to `replacePlugin` are not strings. They will be converted to strings, but for better performance consider converting them manually.");
|
|
196
|
+
return new BuiltinPlugin("builtin:replace", {
|
|
197
|
+
...options,
|
|
198
|
+
values
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/builtin-plugin/transform-plugin.ts
|
|
204
|
+
function transformPlugin(config) {
|
|
205
|
+
if (config) config = {
|
|
206
|
+
...config,
|
|
207
|
+
include: normalizedStringOrRegex(config.include),
|
|
208
|
+
exclude: normalizedStringOrRegex(config.exclude),
|
|
209
|
+
jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
|
|
210
|
+
jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
|
|
211
|
+
};
|
|
212
|
+
return new BuiltinPlugin("builtin:transform", config);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
//#endregion
|
|
216
|
+
export { DevEngine, ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, reactRefreshWrapperPlugin, replacePlugin, reporterPlugin, scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export class DevRuntime {
|
|
2
|
+
/**
|
|
3
|
+
* @type {Record<string, Module>}
|
|
4
|
+
*/
|
|
5
|
+
modules: Record<string, Module>;
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} _moduleId
|
|
8
|
+
*/
|
|
9
|
+
createModuleHotContext(_moduleId: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* @param {string[]} _boundaries
|
|
12
|
+
*/
|
|
13
|
+
applyUpdates(_boundaries: string[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} id
|
|
16
|
+
* @param {{ exports: any }} exportsHolder
|
|
17
|
+
*/
|
|
18
|
+
registerModule(id: string, exportsHolder: {
|
|
19
|
+
exports: any;
|
|
20
|
+
}): void;
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} id
|
|
23
|
+
*/
|
|
24
|
+
loadExports(id: string): any;
|
|
25
|
+
/**
|
|
26
|
+
* __esmMin
|
|
27
|
+
*
|
|
28
|
+
* @type {<T>(fn: any, res: T) => () => T}
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
createEsmInitializer: <T>(fn: any, res: T) => () => T;
|
|
32
|
+
/**
|
|
33
|
+
* __commonJSMin
|
|
34
|
+
*
|
|
35
|
+
* @type {<T extends { exports: any }>(cb: any, mod: { exports: any }) => () => T}
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
createCjsInitializer: <T extends {
|
|
39
|
+
exports: any;
|
|
40
|
+
}>(cb: any, mod: {
|
|
41
|
+
exports: any;
|
|
42
|
+
}) => () => T;
|
|
43
|
+
/** @internal */
|
|
44
|
+
__toESM: any;
|
|
45
|
+
/** @internal */
|
|
46
|
+
__toCommonJS: any;
|
|
47
|
+
/** @internal */
|
|
48
|
+
__export: any;
|
|
49
|
+
/** @internal */
|
|
50
|
+
__toDynamicImportESM: any;
|
|
51
|
+
/** @internal */
|
|
52
|
+
__reExport: any;
|
|
53
|
+
}
|
|
54
|
+
declare class Module {
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} id
|
|
57
|
+
*/
|
|
58
|
+
constructor(id: string);
|
|
59
|
+
/**
|
|
60
|
+
* @type {{ exports: any }}
|
|
61
|
+
*/
|
|
62
|
+
exportsHolder: {
|
|
63
|
+
exports: any;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* @type {string}
|
|
67
|
+
*/
|
|
68
|
+
id: string;
|
|
69
|
+
get exports(): any;
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import "./shared/binding-BVXbXhPv.mjs";
|
|
2
|
+
import { withFilter } from "./shared/define-config-0kfJrpvQ.mjs";
|
|
3
|
+
import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
|
|
4
|
+
export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { arraify, isPromiseLike } from "./shared/misc-CQeo-AFx.mjs";
|
|
2
|
+
import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
|
|
3
|
+
|
|
4
|
+
//#region src/plugin/with-filter.ts
|
|
5
|
+
function withFilterImpl(pluginOption, filterObjectList) {
|
|
6
|
+
if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
|
|
7
|
+
if (pluginOption == false || pluginOption == null) return pluginOption;
|
|
8
|
+
if (Array.isArray(pluginOption)) return pluginOption.map((p) => withFilter(p, filterObjectList));
|
|
9
|
+
let plugin = pluginOption;
|
|
10
|
+
let filterObjectIndex = findMatchedFilterObject(plugin.name, filterObjectList);
|
|
11
|
+
if (filterObjectIndex === -1) return plugin;
|
|
12
|
+
let filterObject = filterObjectList[filterObjectIndex];
|
|
13
|
+
Object.keys(plugin).forEach((key) => {
|
|
14
|
+
switch (key) {
|
|
15
|
+
case "transform":
|
|
16
|
+
case "resolveId":
|
|
17
|
+
case "load":
|
|
18
|
+
if (!plugin[key]) return;
|
|
19
|
+
if (typeof plugin[key] === "object") plugin[key].filter = filterObject[key] ?? plugin[key].filter;
|
|
20
|
+
else plugin[key] = {
|
|
21
|
+
handler: plugin[key],
|
|
22
|
+
filter: filterObject[key]
|
|
23
|
+
};
|
|
24
|
+
break;
|
|
25
|
+
default: break;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return plugin;
|
|
29
|
+
}
|
|
30
|
+
function withFilter(pluginOption, filterObject) {
|
|
31
|
+
return withFilterImpl(pluginOption, arraify(filterObject));
|
|
32
|
+
}
|
|
33
|
+
function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
|
|
34
|
+
if (overrideFilterObjectList.length === 1 && overrideFilterObjectList[0].pluginNamePattern === void 0) return 0;
|
|
35
|
+
for (let i = 0; i < overrideFilterObjectList.length; i++) for (let j = 0; j < (overrideFilterObjectList[i].pluginNamePattern ?? []).length; j++) {
|
|
36
|
+
let pattern = overrideFilterObjectList[i].pluginNamePattern[j];
|
|
37
|
+
if (typeof pattern === "string" && pattern === pluginName) return i;
|
|
38
|
+
else if (pattern instanceof RegExp && pattern.test(pluginName)) return i;
|
|
39
|
+
}
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PreRenderedChunk } from "./shared/binding-BVXbXhPv.mjs";
|
|
2
|
+
import { AddonFunction, AsyncPluginHooks, BufferEncoding, BuildOptions, ChunkFileNamesFunction, ChunkingContext, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OptimizationOptions, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownFileStats, RolldownFsModule, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch } from "./shared/define-config-0kfJrpvQ.mjs";
|
|
3
|
+
export { AddonFunction, AsyncPluginHooks, BufferEncoding, BuildOptions, ChunkFileNamesFunction, ChunkingContext, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OptimizationOptions, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownFileStats, RolldownFsModule, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PluginContextData, bindingifyPlugin } from "
|
|
1
|
+
import { registerPlugins } from "./shared/parse-ast-index-C7EYXjEA.mjs";
|
|
2
|
+
import { PluginContextData, bindingifyPlugin } from "./shared/src-BH2eQDD9.mjs";
|
|
3
|
+
import "./shared/misc-CQeo-AFx.mjs";
|
|
3
4
|
import { parentPort, workerData } from "node:worker_threads";
|
|
4
5
|
|
|
5
6
|
//#region src/parallel-plugin-worker.ts
|
|
@@ -7,24 +8,14 @@ const { registryId, pluginInfos, threadNumber } = workerData;
|
|
|
7
8
|
(async () => {
|
|
8
9
|
try {
|
|
9
10
|
const plugins = await Promise.all(pluginInfos.map(async (pluginInfo) => {
|
|
10
|
-
const
|
|
11
|
-
const definePluginImpl = pluginModule.default;
|
|
11
|
+
const definePluginImpl = (await import(pluginInfo.fileUrl)).default;
|
|
12
12
|
const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
|
|
13
13
|
return {
|
|
14
14
|
index: pluginInfo.index,
|
|
15
|
-
plugin: bindingifyPlugin(
|
|
16
|
-
plugin,
|
|
17
|
-
{},
|
|
18
|
-
{},
|
|
19
|
-
// TODO need to find a way to share pluginContextData
|
|
20
|
-
new PluginContextData(),
|
|
21
|
-
[],
|
|
22
|
-
() => {},
|
|
23
|
-
"info"
|
|
24
|
-
)
|
|
15
|
+
plugin: bindingifyPlugin(plugin, {}, {}, new PluginContextData(() => {}, {}, []), [], () => {}, "info", false)
|
|
25
16
|
};
|
|
26
17
|
}));
|
|
27
|
-
|
|
18
|
+
registerPlugins(registryId, plugins);
|
|
28
19
|
parentPort.postMessage({ type: "success" });
|
|
29
20
|
} catch (error) {
|
|
30
21
|
parentPort.postMessage({
|
|
@@ -36,4 +27,5 @@ const { registryId, pluginInfos, threadNumber } = workerData;
|
|
|
36
27
|
}
|
|
37
28
|
})();
|
|
38
29
|
|
|
39
|
-
//#endregion
|
|
30
|
+
//#endregion
|
|
31
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./shared/binding-BVXbXhPv.mjs";
|
|
2
|
+
import { MaybePromise, Plugin } from "./shared/define-config-0kfJrpvQ.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/plugin/parallel-plugin-implementation.d.ts
|
|
5
|
+
type ParallelPluginImplementation = Plugin;
|
|
6
|
+
type Context = {
|
|
7
|
+
/**
|
|
8
|
+
* Thread number
|
|
9
|
+
*/
|
|
10
|
+
threadNumber: number;
|
|
11
|
+
};
|
|
12
|
+
declare function defineParallelPluginImplementation<Options>(plugin: (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>): (Options: Options, context: Context) => MaybePromise<ParallelPluginImplementation>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { type Context, type ParallelPluginImplementation, defineParallelPluginImplementation };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParseResult, ParserOptions } from "./shared/binding-BVXbXhPv.mjs";
|
|
2
|
+
import { Program } from "@oxc-project/types";
|
|
3
|
+
|
|
4
|
+
//#region src/parse-ast-index.d.ts
|
|
5
|
+
declare function parseAst(sourceText: string, options?: ParserOptions | undefined | null, filename?: string): Program;
|
|
6
|
+
declare function parseAstAsync(sourceText: string, options?: ParserOptions | undefined | null, filename?: string): Promise<Program>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { type ParseResult, type ParserOptions, parseAst, parseAstAsync };
|