rolldown 1.2.0 → 1.2.2
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.d.mts +1 -1
- package/dist/cli.mjs +9 -10
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +2 -2
- package/dist/experimental-default-runtime.mjs +116 -0
- package/dist/experimental-index.d.mts +10 -4
- package/dist/experimental-index.mjs +32 -16
- package/dist/experimental-runtime-base.mjs +95 -0
- package/dist/experimental-runtime.d.ts +177 -0
- package/dist/experimental-runtime.mjs +257 -0
- package/dist/filter-index.d.mts +1 -1
- package/dist/filter-index.mjs +1 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/parallel-plugin-worker.d.mts +1 -1
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.mts +1 -1
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +2 -2
- package/dist/plugins-index.d.mts +3 -3
- package/dist/plugins-index.mjs +2 -2
- package/dist/shared/{binding-Dbbi0RbO.d.mts → binding-CVtkJvyl.d.mts} +11 -0
- package/dist/shared/{binding-Dby9rwGk.mjs → binding-DwUQWZOo.mjs} +124 -50
- package/dist/shared/{bindingify-input-options-_ppP73I9.mjs → bindingify-input-options-BHixd47T.mjs} +448 -268
- package/dist/shared/{constructors-CSWbNgBZ.d.mts → constructors-ALilxAii.d.mts} +2 -2
- package/dist/shared/{constructors-CuGa75s-.mjs → constructors-COwFYQna.mjs} +10 -6
- package/dist/shared/{rolldown-build-CdF8HAHX.mjs → create-bundler-option-LuUKlAT7.mjs} +72 -179
- package/dist/shared/{define-config-B-IDOhDz.d.mts → define-config-DSMNXceb.d.mts} +85 -22
- package/dist/shared/{error-DFGNOCle.mjs → error-nLggAzpQ.mjs} +1 -1
- package/dist/shared/{load-config-C6UyiS41.mjs → load-config-cRWJAHTc.mjs} +2 -2
- 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-SiXbePVH.mjs → normalize-string-or-regex-Cj-DgIV1.mjs} +2 -2
- package/dist/shared/{parse-BFj5G_7i.mjs → parse-C17W7W5g.mjs} +2 -2
- package/dist/shared/{prompt--dNycKSZ.mjs → prompt-CH6TK0bC.mjs} +2 -6
- package/dist/shared/{resolve-tsconfig-2TXRF_zr.mjs → resolve-tsconfig-CE3HNSOK.mjs} +2 -2
- package/dist/shared/rolldown-D23fYgSS.mjs +178 -0
- package/dist/shared/{transform-Cs2bUDRH.d.mts → transform-WmU_cI8e.d.mts} +1 -1
- package/dist/shared/{watch-WnrlHRS0.mjs → watch-DcgK_L55.mjs} +16 -13
- package/dist/utils-index.d.mts +3 -3
- package/dist/utils-index.mjs +6 -8
- package/package.json +32 -25
- package/dist/shared/rolldown-951h_1lf.mjs +0 -40
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
MIT License
|
|
14
|
+
|
|
15
|
+
Copyright (c) 2020 Evan Wallace
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
in the Software without restriction, including without limitation the rights
|
|
20
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
furnished to do so, subject to the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
SOFTWARE.
|
package/dist/cli.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as onExit, t as watch } from "./shared/watch-
|
|
2
|
-
import {
|
|
3
|
-
import { t as arraify } from "./shared/misc-
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as rolldown } from "./shared/rolldown-
|
|
6
|
-
import { t as loadConfig } from "./shared/load-config-
|
|
1
|
+
import { n as onExit, t as watch } from "./shared/watch-DcgK_L55.mjs";
|
|
2
|
+
import { D as version, E as description } from "./shared/bindingify-input-options-BHixd47T.mjs";
|
|
3
|
+
import { t as arraify } from "./shared/misc-DOSKtd97.mjs";
|
|
4
|
+
import { a as getOutputCliKeys, c as styleText, i as getInputCliKeys, n as logger, o as validateCliOptions, r as getCliSchemaInfo } from "./shared/create-bundler-option-LuUKlAT7.mjs";
|
|
5
|
+
import { t as rolldown } from "./shared/rolldown-D23fYgSS.mjs";
|
|
6
|
+
import { t as loadConfig } from "./shared/load-config-cRWJAHTc.mjs";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import g$1 from "node:process";
|
|
9
9
|
import { performance } from "node:perf_hooks";
|
|
@@ -862,7 +862,7 @@ function getClearScreenFunction(options) {
|
|
|
862
862
|
};
|
|
863
863
|
}
|
|
864
864
|
//#endregion
|
|
865
|
-
//#region \0@oxc-project+runtime@0.
|
|
865
|
+
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/usingCtx.js
|
|
866
866
|
function _usingCtx() {
|
|
867
867
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
868
868
|
var n = Error();
|
|
@@ -947,7 +947,8 @@ async function bundleWithCliOptions(cliOptions) {
|
|
|
947
947
|
const { output: outputs } = await _usingCtx$1.a(await rolldown(cliOptions.input)).generate(cliOptions.output);
|
|
948
948
|
if (outputs.length === 0) {
|
|
949
949
|
logger.error("No output generated");
|
|
950
|
-
process.
|
|
950
|
+
process.exitCode = 1;
|
|
951
|
+
return;
|
|
951
952
|
}
|
|
952
953
|
for (const file of outputs) {
|
|
953
954
|
if (outputs.length > 1) logger.log(`\n${styleText(["cyan", "bold"], `|→ ${file.fileName}:`)}\n`);
|
|
@@ -1000,8 +1001,6 @@ async function watchInner(config, cliOptions) {
|
|
|
1000
1001
|
case "ERROR":
|
|
1001
1002
|
await event.result.close();
|
|
1002
1003
|
logger.error(event.error);
|
|
1003
|
-
break;
|
|
1004
|
-
default: break;
|
|
1005
1004
|
}
|
|
1006
1005
|
});
|
|
1007
1006
|
logger.log(`Waiting for changes...`);
|
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-DSMNXceb.mjs";
|
|
2
2
|
//#region src/utils/load-config.d.ts
|
|
3
3
|
type ConfigLoader = "bundle" | "native";
|
|
4
4
|
interface LoadConfigOptions {
|
package/dist/config.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as VERSION } from "./shared/bindingify-input-options-BHixd47T.mjs";
|
|
2
2
|
import { t as defineConfig } from "./shared/define-config-Demdg3_4.mjs";
|
|
3
|
-
import { t as loadConfig } from "./shared/load-config-
|
|
3
|
+
import { t as loadConfig } from "./shared/load-config-cRWJAHTc.mjs";
|
|
4
4
|
export { VERSION, defineConfig, loadConfig };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @import { DevRuntime } from './runtime-extra-dev-common.js' */
|
|
4
|
+
|
|
5
|
+
/** @type {typeof DevRuntime} */
|
|
6
|
+
// @ts-expect-error -- there's no way to declare a variable by JSDoc
|
|
7
|
+
var BaseDevRuntime = DevRuntime;
|
|
8
|
+
|
|
9
|
+
class ModuleHotContext {
|
|
10
|
+
/**
|
|
11
|
+
* @type {{ deps: [string], fn: (moduleExports: Record<string, any>[]) => void }[]}
|
|
12
|
+
*/
|
|
13
|
+
acceptCallbacks = [];
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} moduleId
|
|
16
|
+
* @param {InstanceType<BaseDevRuntime>} devRuntime
|
|
17
|
+
*/
|
|
18
|
+
constructor(moduleId, devRuntime) {
|
|
19
|
+
this.moduleId = moduleId;
|
|
20
|
+
this.devRuntime = devRuntime;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @overload
|
|
25
|
+
* @param {(mod: Record<string, any>) => void} cb
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @param {...any} args
|
|
30
|
+
* @returns {void}
|
|
31
|
+
*/
|
|
32
|
+
accept(...args) {
|
|
33
|
+
if (args.length === 1) {
|
|
34
|
+
const [cb] = /** @type {[(mod: Record<string, any>) => void]} */ (args);
|
|
35
|
+
const acceptingPath = this.moduleId;
|
|
36
|
+
this.acceptCallbacks.push({
|
|
37
|
+
deps: [acceptingPath],
|
|
38
|
+
fn: cb,
|
|
39
|
+
});
|
|
40
|
+
} else if (args.length === 0) {}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error('Invalid arguments for `import.meta.hot.accept`');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
invalidate() {
|
|
47
|
+
socket.send(JSON.stringify({
|
|
48
|
+
type: 'hmr:invalidate',
|
|
49
|
+
moduleId: this.moduleId,
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class DefaultDevRuntime extends BaseDevRuntime {
|
|
55
|
+
/**
|
|
56
|
+
* @type {Map<string, ModuleHotContext>}
|
|
57
|
+
*/
|
|
58
|
+
moduleHotContexts = new Map();
|
|
59
|
+
/**
|
|
60
|
+
* @override
|
|
61
|
+
* @param {string} moduleId
|
|
62
|
+
*/
|
|
63
|
+
createModuleHotContext(moduleId) {
|
|
64
|
+
const hotContext = new ModuleHotContext(moduleId, this);
|
|
65
|
+
this.moduleHotContexts.set(moduleId, hotContext);
|
|
66
|
+
return hotContext;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @param {string} url */
|
|
71
|
+
function loadScript(url) {
|
|
72
|
+
var script = document.createElement('script');
|
|
73
|
+
script.src = url;
|
|
74
|
+
script.type = 'module';
|
|
75
|
+
script.onerror = function() {
|
|
76
|
+
console.error('Failed to load script: ' + url);
|
|
77
|
+
};
|
|
78
|
+
document.body.appendChild(script);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
console.debug('HMR runtime loaded', '$ADDR');
|
|
82
|
+
// Generate client ID immediately at runtime initialization
|
|
83
|
+
// This ensures the client ID is available before any lazy imports
|
|
84
|
+
const clientId = crypto.randomUUID();
|
|
85
|
+
const addr = new URL('ws://$ADDR');
|
|
86
|
+
addr.searchParams.set('clientId', clientId);
|
|
87
|
+
|
|
88
|
+
const socket = new WebSocket(addr);
|
|
89
|
+
|
|
90
|
+
(/** @type {any} */ (globalThis)).__rolldown_runtime__ ??=
|
|
91
|
+
new DefaultDevRuntime(clientId);
|
|
92
|
+
|
|
93
|
+
/** @param {MessageEvent} event */
|
|
94
|
+
socket.onmessage = function(event) {
|
|
95
|
+
const data = JSON.parse(event.data);
|
|
96
|
+
console.debug('Received message:', data);
|
|
97
|
+
if (data.type === 'connected') {
|
|
98
|
+
// Server acknowledged the connection
|
|
99
|
+
console.debug('[hmr]: Connection established with server');
|
|
100
|
+
} else if (data.type === 'hmr:update') {
|
|
101
|
+
if (typeof process === 'object') {
|
|
102
|
+
import(data.path);
|
|
103
|
+
console.debug(`[hmr]: Importing HMR patch: ${data.path}`);
|
|
104
|
+
} else {
|
|
105
|
+
console.debug(`[hmr]: Loading HMR patch: ${data.path}`);
|
|
106
|
+
loadScript(data.url);
|
|
107
|
+
}
|
|
108
|
+
} else if (data.type === 'hmr:reload') {
|
|
109
|
+
console.log('[hmr]: Full reload required, reloading page');
|
|
110
|
+
if (typeof location !== 'undefined') {
|
|
111
|
+
location.reload();
|
|
112
|
+
} else {
|
|
113
|
+
console.log('[hmr]: location is undefined, cannot reload page');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { H as ResolverFactory, J as moduleRunnerTransform, K as isolatedDeclaration, L as NapiResolveOptions, M as IsolatedDeclarationsOptions, N as IsolatedDeclarationsResult, V as ResolveResult, _ as BindingTsconfigCompilerOptions, i as BindingClientHmrUpdate, k as BindingViteTransformPluginConfig, n as BindingBundleAnalyzerPluginConfig, p as BindingRebuildStrategy, q as isolatedDeclarationSync, r as BindingBundleState, u as BindingLazyChunkOutput, v as BindingTsconfigRawOptions, w as BindingViteManifestPluginConfig } from "./shared/binding-
|
|
2
|
-
import {
|
|
3
|
-
import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-
|
|
4
|
-
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-
|
|
1
|
+
import { H as ResolverFactory, J as moduleRunnerTransform, K as isolatedDeclaration, L as NapiResolveOptions, M as IsolatedDeclarationsOptions, N as IsolatedDeclarationsResult, V as ResolveResult, _ as BindingTsconfigCompilerOptions, i as BindingClientHmrUpdate, k as BindingViteTransformPluginConfig, n as BindingBundleAnalyzerPluginConfig, p as BindingRebuildStrategy, q as isolatedDeclarationSync, r as BindingBundleState, u as BindingLazyChunkOutput, v as BindingTsconfigRawOptions, w as BindingViteManifestPluginConfig } from "./shared/binding-CVtkJvyl.mjs";
|
|
2
|
+
import { $ as defineParallelPlugin, Gt as StringOrRegExp, I as BuiltinPlugin, Qt as freeExternalMemory, Vt as OutputOptions, Xt as RolldownOutput, l as InputOptions, ut as NormalizedOutputOptions } from "./shared/define-config-DSMNXceb.mjs";
|
|
3
|
+
import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-WmU_cI8e.mjs";
|
|
4
|
+
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-ALilxAii.mjs";
|
|
5
5
|
//#region src/api/dev/dev-options.d.ts
|
|
6
6
|
type DevOnHmrUpdates = (result: Error | {
|
|
7
7
|
updates: BindingClientHmrUpdate[];
|
|
@@ -10,6 +10,12 @@ type DevOnHmrUpdates = (result: Error | {
|
|
|
10
10
|
type DevOnOutput = (result: Error | RolldownOutput) => void | Promise<void>;
|
|
11
11
|
type DevOnAdditionalAssets = (output: RolldownOutput) => void | Promise<void>;
|
|
12
12
|
interface DevWatchOptions {
|
|
13
|
+
/**
|
|
14
|
+
* If `false`, no file system watcher is started, so file changes are never
|
|
15
|
+
* picked up and no rebuild or HMR update is triggered on their own.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
enabled?: boolean;
|
|
13
19
|
/**
|
|
14
20
|
* If `true`, files are not written to disk.
|
|
15
21
|
* @default false
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./shared/binding-
|
|
2
|
-
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-
|
|
6
|
-
import { n as parseSync$1, t as parse$1 } from "./shared/parse-
|
|
7
|
-
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-
|
|
8
|
-
import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./shared/binding-DwUQWZOo.mjs";
|
|
2
|
+
import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-Cj-DgIV1.mjs";
|
|
3
|
+
import { u as transformToRollupOutput } from "./shared/bindingify-input-options-BHixd47T.mjs";
|
|
4
|
+
import { l as PluginDriver, s as validateOption, t as createBundlerOptions } from "./shared/create-bundler-option-LuUKlAT7.mjs";
|
|
5
|
+
import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-nLggAzpQ.mjs";
|
|
6
|
+
import { n as parseSync$1, t as parse$1 } from "./shared/parse-C17W7W5g.mjs";
|
|
7
|
+
import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-COwFYQna.mjs";
|
|
8
|
+
import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-CE3HNSOK.mjs";
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
//#region src/api/dev/dev-engine.ts
|
|
11
11
|
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
12
12
|
var DevEngine = class DevEngine {
|
|
13
13
|
#inner;
|
|
14
14
|
#cachedBuildFinishPromise = null;
|
|
15
|
+
#asyncRuntimeReleased = false;
|
|
15
16
|
static async create(inputOptions, outputOptions = {}, devOptions = {}) {
|
|
16
17
|
inputOptions = await PluginDriver.callOptionsHook(inputOptions);
|
|
17
18
|
const options = await createBundlerOptions(inputOptions, outputOptions, false);
|
|
@@ -46,6 +47,7 @@ var DevEngine = class DevEngine {
|
|
|
46
47
|
} : void 0,
|
|
47
48
|
rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : import_binding.BindingRebuildStrategy.Never : void 0,
|
|
48
49
|
watch: devOptions.watch && {
|
|
50
|
+
enabled: devOptions.watch.enabled,
|
|
49
51
|
skipWrite: devOptions.watch.skipWrite,
|
|
50
52
|
usePolling: devOptions.watch.usePolling,
|
|
51
53
|
pollInterval: devOptions.watch.pollInterval,
|
|
@@ -58,6 +60,7 @@ var DevEngine = class DevEngine {
|
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
const inner = new import_binding.BindingDevEngine(options.bundlerOptions, bindingDevOptions);
|
|
63
|
+
(0, import_binding.startAsyncRuntime)();
|
|
61
64
|
return new DevEngine(inner);
|
|
62
65
|
}
|
|
63
66
|
constructor(inner) {
|
|
@@ -101,7 +104,13 @@ var DevEngine = class DevEngine {
|
|
|
101
104
|
await this.#inner.removeClient(clientId);
|
|
102
105
|
}
|
|
103
106
|
async close() {
|
|
104
|
-
|
|
107
|
+
const shouldRelease = !this.#asyncRuntimeReleased;
|
|
108
|
+
this.#asyncRuntimeReleased = true;
|
|
109
|
+
try {
|
|
110
|
+
await this.#inner.close();
|
|
111
|
+
} finally {
|
|
112
|
+
if (shouldRelease) (0, import_binding.shutdownAsyncRuntime)();
|
|
113
|
+
}
|
|
105
114
|
}
|
|
106
115
|
/**
|
|
107
116
|
* Compile a lazy entry module and return HMR-style patch code.
|
|
@@ -182,18 +191,25 @@ function freeExternalMemory(handle, keepDataAlive = false) {
|
|
|
182
191
|
const scan = async (rawInputOptions, rawOutputOptions = {}) => {
|
|
183
192
|
validateOption("input", rawInputOptions);
|
|
184
193
|
validateOption("output", rawOutputOptions);
|
|
185
|
-
const
|
|
194
|
+
const inputOptions = await PluginDriver.callOptionsHook(rawInputOptions);
|
|
195
|
+
const ret = await createBundlerOptions(inputOptions, rawOutputOptions, false);
|
|
186
196
|
const bundler = new import_binding.BindingBundler();
|
|
187
|
-
|
|
197
|
+
(0, import_binding.startAsyncRuntime)();
|
|
198
|
+
let cleanedUp = false;
|
|
188
199
|
async function cleanup() {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
if (cleanedUp) return;
|
|
201
|
+
cleanedUp = true;
|
|
202
|
+
try {
|
|
203
|
+
await bundler.close();
|
|
204
|
+
await ret.stopWorkers?.();
|
|
205
|
+
} finally {
|
|
206
|
+
(0, import_binding.shutdownAsyncRuntime)();
|
|
207
|
+
}
|
|
193
208
|
}
|
|
194
209
|
let cleanupPromise = Promise.resolve();
|
|
195
210
|
try {
|
|
196
|
-
|
|
211
|
+
const result = await bundler.scan(ret.bundlerOptions);
|
|
212
|
+
unwrapBindingResult(result);
|
|
197
213
|
} catch (err) {
|
|
198
214
|
await cleanup();
|
|
199
215
|
throw err;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export var __create = Object.create;
|
|
2
|
+
export var __defProp = Object.defineProperty;
|
|
3
|
+
export var __name = (target, value) => __defProp(target, 'name', { value, configurable: true });
|
|
4
|
+
export var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
export var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
export var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
export var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
export var __esm = (fn, res, err) =>
|
|
9
|
+
function () {
|
|
10
|
+
if (err) throw err[0];
|
|
11
|
+
try {
|
|
12
|
+
return (fn && (res = (0, fn[__getOwnPropNames(fn)[0]])((fn = 0))), res);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw ((err = [e]), e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export var __esmMin = (fn, res, err) => () => {
|
|
18
|
+
if (err) throw err[0];
|
|
19
|
+
try {
|
|
20
|
+
return (fn && (res = fn((fn = 0))), res);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
throw ((err = [e]), e);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export var __commonJS = (cb, mod) =>
|
|
26
|
+
function () {
|
|
27
|
+
return (
|
|
28
|
+
mod || ((0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), cb = null), mod.exports
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
export var __commonJSMin = (cb, mod) => () => (
|
|
32
|
+
mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports
|
|
33
|
+
);
|
|
34
|
+
export var __exportAll = (all, no_symbols) => {
|
|
35
|
+
let target = {};
|
|
36
|
+
for (var name in all) {
|
|
37
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
38
|
+
}
|
|
39
|
+
if (!no_symbols) {
|
|
40
|
+
__defProp(target, Symbol.toStringTag, { value: 'Module' });
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
};
|
|
44
|
+
export var __copyProps = (to, from, except, desc) => {
|
|
45
|
+
if ((from && typeof from === 'object') || typeof from === 'function') {
|
|
46
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
47
|
+
key = keys[i];
|
|
48
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
49
|
+
__defProp(to, key, {
|
|
50
|
+
get: ((k) => from[k]).bind(null, key),
|
|
51
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to;
|
|
57
|
+
};
|
|
58
|
+
export var __reExport = (target, mod, secondTarget) => (
|
|
59
|
+
__copyProps(target, mod, 'default'), secondTarget && __copyProps(secondTarget, mod, 'default')
|
|
60
|
+
);
|
|
61
|
+
export var __toESM = (mod, isNodeMode, target) => (
|
|
62
|
+
(target = mod != null ? __create(__getProtoOf(mod)) : {}),
|
|
63
|
+
__copyProps(
|
|
64
|
+
// `__esModule` alone is not enough: the module must own a `default` (#10360).
|
|
65
|
+
isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, 'default')
|
|
66
|
+
? __defProp(target, 'default', { value: mod, enumerable: true })
|
|
67
|
+
: target,
|
|
68
|
+
mod,
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
export var __toCommonJS = (mod) =>
|
|
72
|
+
__hasOwnProp.call(mod, 'module.exports')
|
|
73
|
+
? mod['module.exports']
|
|
74
|
+
: __copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
75
|
+
export var __toBinaryNode = (base64) => new Uint8Array(Buffer.from(base64, 'base64'));
|
|
76
|
+
export var __toBinary = /* @__PURE__ */ (() => {
|
|
77
|
+
var table = new Uint8Array(128);
|
|
78
|
+
for (var i = 0; i < 64; i++) {
|
|
79
|
+
table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
|
|
80
|
+
}
|
|
81
|
+
return (base64) => {
|
|
82
|
+
var n = base64.length,
|
|
83
|
+
bytes = new Uint8Array((((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3) / 4) | 0);
|
|
84
|
+
for (var i = 0, j = 0; i < n; ) {
|
|
85
|
+
var c0 = table[base64.charCodeAt(i++)],
|
|
86
|
+
c1 = table[base64.charCodeAt(i++)];
|
|
87
|
+
var c2 = table[base64.charCodeAt(i++)],
|
|
88
|
+
c3 = table[base64.charCodeAt(i++)];
|
|
89
|
+
bytes[j++] = (c0 << 2) | (c1 >> 4);
|
|
90
|
+
bytes[j++] = (c1 << 4) | (c2 >> 2);
|
|
91
|
+
bytes[j++] = (c2 << 6) | c3;
|
|
92
|
+
}
|
|
93
|
+
return bytes;
|
|
94
|
+
};
|
|
95
|
+
})();
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
|
|
3
|
+
* `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
|
|
4
|
+
* `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
|
|
5
|
+
* @typedef {{ ids: string[], localCount: number, edges: number[][], dynamicEdges?: number[][] }} ModuleGraphDelta
|
|
6
|
+
* @typedef {{ createModuleHotContext(moduleId: string): any, onModuleCacheRemoval(moduleId: string): void }} DevRuntimeHooks
|
|
7
|
+
*/
|
|
8
|
+
export class MissingFactoryError {
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} id
|
|
11
|
+
*/
|
|
12
|
+
constructor(id: string);
|
|
13
|
+
id: string;
|
|
14
|
+
}
|
|
15
|
+
export class DevRuntime {
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} clientId
|
|
18
|
+
*/
|
|
19
|
+
constructor(clientId: string);
|
|
20
|
+
/**
|
|
21
|
+
* Client ID generated at runtime initialization, used for lazy compilation requests.
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
clientId: string;
|
|
25
|
+
/**
|
|
26
|
+
* Static import edges from `registerGraph` — entries persist across `removeModuleCache`
|
|
27
|
+
* and change only by replacement from a newer payload (last write wins).
|
|
28
|
+
* @type {Map<string, { edges: string[] }>}
|
|
29
|
+
*/
|
|
30
|
+
staticImports: Map<string, {
|
|
31
|
+
edges: string[];
|
|
32
|
+
}>;
|
|
33
|
+
/**
|
|
34
|
+
* Reverse index over the static imports.
|
|
35
|
+
* @type {Map<string, Set<string>>}
|
|
36
|
+
*/
|
|
37
|
+
importers: Map<string, Set<string>>;
|
|
38
|
+
/**
|
|
39
|
+
* Dynamic `import()` edges from `registerGraph`, keyed by importer — mirror of
|
|
40
|
+
* `staticImports` for the dynamic reverse index.
|
|
41
|
+
* @type {Map<string, { edges: string[] }>}
|
|
42
|
+
*/
|
|
43
|
+
dynamicImports: Map<string, {
|
|
44
|
+
edges: string[];
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Reverse index over the dynamic imports.
|
|
48
|
+
* @type {Map<string, Set<string>>}
|
|
49
|
+
*/
|
|
50
|
+
dynamicImporters: Map<string, Set<string>>;
|
|
51
|
+
/**
|
|
52
|
+
* The module cache. Membership means "this module's side effects ran in this tab" —
|
|
53
|
+
* registration is emitted ahead of every module body, and nothing un-registers on
|
|
54
|
+
* unwind, so a factory that throws mid-body stays registered. A `Map` rather than a
|
|
55
|
+
* plain object: HMR eviction deletes entries, and a `delete` on an object drops V8
|
|
56
|
+
* into dictionary mode, taxing every later lookup on the hottest read path.
|
|
57
|
+
* @type {Map<string, Module>}
|
|
58
|
+
*/
|
|
59
|
+
moduleCache: Map<string, Module>;
|
|
60
|
+
/**
|
|
61
|
+
* Re-runnable factories from HMR patches and lazy chunks. The initial bundle stays
|
|
62
|
+
* scope-hoisted and contributes none.
|
|
63
|
+
* @type {Map<string, { kind: 'esm' | 'cjs', fn: (id: string) => void }>}
|
|
64
|
+
*/
|
|
65
|
+
factories: Map<string, {
|
|
66
|
+
kind: "esm" | "cjs";
|
|
67
|
+
fn: (id: string) => void;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Installed by the dev client at boot. The runtime is a store + executor and makes
|
|
71
|
+
* no HMR decisions; accepting, disposing, and reloading live behind these hooks.
|
|
72
|
+
* @type {DevRuntimeHooks | null}
|
|
73
|
+
*/
|
|
74
|
+
hooks: DevRuntimeHooks | null;
|
|
75
|
+
/**
|
|
76
|
+
* @param {ModuleGraphDelta} delta
|
|
77
|
+
*/
|
|
78
|
+
registerGraph(delta: ModuleGraphDelta): void;
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} id
|
|
81
|
+
* @param {'esm' | 'cjs'} kind
|
|
82
|
+
* @param {(id: string) => void} fn
|
|
83
|
+
*/
|
|
84
|
+
registerFactory(id: string, kind: "esm" | "cjs", fn: (id: string) => void): void;
|
|
85
|
+
/**
|
|
86
|
+
* @param {string} id
|
|
87
|
+
* @param {{ exports: any }} exportsHolder
|
|
88
|
+
*/
|
|
89
|
+
registerModule(id: string, exportsHolder: {
|
|
90
|
+
exports: any;
|
|
91
|
+
}): void;
|
|
92
|
+
/**
|
|
93
|
+
* @param {string} id
|
|
94
|
+
* @returns {string[]}
|
|
95
|
+
*/
|
|
96
|
+
getImporters(id: string): string[];
|
|
97
|
+
/**
|
|
98
|
+
* @param {string} id
|
|
99
|
+
*/
|
|
100
|
+
isExecuted(id: string): any;
|
|
101
|
+
/**
|
|
102
|
+
* @param {string} id
|
|
103
|
+
*/
|
|
104
|
+
hasFactory(id: string): any;
|
|
105
|
+
/**
|
|
106
|
+
* Module-cache delete only — static imports and factories persist. Removal is what
|
|
107
|
+
* re-arms a cache-gated factory for `initModule`.
|
|
108
|
+
* @param {string} id
|
|
109
|
+
*/
|
|
110
|
+
removeModuleCache(id: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* The one re-execution gate: registered → return the live exports; otherwise run the
|
|
113
|
+
* mapped factory (which registers itself first, then runs the body).
|
|
114
|
+
* @param {string} id
|
|
115
|
+
*/
|
|
116
|
+
initModule(id: string): any;
|
|
117
|
+
/**
|
|
118
|
+
* @param {string} id
|
|
119
|
+
*/
|
|
120
|
+
loadExports(id: string): any;
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} moduleId
|
|
123
|
+
*/
|
|
124
|
+
createModuleHotContext(moduleId: string): any;
|
|
125
|
+
/** @internal */
|
|
126
|
+
__toESM: any;
|
|
127
|
+
/** @internal */
|
|
128
|
+
__toCommonJS: any;
|
|
129
|
+
/** @internal */
|
|
130
|
+
__exportAll: any;
|
|
131
|
+
/**
|
|
132
|
+
* @param {boolean} [isNodeMode]
|
|
133
|
+
* @returns {(mod: any) => any}
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
__toDynamicImportESM: (isNodeMode?: boolean) => (mod: any) => any;
|
|
137
|
+
/** @internal */
|
|
138
|
+
__reExport: any;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
|
|
142
|
+
* `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
|
|
143
|
+
* `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
|
|
144
|
+
*/
|
|
145
|
+
export type ModuleGraphDelta = {
|
|
146
|
+
ids: string[];
|
|
147
|
+
localCount: number;
|
|
148
|
+
edges: number[][];
|
|
149
|
+
dynamicEdges?: number[][];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
|
|
153
|
+
* `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
|
|
154
|
+
* `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
|
|
155
|
+
*/
|
|
156
|
+
export type DevRuntimeHooks = {
|
|
157
|
+
createModuleHotContext(moduleId: string): any;
|
|
158
|
+
onModuleCacheRemoval(moduleId: string): void;
|
|
159
|
+
};
|
|
160
|
+
declare class Module {
|
|
161
|
+
/**
|
|
162
|
+
* @param {string} id
|
|
163
|
+
*/
|
|
164
|
+
constructor(id: string);
|
|
165
|
+
/**
|
|
166
|
+
* @type {{ exports: any }}
|
|
167
|
+
*/
|
|
168
|
+
exportsHolder: {
|
|
169
|
+
exports: any;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* @type {string}
|
|
173
|
+
*/
|
|
174
|
+
id: string;
|
|
175
|
+
get exports(): any;
|
|
176
|
+
}
|
|
177
|
+
export {};
|