@rollipop/rolldown 1.0.24 → 1.0.26
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/THIRD-PARTY-LICENSE +33 -0
- package/dist/cli.mjs +9 -10
- package/dist/config.d.mts +16 -17
- package/dist/config.mjs +2 -2
- package/dist/experimental-default-runtime.mjs +116 -0
- package/dist/experimental-index.d.mts +220 -205
- package/dist/experimental-index.mjs +47 -22
- package/dist/experimental-runtime-base.mjs +95 -0
- package/dist/experimental-runtime-types.d.ts +111 -41
- package/dist/experimental-runtime.d.ts +177 -0
- package/dist/experimental-runtime.mjs +257 -0
- package/dist/filter-index.d.mts +6 -5
- package/dist/filter-index.mjs +1 -3
- package/dist/get-log-filter.d.mts +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/parallel-plugin-worker.mjs +2 -2
- package/dist/parallel-plugin.d.mts +3 -4
- package/dist/parse-ast-index.d.mts +19 -20
- package/dist/parse-ast-index.mjs +2 -2
- package/dist/plugins-index.d.mts +27 -28
- package/dist/plugins-index.mjs +2 -2
- package/dist/shared/{binding-DLP3kSP5.mjs → binding-D_XVvOPT.mjs} +124 -50
- package/dist/shared/{binding-FraDreAW.d.mts → binding-We_IfeZk.d.mts} +48 -25
- package/dist/shared/{bindingify-input-options-DQnooxIa.mjs → bindingify-input-options-BXQG8xz-.mjs} +213 -262
- package/dist/shared/{constructors-CXtPAgZN.d.mts → constructors-BIHQ8UmW.d.mts} +9 -10
- package/dist/shared/{constructors-DpCCe7z3.mjs → constructors-CNB5XL7Q.mjs} +10 -6
- package/dist/shared/{rolldown-build-Blclcr5k.mjs → create-bundler-option-Be4KJzGL.mjs} +39 -156
- package/dist/shared/define-config-thpMQ05a.d.mts +4096 -0
- package/dist/shared/{error-CIdnbKmG.mjs → error-bm-jLrD1.mjs} +1 -1
- package/dist/shared/get-log-filter-B6CU6b90.d.mts +34 -0
- package/dist/shared/{load-config-5r6l-9qr.mjs → load-config-Bu7-JwX4.mjs} +2 -2
- package/dist/shared/{logging-BSNejiLS.d.mts → logging-xuHO4mAy.d.mts} +6 -6
- package/dist/shared/{logs-ZGEh6uhb.mjs → logs-DmYCAKcW.mjs} +8 -1
- package/dist/shared/{misc-CoQm4NHO.mjs → misc-DOSKtd97.mjs} +9 -1
- package/dist/shared/{normalize-string-or-regex-oITfWWWc.mjs → normalize-string-or-regex-CiPu-0L6.mjs} +2 -2
- package/dist/shared/{parse-CI_bqXWS.mjs → parse-DFZrcERz.mjs} +2 -2
- package/dist/shared/{prompt--dNycKSZ.mjs → prompt-CH6TK0bC.mjs} +2 -6
- package/dist/shared/{resolve-tsconfig-9cpL_qUM.mjs → resolve-tsconfig-CsDgQmsO.mjs} +2 -2
- package/dist/shared/rolldown-CnVo3ESi.mjs +178 -0
- package/dist/shared/transform-CsZGbS4Q.d.mts +148 -0
- package/dist/shared/{watch-DElgNTzo.mjs → watch-WV6bq5kw.mjs} +16 -13
- package/dist/utils-index.d.mts +29 -30
- package/dist/utils-index.mjs +6 -8
- package/package.json +25 -16
- package/dist/shared/define-config-oNOGrLUX.d.mts +0 -4008
- package/dist/shared/get-log-filter-B4LpBryx.d.mts +0 -35
- package/dist/shared/rolldown-DBxQ1pTJ.mjs +0 -40
- package/dist/shared/transform-DmrnpNrQ.d.mts +0 -149
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { a as RolldownLog } from "./logging-xuHO4mAy.mjs";
|
|
2
|
+
//#region src/get-log-filter.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* @param filters A list of log filters to apply
|
|
5
|
+
* @returns A function that tests whether a log should be output
|
|
6
|
+
*
|
|
7
|
+
* @category Config
|
|
8
|
+
*/
|
|
9
|
+
type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* A helper function to generate log filters using the same syntax as the CLI.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { defineConfig } from '@rollipop/rolldown';
|
|
16
|
+
* import { getLogFilter } from '@rollipop/rolldown/getLogFilter';
|
|
17
|
+
*
|
|
18
|
+
* const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* input: 'main.js',
|
|
22
|
+
* onLog(level, log, handler) {
|
|
23
|
+
* if (logFilter(log)) {
|
|
24
|
+
* handler(level, log);
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @category Config
|
|
31
|
+
*/
|
|
32
|
+
declare const getLogFilter: GetLogFilter;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getLogFilter as n, GetLogFilter as t };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as rolldown } from "./rolldown-
|
|
1
|
+
import { t as rolldown } from "./rolldown-CnVo3ESi.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { readdir } from "node:fs/promises";
|
|
5
|
-
import { cwd } from "node:process";
|
|
6
5
|
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { cwd } from "node:process";
|
|
7
7
|
//#region src/utils/load-config.ts
|
|
8
8
|
async function bundleTsConfig(configFile, isEsm) {
|
|
9
9
|
const dirnameVarName = "injected_original_dirname";
|
|
@@ -9,9 +9,9 @@ interface RolldownLog {
|
|
|
9
9
|
binding?: string;
|
|
10
10
|
cause?: unknown;
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
* The log code for this log object.
|
|
13
|
+
* @example 'PLUGIN_ERROR'
|
|
14
|
+
*/
|
|
15
15
|
code?: string;
|
|
16
16
|
exporter?: string;
|
|
17
17
|
frame?: string;
|
|
@@ -24,9 +24,9 @@ interface RolldownLog {
|
|
|
24
24
|
line: number;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
* The message for this log object.
|
|
28
|
+
* @example 'The "transform" hook used by the output plugin "rolldown-plugin-foo" is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.'
|
|
29
|
+
*/
|
|
30
30
|
message: string;
|
|
31
31
|
meta?: any;
|
|
32
32
|
names?: string[];
|
|
@@ -103,6 +103,7 @@ const INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
|
|
|
103
103
|
const CYCLE_LOADING = "CYCLE_LOADING";
|
|
104
104
|
const MULTIPLE_WATCHER_OPTION = "MULTIPLE_WATCHER_OPTION";
|
|
105
105
|
const PARSE_ERROR = "PARSE_ERROR";
|
|
106
|
+
const VALIDATION_ERROR = "VALIDATION_ERROR";
|
|
106
107
|
function logParseError(message, id, pos) {
|
|
107
108
|
return {
|
|
108
109
|
code: PARSE_ERROR,
|
|
@@ -111,6 +112,12 @@ function logParseError(message, id, pos) {
|
|
|
111
112
|
pos
|
|
112
113
|
};
|
|
113
114
|
}
|
|
115
|
+
function logFailedValidation(message) {
|
|
116
|
+
return {
|
|
117
|
+
code: VALIDATION_ERROR,
|
|
118
|
+
message
|
|
119
|
+
};
|
|
120
|
+
}
|
|
114
121
|
function logInvalidLogPosition(pluginName) {
|
|
115
122
|
return {
|
|
116
123
|
code: INVALID_LOG_POSITION,
|
|
@@ -182,4 +189,4 @@ function augmentCodeLocation(properties, pos, source, id) {
|
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
//#endregion
|
|
185
|
-
export {
|
|
192
|
+
export { logInputHookInOutputPlugin as a, logParseError as c, getCodeFrame as d, logFailedValidation as i, logPluginError as l, error as n, logInvalidLogPosition as o, logCycleLoading as r, logMultipleWatcherOption as s, augmentCodeLocation as t, locate as u };
|
|
@@ -17,5 +17,13 @@ function unsupported(info) {
|
|
|
17
17
|
throw new Error(`UNSUPPORTED: ${info}`);
|
|
18
18
|
}
|
|
19
19
|
function noop(..._args) {}
|
|
20
|
+
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[/\\|])/;
|
|
21
|
+
/**
|
|
22
|
+
* Whether `name` is a path fragment — an absolute or relative path. Emitted file
|
|
23
|
+
* names, `[name]` substitutions and file-name patterns can be neither.
|
|
24
|
+
*/
|
|
25
|
+
function isPathFragment(name) {
|
|
26
|
+
return name[0] === "/" || name[0] === "." && (name[1] === "/" || name[1] === ".") || ABSOLUTE_PATH_REGEX.test(name);
|
|
27
|
+
}
|
|
20
28
|
//#endregion
|
|
21
|
-
export {
|
|
29
|
+
export { unimplemented as a, noop as i, isPathFragment as n, unreachable as o, isPromiseLike as r, unsupported as s, arraify as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-
|
|
2
|
-
import {
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-D_XVvOPT.mjs";
|
|
2
|
+
import { l as logPluginError, n as error } from "./logs-DmYCAKcW.mjs";
|
|
3
3
|
//#region src/builtin-plugin/utils.ts
|
|
4
4
|
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
5
5
|
var BuiltinPlugin = class {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-
|
|
2
|
-
//#region ../../node_modules/.pnpm/oxc-parser@0.
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-D_XVvOPT.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.142.0/node_modules/oxc-parser/src-js/wrap.js
|
|
3
3
|
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
4
4
|
function wrap(result) {
|
|
5
5
|
let program, module, comments, errors;
|
|
@@ -604,9 +604,7 @@ let wD = class extends x {
|
|
|
604
604
|
case "right":
|
|
605
605
|
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
606
606
|
break;
|
|
607
|
-
case "space":
|
|
608
|
-
this.toggleValue();
|
|
609
|
-
break;
|
|
607
|
+
case "space": this.toggleValue();
|
|
610
608
|
}
|
|
611
609
|
});
|
|
612
610
|
}
|
|
@@ -639,9 +637,7 @@ var jD = class extends x {
|
|
|
639
637
|
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
640
638
|
break;
|
|
641
639
|
case "down":
|
|
642
|
-
case "right":
|
|
643
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
644
|
-
break;
|
|
640
|
+
case "right": this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
645
641
|
}
|
|
646
642
|
this.changeValue();
|
|
647
643
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-
|
|
2
|
-
import { a as bindingifySourcemap, n as normalizeBindingError } from "./error-
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-D_XVvOPT.mjs";
|
|
2
|
+
import { a as bindingifySourcemap, n as normalizeBindingError } from "./error-bm-jLrD1.mjs";
|
|
3
3
|
//#region src/utils/minify.ts
|
|
4
4
|
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
5
5
|
/**
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-D_XVvOPT.mjs";
|
|
2
|
+
import { c as __decorate, d as PlainObjectLike, o as transformToRollupOutput, u as lazyProp } from "./bindingify-input-options-BXQG8xz-.mjs";
|
|
3
|
+
import { l as PluginDriver, s as validateOption, t as createBundlerOptions } from "./create-bundler-option-Be4KJzGL.mjs";
|
|
4
|
+
import { i as unwrapBindingResult } from "./error-bm-jLrD1.mjs";
|
|
5
|
+
//#region src/types/rolldown-output-impl.ts
|
|
6
|
+
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
7
|
+
var RolldownOutputImpl = class extends PlainObjectLike {
|
|
8
|
+
bindingOutputs;
|
|
9
|
+
constructor(bindingOutputs) {
|
|
10
|
+
super();
|
|
11
|
+
this.bindingOutputs = bindingOutputs;
|
|
12
|
+
}
|
|
13
|
+
get output() {
|
|
14
|
+
return transformToRollupOutput(this.bindingOutputs).output;
|
|
15
|
+
}
|
|
16
|
+
__rolldown_external_memory_handle__(keepDataAlive) {
|
|
17
|
+
const results = this.output.map((item) => item.__rolldown_external_memory_handle__(keepDataAlive));
|
|
18
|
+
if (!results.every((r) => r.freed)) {
|
|
19
|
+
const reasons = results.filter((r) => !r.freed).map((r) => r.reason).filter(Boolean);
|
|
20
|
+
return {
|
|
21
|
+
freed: false,
|
|
22
|
+
reason: `Failed to free ${reasons.length} item(s): ${reasons.join("; ")}`
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return { freed: true };
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
__decorate([lazyProp], RolldownOutputImpl.prototype, "output", null);
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/api/rolldown/rolldown-build.ts
|
|
31
|
+
Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
|
|
32
|
+
/**
|
|
33
|
+
* The bundle object returned by {@linkcode rolldown} function.
|
|
34
|
+
*
|
|
35
|
+
* @category Programmatic APIs
|
|
36
|
+
*/
|
|
37
|
+
var RolldownBuild = class {
|
|
38
|
+
#inputOptions;
|
|
39
|
+
#bundler;
|
|
40
|
+
#stopWorkers;
|
|
41
|
+
#asyncRuntimeReleased = false;
|
|
42
|
+
/** @hidden should not be used directly */
|
|
43
|
+
constructor(inputOptions) {
|
|
44
|
+
this.#inputOptions = inputOptions;
|
|
45
|
+
this.#bundler = new import_binding.BindingBundler();
|
|
46
|
+
(0, import_binding.startAsyncRuntime)();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether the bundle has been closed.
|
|
50
|
+
*
|
|
51
|
+
* If the bundle is closed, calling other methods will throw an error.
|
|
52
|
+
*/
|
|
53
|
+
get closed() {
|
|
54
|
+
return this.#bundler.closed;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Generate bundles in-memory.
|
|
58
|
+
*
|
|
59
|
+
* If you directly want to write bundles to disk, use the {@linkcode write} method instead.
|
|
60
|
+
*
|
|
61
|
+
* @param outputOptions The output options.
|
|
62
|
+
* @returns The generated bundle.
|
|
63
|
+
* @throws {@linkcode BundleError} When an error occurs during the build.
|
|
64
|
+
*/
|
|
65
|
+
async generate(outputOptions = {}) {
|
|
66
|
+
return this.#build(false, outputOptions);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Generate and write bundles to disk.
|
|
70
|
+
*
|
|
71
|
+
* If you want to generate bundles in-memory, use the {@linkcode generate} method instead.
|
|
72
|
+
*
|
|
73
|
+
* @param outputOptions The output options.
|
|
74
|
+
* @returns The generated bundle.
|
|
75
|
+
* @throws {@linkcode BundleError} When an error occurs during the build.
|
|
76
|
+
*/
|
|
77
|
+
async write(outputOptions = {}) {
|
|
78
|
+
return this.#build(true, outputOptions);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Close the bundle and free resources.
|
|
82
|
+
*
|
|
83
|
+
* This method should be called even if the {@linkcode generate} method
|
|
84
|
+
* or the {@linkcode write} method threw an error. It should be called
|
|
85
|
+
* even if neither of the methods are called.
|
|
86
|
+
*
|
|
87
|
+
* This method is called automatically when using `using` syntax.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```js
|
|
91
|
+
* import { rolldown } from '@rollipop/rolldown';
|
|
92
|
+
*
|
|
93
|
+
* {
|
|
94
|
+
* using bundle = await rolldown({ input: 'src/main.js' });
|
|
95
|
+
* const output = await bundle.generate({ format: 'esm' });
|
|
96
|
+
* console.log(output);
|
|
97
|
+
* // bundle.close() is called automatically here
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
async close() {
|
|
102
|
+
const shouldRelease = !this.#asyncRuntimeReleased;
|
|
103
|
+
this.#asyncRuntimeReleased = true;
|
|
104
|
+
try {
|
|
105
|
+
await this.#stopWorkers?.();
|
|
106
|
+
await this.#bundler.close();
|
|
107
|
+
this.#stopWorkers = void 0;
|
|
108
|
+
} finally {
|
|
109
|
+
if (shouldRelease) (0, import_binding.shutdownAsyncRuntime)();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** @hidden documented in close method */
|
|
113
|
+
async [Symbol.asyncDispose]() {
|
|
114
|
+
await this.close();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @experimental
|
|
118
|
+
* @hidden not ready for public usage yet
|
|
119
|
+
*/
|
|
120
|
+
get watchFiles() {
|
|
121
|
+
return Promise.resolve(this.#bundler.getWatchFiles());
|
|
122
|
+
}
|
|
123
|
+
async #build(isWrite, outputOptions) {
|
|
124
|
+
validateOption("output", outputOptions);
|
|
125
|
+
await this.#stopWorkers?.();
|
|
126
|
+
const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
|
|
127
|
+
try {
|
|
128
|
+
this.#stopWorkers = option.stopWorkers;
|
|
129
|
+
let output;
|
|
130
|
+
if (isWrite) output = await this.#bundler.write(option.bundlerOptions);
|
|
131
|
+
else output = await this.#bundler.generate(option.bundlerOptions);
|
|
132
|
+
return new RolldownOutputImpl(unwrapBindingResult(output));
|
|
133
|
+
} catch (e) {
|
|
134
|
+
await option.stopWorkers?.();
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/api/rolldown/index.ts
|
|
141
|
+
/**
|
|
142
|
+
* The API compatible with Rollup's `rollup` function.
|
|
143
|
+
*
|
|
144
|
+
* Unlike Rollup, the module graph is not built until the methods of the bundle object are called.
|
|
145
|
+
*
|
|
146
|
+
* @param input The input options object.
|
|
147
|
+
* @returns A Promise that resolves to a bundle object.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```js
|
|
151
|
+
* import { rolldown } from '@rollipop/rolldown';
|
|
152
|
+
*
|
|
153
|
+
* let bundle, failed = false;
|
|
154
|
+
* try {
|
|
155
|
+
* bundle = await rolldown({
|
|
156
|
+
* input: 'src/main.js',
|
|
157
|
+
* });
|
|
158
|
+
* await bundle.write({
|
|
159
|
+
* format: 'esm',
|
|
160
|
+
* });
|
|
161
|
+
* } catch (e) {
|
|
162
|
+
* console.error(e);
|
|
163
|
+
* failed = true;
|
|
164
|
+
* }
|
|
165
|
+
* if (bundle) {
|
|
166
|
+
* await bundle.close();
|
|
167
|
+
* }
|
|
168
|
+
* process.exitCode = failed ? 1 : 0;
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @category Programmatic APIs
|
|
172
|
+
*/
|
|
173
|
+
const rolldown = async (input) => {
|
|
174
|
+
validateOption("input", input);
|
|
175
|
+
return new RolldownBuild(await PluginDriver.callOptionsHook(input));
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
export { rolldown as t };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { a as RolldownLog } from "./logging-xuHO4mAy.mjs";
|
|
2
|
+
import { H as ParserOptions$1, L as MinifyOptions$1, R as MinifyResult$1, V as ParseResult$1, Y as TsconfigCache$1, a as BindingEnhancedTransformOptions, o as BindingEnhancedTransformResult, q as SourceMap, x as BindingTsconfigResult } from "./binding-We_IfeZk.mjs";
|
|
3
|
+
//#region src/utils/resolve-tsconfig.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cache for tsconfig resolution to avoid redundant file system operations.
|
|
6
|
+
*
|
|
7
|
+
* The cache stores resolved tsconfig configurations keyed by their file paths.
|
|
8
|
+
* When transforming multiple files in the same project, tsconfig lookups are
|
|
9
|
+
* deduplicated, improving performance.
|
|
10
|
+
*
|
|
11
|
+
* @category Utilities
|
|
12
|
+
* @experimental
|
|
13
|
+
*/
|
|
14
|
+
declare class TsconfigCache extends TsconfigCache$1 {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
/** @hidden This is only expected to be used by Vite */
|
|
18
|
+
declare function resolveTsconfig(filename: string, cache?: TsconfigCache | null): BindingTsconfigResult | null;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/utils/parse.d.ts
|
|
21
|
+
/**
|
|
22
|
+
* Result of parsing a code
|
|
23
|
+
*
|
|
24
|
+
* @category Utilities
|
|
25
|
+
*/
|
|
26
|
+
interface ParseResult extends ParseResult$1 {}
|
|
27
|
+
/**
|
|
28
|
+
* Options for parsing a code
|
|
29
|
+
*
|
|
30
|
+
* @category Utilities
|
|
31
|
+
*/
|
|
32
|
+
interface ParserOptions extends ParserOptions$1 {}
|
|
33
|
+
/**
|
|
34
|
+
* Parse JS/TS source asynchronously on a separate thread.
|
|
35
|
+
*
|
|
36
|
+
* Note that not all of the workload can happen on a separate thread.
|
|
37
|
+
* Parsing on Rust side does happen in a separate thread, but deserialization of the AST to JS objects
|
|
38
|
+
* has to happen on current thread. This synchronous deserialization work typically outweighs
|
|
39
|
+
* the asynchronous parsing by a factor of between 3 and 20.
|
|
40
|
+
*
|
|
41
|
+
* i.e. the majority of the workload cannot be parallelized by using this method.
|
|
42
|
+
*
|
|
43
|
+
* Generally {@linkcode parseSync} is preferable to use as it does not have the overhead of spawning a thread.
|
|
44
|
+
* If you need to parallelize parsing multiple files, it is recommended to use worker threads.
|
|
45
|
+
*
|
|
46
|
+
* @category Utilities
|
|
47
|
+
*/
|
|
48
|
+
declare function parse(filename: string, sourceText: string, options?: ParserOptions | null): Promise<ParseResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Parse JS/TS source synchronously on current thread.
|
|
51
|
+
*
|
|
52
|
+
* This is generally preferable over {@linkcode parse} (async) as it does not have the overhead
|
|
53
|
+
* of spawning a thread, and the majority of the workload cannot be parallelized anyway
|
|
54
|
+
* (see {@linkcode parse} documentation for details).
|
|
55
|
+
*
|
|
56
|
+
* If you need to parallelize parsing multiple files, it is recommended to use worker threads
|
|
57
|
+
* with {@linkcode parseSync} rather than using {@linkcode parse}.
|
|
58
|
+
*
|
|
59
|
+
* @category Utilities
|
|
60
|
+
*/
|
|
61
|
+
declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | null): ParseResult;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/utils/minify.d.ts
|
|
64
|
+
/**
|
|
65
|
+
* Options for minification.
|
|
66
|
+
*
|
|
67
|
+
* @category Utilities
|
|
68
|
+
*/
|
|
69
|
+
interface MinifyOptions extends MinifyOptions$1 {
|
|
70
|
+
inputMap?: SourceMap;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The result of minification.
|
|
74
|
+
*
|
|
75
|
+
* @category Utilities
|
|
76
|
+
*/
|
|
77
|
+
interface MinifyResult extends MinifyResult$1 {}
|
|
78
|
+
/**
|
|
79
|
+
* Minify asynchronously.
|
|
80
|
+
*
|
|
81
|
+
* Note: This function can be slower than {@linkcode minifySync} due to the overhead of spawning a thread.
|
|
82
|
+
*
|
|
83
|
+
* @category Utilities
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
declare function minify(filename: string, sourceText: string, options?: MinifyOptions | null): Promise<MinifyResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Minify synchronously.
|
|
89
|
+
*
|
|
90
|
+
* @category Utilities
|
|
91
|
+
* @experimental
|
|
92
|
+
*/
|
|
93
|
+
declare function minifySync(filename: string, sourceText: string, options?: MinifyOptions | null): MinifyResult;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/utils/transform.d.ts
|
|
96
|
+
/**
|
|
97
|
+
* Options for transforming a code.
|
|
98
|
+
*
|
|
99
|
+
* @category Utilities
|
|
100
|
+
*/
|
|
101
|
+
interface TransformOptions extends BindingEnhancedTransformOptions {}
|
|
102
|
+
/**
|
|
103
|
+
* Result of transforming a code.
|
|
104
|
+
*
|
|
105
|
+
* @category Utilities
|
|
106
|
+
*/
|
|
107
|
+
type TransformResult = Omit<BindingEnhancedTransformResult, "errors" | "warnings"> & {
|
|
108
|
+
errors: Error[];
|
|
109
|
+
warnings: RolldownLog[];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
|
|
113
|
+
*
|
|
114
|
+
* Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
|
|
115
|
+
*
|
|
116
|
+
* @param filename The name of the file being transformed. If this is a
|
|
117
|
+
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
|
|
118
|
+
* @param sourceText The source code to transform.
|
|
119
|
+
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
|
|
120
|
+
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
|
|
121
|
+
* Only used when `options.tsconfig` is `true`.
|
|
122
|
+
*
|
|
123
|
+
* @returns a promise that resolves to an object containing the transformed code,
|
|
124
|
+
* source maps, and any errors that occurred during parsing or transformation.
|
|
125
|
+
*
|
|
126
|
+
* @category Utilities
|
|
127
|
+
* @experimental
|
|
128
|
+
*/
|
|
129
|
+
declare function transform(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): Promise<TransformResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Transpile a JavaScript or TypeScript into a target ECMAScript version.
|
|
132
|
+
*
|
|
133
|
+
* @param filename The name of the file being transformed. If this is a
|
|
134
|
+
* relative path, consider setting the {@linkcode TransformOptions#cwd} option.
|
|
135
|
+
* @param sourceText The source code to transform.
|
|
136
|
+
* @param options The transform options including tsconfig and inputMap. See {@linkcode TransformOptions} for more information.
|
|
137
|
+
* @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
|
|
138
|
+
* Only used when `options.tsconfig` is `true`.
|
|
139
|
+
*
|
|
140
|
+
* @returns an object containing the transformed code, source maps, and any errors
|
|
141
|
+
* that occurred during parsing or transformation.
|
|
142
|
+
*
|
|
143
|
+
* @category Utilities
|
|
144
|
+
* @experimental
|
|
145
|
+
*/
|
|
146
|
+
declare function transformSync(filename: string, sourceText: string, options?: TransformOptions | null, cache?: TsconfigCache | null): TransformResult;
|
|
147
|
+
//#endregion
|
|
148
|
+
export { MinifyOptions as a, minifySync as c, parse as d, parseSync as f, transformSync as i, ParseResult as l, resolveTsconfig as m, TransformResult as n, MinifyResult as o, TsconfigCache as p, transform as r, minify as s, TransformOptions as t, ParserOptions as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as arraify } from "./misc-
|
|
5
|
-
import {
|
|
6
|
-
import { t as aggregateBindingErrorsIntoJsError } from "./error-
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-D_XVvOPT.mjs";
|
|
2
|
+
import { s as logMultipleWatcherOption } from "./logs-DmYCAKcW.mjs";
|
|
3
|
+
import { y as LOG_LEVEL_WARN } from "./bindingify-input-options-BXQG8xz-.mjs";
|
|
4
|
+
import { t as arraify } from "./misc-DOSKtd97.mjs";
|
|
5
|
+
import { l as PluginDriver, t as createBundlerOptions } from "./create-bundler-option-Be4KJzGL.mjs";
|
|
6
|
+
import { t as aggregateBindingErrorsIntoJsError } from "./error-bm-jLrD1.mjs";
|
|
7
7
|
//#region ../../node_modules/.pnpm/signal-exit@4.1.0/node_modules/signal-exit/dist/mjs/signals.js
|
|
8
8
|
/**
|
|
9
9
|
* This is not the set of all possible signals.
|
|
@@ -276,9 +276,7 @@ function createEventCallback(emitter) {
|
|
|
276
276
|
case "restart":
|
|
277
277
|
await emitter.emit("restart");
|
|
278
278
|
break;
|
|
279
|
-
case "close":
|
|
280
|
-
await emitter.emit("close");
|
|
281
|
-
break;
|
|
279
|
+
case "close": await emitter.emit("close");
|
|
282
280
|
}
|
|
283
281
|
};
|
|
284
282
|
}
|
|
@@ -291,6 +289,7 @@ var Watcher = class {
|
|
|
291
289
|
this.closed = false;
|
|
292
290
|
this.inner = inner;
|
|
293
291
|
this.emitter = emitter;
|
|
292
|
+
(0, import_binding.startAsyncRuntime)();
|
|
294
293
|
const originClose = emitter.close.bind(emitter);
|
|
295
294
|
emitter.close = async () => {
|
|
296
295
|
await this.close();
|
|
@@ -302,9 +301,12 @@ var Watcher = class {
|
|
|
302
301
|
async close() {
|
|
303
302
|
if (this.closed) return;
|
|
304
303
|
this.closed = true;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
try {
|
|
305
|
+
for (const stop of this.stopWorkers) await stop?.();
|
|
306
|
+
await this.inner.close();
|
|
307
|
+
} finally {
|
|
308
|
+
(0, import_binding.shutdownAsyncRuntime)();
|
|
309
|
+
}
|
|
308
310
|
}
|
|
309
311
|
async run() {
|
|
310
312
|
await this.inner.run();
|
|
@@ -314,7 +316,8 @@ var Watcher = class {
|
|
|
314
316
|
async function createWatcher(emitter, input) {
|
|
315
317
|
const options = arraify(input);
|
|
316
318
|
const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
|
|
317
|
-
|
|
319
|
+
const inputOptions = await PluginDriver.callOptionsHook(option, true);
|
|
320
|
+
return createBundlerOptions(inputOptions, output, true);
|
|
318
321
|
})).flat());
|
|
319
322
|
warnMultiplePollingOptions(bundlerOptions);
|
|
320
323
|
const callback = createEventCallback(emitter);
|
package/dist/utils-index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as MinifyOptions, c as minifySync, d as parse, f as parseSync, i as transformSync, l as ParseResult, n as TransformResult, o as MinifyResult, p as TsconfigCache, r as transform, s as minify, t as TransformOptions, u as ParserOptions } from "./shared/transform-
|
|
1
|
+
import { b as BindingTsconfigRawOptions, y as BindingTsconfigCompilerOptions } from "./shared/binding-We_IfeZk.mjs";
|
|
2
|
+
import { a as MinifyOptions, c as minifySync, d as parse, f as parseSync, i as transformSync, l as ParseResult, n as TransformResult, o as MinifyResult, p as TsconfigCache, r as transform, s as minify, t as TransformOptions, u as ParserOptions } from "./shared/transform-CsZGbS4Q.mjs";
|
|
3
3
|
import * as ESTree from "@oxc-project/types";
|
|
4
4
|
import { Program } from "@oxc-project/types";
|
|
5
|
-
|
|
6
|
-
//#region ../../node_modules/.pnpm/oxc-parser@0.139.0/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts
|
|
5
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.142.0/node_modules/oxc-parser/src-js/generated/visit/visitor.d.ts
|
|
7
6
|
interface VisitorObject$1 {
|
|
8
7
|
DebuggerStatement?: (node: ESTree.DebuggerStatement) => void;
|
|
9
8
|
"DebuggerStatement:exit"?: (node: ESTree.DebuggerStatement) => void;
|
|
@@ -339,34 +338,34 @@ interface VisitorObject$1 {
|
|
|
339
338
|
//#endregion
|
|
340
339
|
//#region src/utils/visitor.d.ts
|
|
341
340
|
/**
|
|
342
|
-
* Visitor object for traversing AST.
|
|
343
|
-
*
|
|
344
|
-
* @category Utilities
|
|
345
|
-
*/
|
|
341
|
+
* Visitor object for traversing AST.
|
|
342
|
+
*
|
|
343
|
+
* @category Utilities
|
|
344
|
+
*/
|
|
346
345
|
type VisitorObject = VisitorObject$1;
|
|
347
346
|
/**
|
|
348
|
-
* Visitor class for traversing AST.
|
|
349
|
-
*
|
|
350
|
-
* @example
|
|
351
|
-
* ```ts
|
|
352
|
-
* import { Visitor } from '@rollipop/rolldown/utils';
|
|
353
|
-
* import { parseSync } from '@rollipop/rolldown/utils';
|
|
354
|
-
*
|
|
355
|
-
* const result = parseSync(...);
|
|
356
|
-
* const visitor = new Visitor({
|
|
357
|
-
* VariableDeclaration(path) {
|
|
358
|
-
* // Do something with the variable declaration
|
|
359
|
-
* },
|
|
360
|
-
* "VariableDeclaration:exit"(path) {
|
|
361
|
-
* // Do something after visiting the variable declaration
|
|
362
|
-
* }
|
|
363
|
-
* });
|
|
364
|
-
* visitor.visit(result.program);
|
|
365
|
-
* ```
|
|
366
|
-
*
|
|
367
|
-
* @category Utilities
|
|
368
|
-
* @experimental
|
|
369
|
-
*/
|
|
347
|
+
* Visitor class for traversing AST.
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* import { Visitor } from '@rollipop/rolldown/utils';
|
|
352
|
+
* import { parseSync } from '@rollipop/rolldown/utils';
|
|
353
|
+
*
|
|
354
|
+
* const result = parseSync(...);
|
|
355
|
+
* const visitor = new Visitor({
|
|
356
|
+
* VariableDeclaration(path) {
|
|
357
|
+
* // Do something with the variable declaration
|
|
358
|
+
* },
|
|
359
|
+
* "VariableDeclaration:exit"(path) {
|
|
360
|
+
* // Do something after visiting the variable declaration
|
|
361
|
+
* }
|
|
362
|
+
* });
|
|
363
|
+
* visitor.visit(result.program);
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @category Utilities
|
|
367
|
+
* @experimental
|
|
368
|
+
*/
|
|
370
369
|
declare class Visitor {
|
|
371
370
|
#private;
|
|
372
371
|
constructor(visitor: VisitorObject);
|