xbintsc 0.3.15 → 0.3.16
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/dist/src/cli/main.js +4 -4
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/state.js +8 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +8 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/driver/bundler/graph.d.ts +8 -0
- package/dist/src/driver/bundler/graph.js +85 -0
- package/dist/src/driver/bundler/graph.js.map +1 -0
- package/dist/src/driver/bundler/merge.d.ts +11 -0
- package/dist/src/driver/bundler/merge.js +288 -0
- package/dist/src/driver/bundler/merge.js.map +1 -0
- package/dist/src/driver/bundler/resolve.d.ts +12 -0
- package/dist/src/driver/bundler/resolve.js +246 -0
- package/dist/src/driver/bundler/resolve.js.map +1 -0
- package/dist/src/driver/bundler/symbols.d.ts +15 -0
- package/dist/src/driver/bundler/symbols.js +51 -0
- package/dist/src/driver/bundler/symbols.js.map +1 -0
- package/dist/src/driver/bundler/types.d.ts +36 -0
- package/dist/src/driver/bundler/types.js +5 -0
- package/dist/src/driver/bundler/types.js.map +1 -0
- package/dist/src/driver/modules.d.ts +9 -16
- package/dist/src/driver/modules.js +8 -644
- package/dist/src/driver/modules.js.map +1 -1
- package/dist/src/extensions/catalog.js +2 -1
- package/dist/src/extensions/catalog.js.map +1 -1
- package/dist/src/extensions/gui/index.d.ts +24 -0
- package/dist/src/extensions/gui/index.js +101 -0
- package/dist/src/extensions/gui/index.js.map +1 -0
- package/dist/tests/e2e/compile-basics.test.d.ts +4 -0
- package/dist/tests/e2e/compile-basics.test.js +134 -0
- package/dist/tests/e2e/compile-basics.test.js.map +1 -0
- package/dist/tests/e2e/compile-builtins.test.d.ts +4 -0
- package/dist/tests/e2e/compile-builtins.test.js +191 -0
- package/dist/tests/e2e/compile-builtins.test.js.map +1 -0
- package/dist/tests/e2e/compile-control-flow.test.d.ts +4 -0
- package/dist/tests/e2e/compile-control-flow.test.js +190 -0
- package/dist/tests/e2e/compile-control-flow.test.js.map +1 -0
- package/dist/tests/e2e/compile-modules.test.d.ts +4 -0
- package/dist/tests/e2e/compile-modules.test.js +48 -0
- package/dist/tests/e2e/compile-modules.test.js.map +1 -0
- package/dist/tests/e2e/compile-objects-classes.test.d.ts +4 -0
- package/dist/tests/e2e/compile-objects-classes.test.js +362 -0
- package/dist/tests/e2e/compile-objects-classes.test.js.map +1 -0
- package/dist/tests/e2e/differential-helpers.d.ts +12 -0
- package/dist/tests/e2e/differential-helpers.js +16 -0
- package/dist/tests/e2e/differential-helpers.js.map +1 -0
- package/dist/tests/e2e/differential-language.test.d.ts +4 -0
- package/dist/tests/e2e/{differential.test.js → differential-language.test.js} +5 -287
- package/dist/tests/e2e/differential-language.test.js.map +1 -0
- package/dist/tests/e2e/differential-symbols.test.d.ts +4 -0
- package/dist/tests/e2e/differential-symbols.test.js +92 -0
- package/dist/tests/e2e/differential-symbols.test.js.map +1 -0
- package/dist/tests/e2e/differential-values.test.d.ts +4 -0
- package/dist/tests/e2e/differential-values.test.js +197 -0
- package/dist/tests/e2e/differential-values.test.js.map +1 -0
- package/dist/tests/e2e/gui.test.d.ts +12 -0
- package/dist/tests/e2e/gui.test.js +493 -0
- package/dist/tests/e2e/gui.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js +97 -0
- package/dist/tests/e2e/runtime-coverage-buffer.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.js +149 -0
- package/dist/tests/e2e/runtime-coverage-globals.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-node-modules.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-node-modules.test.js +177 -0
- package/dist/tests/e2e/runtime-coverage-node-modules.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-streams.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-streams.test.js +161 -0
- package/dist/tests/e2e/runtime-coverage-streams.test.js.map +1 -0
- package/dist/tests/e2e/runtime-coverage-system.test.d.ts +4 -0
- package/dist/tests/e2e/runtime-coverage-system.test.js +91 -0
- package/dist/tests/e2e/runtime-coverage-system.test.js.map +1 -0
- package/dist/tests/e2e/timers.test.d.ts +7 -0
- package/dist/tests/e2e/timers.test.js +63 -0
- package/dist/tests/e2e/timers.test.js.map +1 -0
- package/package.json +2 -1
- package/runtime/ext_gui/css.cpp +743 -0
- package/runtime/ext_gui/css.h +98 -0
- package/runtime/ext_gui/document.cpp +264 -0
- package/runtime/ext_gui/document.h +89 -0
- package/runtime/ext_gui/dom.cpp +472 -0
- package/runtime/ext_gui/dom.h +71 -0
- package/runtime/ext_gui/gui.cpp +457 -0
- package/runtime/ext_gui/gui_engine.h +81 -0
- package/runtime/ext_gui/image.cpp +125 -0
- package/runtime/ext_gui/image.h +42 -0
- package/runtime/ext_gui/layout.cpp +748 -0
- package/runtime/ext_gui/layout.h +93 -0
- package/runtime/ext_gui/paint.cpp +137 -0
- package/runtime/ext_gui/paint.h +75 -0
- package/runtime/ext_gui/renderer.cpp +959 -0
- package/runtime/ext_gui/renderer.h +68 -0
- package/runtime/ext_gui/stb_image.h +7988 -0
- package/runtime/ext_gui/style.cpp +771 -0
- package/runtime/ext_gui/style.h +117 -0
- package/runtime/ext_gui/text.cpp +378 -0
- package/runtime/ext_gui/text.h +78 -0
- package/runtime/ext_gui/window.cpp +405 -0
- package/runtime/ext_node/fs/fs_common.h +13 -527
- package/runtime/ext_node/fs/parts/buffer-bridge.inc +6 -0
- package/runtime/ext_node/fs/parts/builtins.inc +69 -0
- package/runtime/ext_node/fs/parts/dir.inc +47 -0
- package/runtime/ext_node/fs/parts/encoding.inc +186 -0
- package/runtime/ext_node/fs/parts/errors.inc +66 -0
- package/runtime/ext_node/fs/parts/flags.inc +39 -0
- package/runtime/ext_node/fs/parts/platform.inc +86 -0
- package/runtime/ext_node/fs/parts/promisify.inc +15 -0
- package/runtime/ext_node/fs/parts/time.inc +9 -0
- package/runtime/rt.h +33 -0
- package/runtime/xt_builtins.c +4 -0
- package/runtime/xt_containers/access.inc +168 -0
- package/runtime/xt_containers/arrays.inc +108 -0
- package/runtime/xt_containers/boxes.inc +11 -0
- package/runtime/xt_containers/objects.inc +326 -0
- package/runtime/xt_containers.c +8 -618
- package/runtime/xt_io/base64.inc +87 -0
- package/runtime/xt_io/console.inc +119 -0
- package/runtime/xt_io/exception.inc +142 -0
- package/runtime/xt_io/inspect.inc +212 -0
- package/runtime/xt_io.c +8 -553
- package/runtime/xt_loop.c +262 -24
- package/runtime/xt_regex/api.inc +58 -0
- package/runtime/xt_regex/helpers.inc +68 -0
- package/runtime/xt_regex/matcher.inc +248 -0
- package/runtime/xt_regex/parser.inc +236 -0
- package/runtime/xt_regex/types.inc +58 -0
- package/runtime/xt_regex.h +9 -672
- package/runtime/xt_values/arithmetic.inc +150 -0
- package/runtime/xt_values/comparison.inc +112 -0
- package/runtime/xt_values/constructors.inc +41 -0
- package/runtime/xt_values/conversions.inc +115 -0
- package/runtime/xt_values/number-format.inc +180 -0
- package/runtime/xt_values/strings.inc +22 -0
- package/runtime/xt_values.c +10 -626
- package/scripts/build-gui.ts +317 -0
- package/src/cli/main.ts +4 -3
- package/src/codegen/generator/state.ts +8 -0
- package/src/codegen/generator/tables.ts +8 -0
- package/src/driver/bundler/graph.ts +95 -0
- package/src/driver/bundler/merge.ts +312 -0
- package/src/driver/bundler/resolve.ts +240 -0
- package/src/driver/bundler/symbols.ts +55 -0
- package/src/driver/bundler/types.ts +37 -0
- package/src/driver/modules.ts +9 -693
- package/src/extensions/catalog.ts +2 -1
- package/src/extensions/gui/index.ts +107 -0
- package/dist/tests/e2e/compile.test.d.ts +0 -8
- package/dist/tests/e2e/compile.test.js +0 -893
- package/dist/tests/e2e/compile.test.js.map +0 -1
- package/dist/tests/e2e/differential.test.d.ts +0 -7
- package/dist/tests/e2e/differential.test.js.map +0 -1
- package/dist/tests/e2e/runtime-coverage.test.d.ts +0 -11
- package/dist/tests/e2e/runtime-coverage.test.js +0 -646
- package/dist/tests/e2e/runtime-coverage.test.js.map +0 -1
package/src/driver/modules.ts
CHANGED
|
@@ -6,698 +6,14 @@
|
|
|
6
6
|
* Each module's top-level bindings are renamed to a globally unique name and
|
|
7
7
|
* imported names are rewritten to the (renamed) exported binding.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
17
|
-
import {
|
|
18
|
-
ModifierKind,
|
|
19
|
-
SyntaxKind,
|
|
20
|
-
type ExportAssignment,
|
|
21
|
-
type ExportDeclaration,
|
|
22
|
-
type Identifier,
|
|
23
|
-
type ImportDeclaration,
|
|
24
|
-
type Node,
|
|
25
|
-
type ObjectLiteralExpression,
|
|
26
|
-
type PropertyAssignment,
|
|
27
|
-
type SourceFileNode,
|
|
28
|
-
type Statement,
|
|
29
|
-
type VariableDeclaration,
|
|
30
|
-
type VariableDeclarationList,
|
|
31
|
-
type VariableStatement,
|
|
32
|
-
} from "../ast/nodes.js";
|
|
33
|
-
import { bind, SymbolKind, type BindResult, type SymbolInfo } from "../binder/binder.js";
|
|
34
|
-
import { DiagnosticBag, DiagnosticCode } from "../diagnostics/diagnostic.js";
|
|
35
|
-
import { SourceFile } from "../diagnostics/source.js";
|
|
36
|
-
import { Parser } from "../parser/parser.js";
|
|
37
|
-
|
|
38
|
-
interface ModuleRecord {
|
|
39
|
-
readonly path: string;
|
|
40
|
-
readonly text: string;
|
|
41
|
-
readonly sourceFile: SourceFileNode;
|
|
42
|
-
readonly bind: BindResult;
|
|
43
|
-
readonly prefix: string;
|
|
44
|
-
/** exported name -> final (renamed) local name */
|
|
45
|
-
readonly exports: Map<string, string>;
|
|
46
|
-
/** original local name of every top-level symbol */
|
|
47
|
-
readonly originalNames: Map<number, string>;
|
|
48
|
-
/** final name of every top-level symbol */
|
|
49
|
-
readonly finalNames: Map<number, string>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface BundleResult {
|
|
53
|
-
readonly sourceFile: SourceFileNode;
|
|
54
|
-
readonly text: string;
|
|
55
|
-
readonly moduleCount: number;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Source extensions probed for an extension-less specifier. TypeScript suffixes
|
|
60
|
-
* are tried before their JavaScript counterparts so a project that ships both
|
|
61
|
-
* `foo.ts` and a compiled `foo.js` prefers the source it is compiled from.
|
|
62
|
-
*/
|
|
63
|
-
const RESOLVE_SUFFIXES = ["", ".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
64
|
-
/** File extensions a directory `index` entry may use. */
|
|
65
|
-
const INDEX_SUFFIXES = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
|
|
66
|
-
/** Conditions consulted, in order, when reading a package `exports` map. */
|
|
67
|
-
const EXPORT_CONDITIONS = ["import", "module", "default", "node", "require"];
|
|
68
|
-
|
|
69
|
-
/** A specifier is a file path (`./x`, `../x`, `/x`) rather than a package. */
|
|
70
|
-
function isRelativeSpecifier(specifier: string): boolean {
|
|
71
|
-
return specifier.startsWith(".") || isAbsolute(specifier);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Resolve a path on disk, tolerating TypeScript's `.js` import convention
|
|
76
|
-
* (`import "./foo.js"` pointing at `foo.ts`) and Node's directory/`index`
|
|
77
|
-
* conventions.
|
|
78
|
-
*/
|
|
79
|
-
function resolvePath(base: string): string | undefined {
|
|
80
|
-
// A JavaScript specifier may refer to a TypeScript source that will emit it
|
|
81
|
-
// (`import "./foo.js"` pointing at `foo.ts`). Probe the matching TypeScript
|
|
82
|
-
// extensions after the literal path: `.js`/`.jsx` -> `.ts`/`.tsx`,
|
|
83
|
-
// `.mjs` -> `.mts`, `.cjs` -> `.cts`.
|
|
84
|
-
const candidates = [base];
|
|
85
|
-
const jsExtension = /\.((?:m|c)?jsx?)$/.exec(base);
|
|
86
|
-
if (jsExtension) {
|
|
87
|
-
const stem = base.slice(0, jsExtension.index);
|
|
88
|
-
switch (jsExtension[1]) {
|
|
89
|
-
case "jsx":
|
|
90
|
-
candidates.push(`${stem}.tsx`, `${stem}.ts`);
|
|
91
|
-
break;
|
|
92
|
-
case "mjs":
|
|
93
|
-
candidates.push(`${stem}.mts`);
|
|
94
|
-
break;
|
|
95
|
-
case "cjs":
|
|
96
|
-
candidates.push(`${stem}.cts`);
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
candidates.push(`${stem}.ts`, `${stem}.tsx`);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
for (const candidate of candidates) {
|
|
104
|
-
if (existsSync(candidate) && statSync(candidate).isFile()) return candidate;
|
|
105
|
-
}
|
|
106
|
-
for (const suffix of RESOLVE_SUFFIXES) {
|
|
107
|
-
const candidate = base + suffix;
|
|
108
|
-
if (existsSync(candidate) && statSync(candidate).isFile()) return candidate;
|
|
109
|
-
}
|
|
110
|
-
if (existsSync(base) && statSync(base).isDirectory()) return resolveDirectory(base);
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/** Resolve a directory to its package entry or an `index` file. */
|
|
115
|
-
function resolveDirectory(directory: string): string | undefined {
|
|
116
|
-
const pkg = readPackageJson(directory);
|
|
117
|
-
if (pkg && typeof pkg.main === "string") {
|
|
118
|
-
const main = resolvePath(resolve(directory, pkg.main));
|
|
119
|
-
if (main) return main;
|
|
120
|
-
}
|
|
121
|
-
for (const suffix of INDEX_SUFFIXES) {
|
|
122
|
-
const candidate = join(directory, `index${suffix}`);
|
|
123
|
-
if (existsSync(candidate) && statSync(candidate).isFile()) return candidate;
|
|
124
|
-
}
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function resolveModule(fromDir: string, specifier: string): string | undefined {
|
|
129
|
-
return resolvePath(resolve(fromDir, specifier));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
interface PackageJson {
|
|
133
|
-
readonly main?: string;
|
|
134
|
-
readonly module?: string;
|
|
135
|
-
readonly exports?: unknown;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function readPackageJson(directory: string): PackageJson | undefined {
|
|
139
|
-
const file = join(directory, "package.json");
|
|
140
|
-
if (!existsSync(file) || !statSync(file).isFile()) return undefined;
|
|
141
|
-
try {
|
|
142
|
-
const parsed = JSON.parse(readFileSync(file, "utf8")) as unknown;
|
|
143
|
-
return parsed && typeof parsed === "object" ? (parsed as PackageJson) : undefined;
|
|
144
|
-
} catch {
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** Split `pkg/sub/path` or `@scope/pkg/sub/path` into package name and subpath. */
|
|
150
|
-
function splitPackageSpecifier(specifier: string): { packageName: string; subpath: string } {
|
|
151
|
-
const parts = specifier.split("/");
|
|
152
|
-
if (specifier.startsWith("@")) {
|
|
153
|
-
return { packageName: parts.slice(0, 2).join("/"), subpath: parts.slice(2).join("/") };
|
|
154
|
-
}
|
|
155
|
-
return { packageName: parts[0] ?? specifier, subpath: parts.slice(1).join("/") };
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Resolve a bare specifier against the `node_modules` directories above
|
|
160
|
-
* `fromDir`, following a package's `exports` map and falling back to
|
|
161
|
-
* `module`/`main`/`index`. Packages that only ship CommonJS resolve here too;
|
|
162
|
-
* their `require` calls are then rejected during code generation.
|
|
163
|
-
*/
|
|
164
|
-
function resolveNodePackage(fromDir: string, specifier: string): string | undefined {
|
|
165
|
-
const { packageName, subpath } = splitPackageSpecifier(specifier);
|
|
166
|
-
if (!packageName || packageName.startsWith(".")) return undefined;
|
|
167
|
-
let directory = fromDir;
|
|
168
|
-
for (;;) {
|
|
169
|
-
const packageDir = join(directory, "node_modules", packageName);
|
|
170
|
-
if (existsSync(packageDir) && statSync(packageDir).isDirectory()) {
|
|
171
|
-
const resolved = subpath
|
|
172
|
-
? resolvePackageSubpath(packageDir, subpath)
|
|
173
|
-
: resolvePackageEntry(packageDir);
|
|
174
|
-
if (resolved) return resolved;
|
|
175
|
-
}
|
|
176
|
-
const parent = dirname(directory);
|
|
177
|
-
if (parent === directory) return undefined;
|
|
178
|
-
directory = parent;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function resolvePackageEntry(packageDir: string): string | undefined {
|
|
183
|
-
const pkg = readPackageJson(packageDir);
|
|
184
|
-
if (pkg) {
|
|
185
|
-
const exported = resolveExportTarget(subpathValue(pkg.exports, "."));
|
|
186
|
-
if (exported) {
|
|
187
|
-
const resolved = resolvePath(resolve(packageDir, exported));
|
|
188
|
-
if (resolved) return resolved;
|
|
189
|
-
}
|
|
190
|
-
if (typeof pkg.module === "string") {
|
|
191
|
-
const resolved = resolvePath(resolve(packageDir, pkg.module));
|
|
192
|
-
if (resolved) return resolved;
|
|
193
|
-
}
|
|
194
|
-
if (typeof pkg.main === "string") {
|
|
195
|
-
const resolved = resolvePath(resolve(packageDir, pkg.main));
|
|
196
|
-
if (resolved) return resolved;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return resolveDirectory(packageDir);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function resolvePackageSubpath(packageDir: string, subpath: string): string | undefined {
|
|
203
|
-
const pkg = readPackageJson(packageDir);
|
|
204
|
-
const exported = resolveExportTarget(subpathValue(pkg?.exports, `./${subpath}`));
|
|
205
|
-
if (exported) {
|
|
206
|
-
const resolved = resolvePath(resolve(packageDir, exported));
|
|
207
|
-
if (resolved) return resolved;
|
|
208
|
-
}
|
|
209
|
-
return resolvePath(join(packageDir, subpath));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** Pick the export target for a subpath (`"."` or `"./sub"`) from an exports map. */
|
|
213
|
-
function subpathValue(exportsField: unknown, subpath: string): unknown {
|
|
214
|
-
if (exportsField === undefined) return undefined;
|
|
215
|
-
if (typeof exportsField === "string" || Array.isArray(exportsField)) {
|
|
216
|
-
return subpath === "." ? exportsField : undefined;
|
|
217
|
-
}
|
|
218
|
-
if (!exportsField || typeof exportsField !== "object") return undefined;
|
|
219
|
-
const record = exportsField as Record<string, unknown>;
|
|
220
|
-
const keys = Object.keys(record);
|
|
221
|
-
// A map without `.`-prefixed keys is a condition map for the root export.
|
|
222
|
-
if (!keys.some((key) => key.startsWith("."))) {
|
|
223
|
-
return subpath === "." ? exportsField : undefined;
|
|
224
|
-
}
|
|
225
|
-
if (subpath in record) return record[subpath];
|
|
226
|
-
// Wildcard patterns such as `"./*": "./dist/*.js"`.
|
|
227
|
-
for (const key of keys) {
|
|
228
|
-
const star = key.indexOf("*");
|
|
229
|
-
if (star === -1) continue;
|
|
230
|
-
const prefix = key.slice(0, star);
|
|
231
|
-
const suffix = key.slice(star + 1);
|
|
232
|
-
if (subpath.startsWith(prefix) && subpath.endsWith(suffix)) {
|
|
233
|
-
const matched = subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
234
|
-
return substituteStar(record[key], matched);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return undefined;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function substituteStar(target: unknown, matched: string): unknown {
|
|
241
|
-
if (typeof target === "string") return target.split("*").join(matched);
|
|
242
|
-
if (Array.isArray(target)) return target.map((entry) => substituteStar(entry, matched));
|
|
243
|
-
if (target && typeof target === "object") {
|
|
244
|
-
const record: Record<string, unknown> = {};
|
|
245
|
-
for (const [key, value] of Object.entries(target)) record[key] = substituteStar(value, matched);
|
|
246
|
-
return record;
|
|
247
|
-
}
|
|
248
|
-
return target;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/** Pick a runtime string from a (possibly conditional) exports target. */
|
|
252
|
-
function resolveExportTarget(target: unknown): string | undefined {
|
|
253
|
-
if (typeof target === "string") return target;
|
|
254
|
-
if (Array.isArray(target)) {
|
|
255
|
-
for (const entry of target) {
|
|
256
|
-
const resolved = resolveExportTarget(entry);
|
|
257
|
-
if (resolved) return resolved;
|
|
258
|
-
}
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
if (target && typeof target === "object") {
|
|
262
|
-
const record = target as Record<string, unknown>;
|
|
263
|
-
for (const condition of EXPORT_CONDITIONS) {
|
|
264
|
-
if (condition in record) {
|
|
265
|
-
const resolved = resolveExportTarget(record[condition]);
|
|
266
|
-
if (resolved) return resolved;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return undefined;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
type DependencyResolution =
|
|
274
|
-
| { readonly kind: "external" }
|
|
275
|
-
| { readonly kind: "file"; readonly path: string }
|
|
276
|
-
| { readonly kind: "missing" };
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Classify an import specifier. Known platform modules (extension modules and
|
|
280
|
-
* `node:` builtins) are left for code generation; relative paths and
|
|
281
|
-
* `node_modules` packages are resolved to a source file to bundle; a relative
|
|
282
|
-
* path that does not exist is an error.
|
|
283
|
-
*/
|
|
284
|
-
function classifyDependency(
|
|
285
|
-
fromDir: string,
|
|
286
|
-
specifier: string,
|
|
287
|
-
externalSpecifiers: ReadonlySet<string>,
|
|
288
|
-
): DependencyResolution {
|
|
289
|
-
if (specifier.startsWith("node:") || externalSpecifiers.has(specifier)) {
|
|
290
|
-
return { kind: "external" };
|
|
291
|
-
}
|
|
292
|
-
const resolved = isRelativeSpecifier(specifier)
|
|
293
|
-
? resolveModule(fromDir, specifier)
|
|
294
|
-
: resolveNodePackage(fromDir, specifier);
|
|
295
|
-
if (resolved) return { kind: "file", path: resolved };
|
|
296
|
-
// A bare specifier that is not a file may still be a platform module the
|
|
297
|
-
// generator knows about (e.g. when the caller passes no extension registry).
|
|
298
|
-
return isRelativeSpecifier(specifier) ? { kind: "missing" } : { kind: "external" };
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function hasModifier(node: Node, kind: ModifierKind): boolean {
|
|
302
|
-
const modifiers = (node as { modifiers?: { modifierKind: ModifierKind }[] }).modifiers;
|
|
303
|
-
return !!modifiers && modifiers.some((modifier) => modifier.modifierKind === kind);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function declarationName(node: Node): Identifier | undefined {
|
|
307
|
-
switch (node.kind) {
|
|
308
|
-
case SyntaxKind.FunctionDeclaration:
|
|
309
|
-
case SyntaxKind.ClassDeclaration:
|
|
310
|
-
case SyntaxKind.EnumDeclaration:
|
|
311
|
-
case SyntaxKind.InterfaceDeclaration:
|
|
312
|
-
case SyntaxKind.TypeAliasDeclaration:
|
|
313
|
-
case SyntaxKind.ModuleDeclaration:
|
|
314
|
-
return (node as { name?: Identifier }).name;
|
|
315
|
-
case SyntaxKind.VariableDeclaration: {
|
|
316
|
-
const name = (node as VariableDeclaration).name;
|
|
317
|
-
return name.kind === SyntaxKind.Identifier ? name : undefined;
|
|
318
|
-
}
|
|
319
|
-
default:
|
|
320
|
-
return undefined;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/** Load, parse and bind the entry module and every module it imports. */
|
|
325
|
-
function loadGraph(
|
|
326
|
-
entryPath: string,
|
|
327
|
-
diagnostics: DiagnosticBag,
|
|
328
|
-
externalSpecifiers: ReadonlySet<string>,
|
|
329
|
-
): ModuleRecord[] | undefined {
|
|
330
|
-
const records = new Map<string, ModuleRecord>();
|
|
331
|
-
const order: ModuleRecord[] = [];
|
|
332
|
-
const visiting = new Set<string>();
|
|
333
|
-
let counter = 0;
|
|
334
|
-
let failed = false;
|
|
335
|
-
|
|
336
|
-
const load = (path: string): ModuleRecord | undefined => {
|
|
337
|
-
const existing = records.get(path);
|
|
338
|
-
if (existing) return existing;
|
|
339
|
-
if (visiting.has(path)) {
|
|
340
|
-
diagnostics.error(DiagnosticCode.CodegenError, `Circular import detected involving '${path}'`);
|
|
341
|
-
failed = true;
|
|
342
|
-
return undefined;
|
|
343
|
-
}
|
|
344
|
-
if (!existsSync(path)) {
|
|
345
|
-
diagnostics.error(DiagnosticCode.CodegenError, `Cannot find module '${path}'`);
|
|
346
|
-
failed = true;
|
|
347
|
-
return undefined;
|
|
348
|
-
}
|
|
349
|
-
visiting.add(path);
|
|
350
|
-
const text = readFileSync(path, "utf8");
|
|
351
|
-
const file = new SourceFile(path, text);
|
|
352
|
-
const parser = new Parser(file, diagnostics);
|
|
353
|
-
const sourceFile = parser.parseSourceFile();
|
|
354
|
-
const bindResult = bind(sourceFile);
|
|
355
|
-
const record: ModuleRecord = {
|
|
356
|
-
path,
|
|
357
|
-
text,
|
|
358
|
-
sourceFile,
|
|
359
|
-
bind: bindResult,
|
|
360
|
-
prefix: `m${counter++}_`,
|
|
361
|
-
exports: new Map(),
|
|
362
|
-
originalNames: new Map(),
|
|
363
|
-
finalNames: new Map(),
|
|
364
|
-
};
|
|
365
|
-
records.set(path, record);
|
|
366
|
-
|
|
367
|
-
for (const statement of sourceFile.statements) {
|
|
368
|
-
const specifier = moduleSpecifierOf(statement);
|
|
369
|
-
if (!specifier) continue;
|
|
370
|
-
const dependency = classifyDependency(dirname(path), specifier, externalSpecifiers);
|
|
371
|
-
if (dependency.kind === "external") continue;
|
|
372
|
-
if (dependency.kind === "missing") {
|
|
373
|
-
diagnostics.error(
|
|
374
|
-
DiagnosticCode.CodegenError,
|
|
375
|
-
`Cannot resolve module '${specifier}' from '${path}'`,
|
|
376
|
-
statement,
|
|
377
|
-
path,
|
|
378
|
-
);
|
|
379
|
-
failed = true;
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
load(dependency.path);
|
|
383
|
-
}
|
|
384
|
-
visiting.delete(path);
|
|
385
|
-
order.push(record);
|
|
386
|
-
return record;
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
load(entryPath);
|
|
390
|
-
if (failed) return undefined;
|
|
391
|
-
return order;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function moduleSpecifierOf(statement: Statement): string | undefined {
|
|
395
|
-
if (statement.kind === SyntaxKind.ImportDeclaration) {
|
|
396
|
-
return (statement as ImportDeclaration).moduleSpecifier.value;
|
|
397
|
-
}
|
|
398
|
-
if (statement.kind === SyntaxKind.ExportDeclaration) {
|
|
399
|
-
const specifier = (statement as ExportDeclaration).moduleSpecifier;
|
|
400
|
-
if (specifier) return specifier.value;
|
|
401
|
-
}
|
|
402
|
-
return undefined;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/** Rewrite a symbol's declaration and every reference to `finalName`. */
|
|
406
|
-
function renameSymbol(symbol: SymbolInfo, finalName: string): void {
|
|
407
|
-
for (const declaration of symbol.declarations) {
|
|
408
|
-
const name = declarationName(declaration);
|
|
409
|
-
if (name) (name as { text: string }).text = finalName;
|
|
410
|
-
}
|
|
411
|
-
for (const reference of symbol.references) (reference as { text: string }).text = finalName;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/** Rewrite just the references of a symbol (used for imported names). */
|
|
415
|
-
function renameReferences(symbol: SymbolInfo, finalName: string): void {
|
|
416
|
-
for (const reference of symbol.references) (reference as { text: string }).text = finalName;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function moduleScope(record: ModuleRecord) {
|
|
420
|
-
return record.bind.scopes.get(record.sourceFile);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
function topLevelSymbols(record: ModuleRecord): SymbolInfo[] {
|
|
424
|
-
const scope = moduleScope(record);
|
|
425
|
-
if (!scope) return [];
|
|
426
|
-
return [...scope.symbols.values()];
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Merge every module's statements into a single file. Dependencies come first
|
|
431
|
-
* (post-order over the import graph), the entry module last.
|
|
9
|
+
* The implementation lives under `bundler/` split by concern:
|
|
10
|
+
* resolve.ts specifier/path/package resolution
|
|
11
|
+
* graph.ts import-graph loading (parse + bind)
|
|
12
|
+
* symbols.ts top-level symbol renaming
|
|
13
|
+
* merge.ts the bundling passes themselves
|
|
14
|
+
*
|
|
15
|
+
* This file remains the public entry point for the driver and tests.
|
|
432
16
|
*/
|
|
433
|
-
export function bundleModules(
|
|
434
|
-
entryPath: string,
|
|
435
|
-
diagnostics: DiagnosticBag,
|
|
436
|
-
externalSpecifiers: ReadonlySet<string> = new Set(),
|
|
437
|
-
): BundleResult | undefined {
|
|
438
|
-
const records = loadGraph(entryPath, diagnostics, externalSpecifiers);
|
|
439
|
-
if (!records) return undefined;
|
|
440
|
-
|
|
441
|
-
const byPath = new Map(records.map((record) => [record.path, record]));
|
|
442
|
-
const dependencyOf = (record: ModuleRecord, specifier: string): ModuleRecord | undefined => {
|
|
443
|
-
const resolution = classifyDependency(dirname(record.path), specifier, externalSpecifiers);
|
|
444
|
-
return resolution.kind === "file" ? byPath.get(resolution.path) : undefined;
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
// Phase 1: record every top-level binding and pick a unique final name.
|
|
448
|
-
for (const record of records) {
|
|
449
|
-
for (const symbol of topLevelSymbols(record)) {
|
|
450
|
-
record.originalNames.set(symbol.id, symbol.name);
|
|
451
|
-
if (symbol.kind === SymbolKind.Import) continue;
|
|
452
|
-
record.finalNames.set(symbol.id, record.prefix + symbol.name);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// Phase 2: collect each module's exported names.
|
|
457
|
-
for (const record of records) {
|
|
458
|
-
const scope = moduleScope(record);
|
|
459
|
-
if (!scope) continue;
|
|
460
|
-
const symbolByName = scope.symbols;
|
|
461
|
-
for (const statement of record.sourceFile.statements) {
|
|
462
|
-
if (statement.kind === SyntaxKind.ExportDeclaration) {
|
|
463
|
-
const declaration = statement as ExportDeclaration;
|
|
464
|
-
if (declaration.exportClause && declaration.exportClause.kind === SyntaxKind.NamedExports) {
|
|
465
|
-
for (const specifier of declaration.exportClause.elements) {
|
|
466
|
-
const localName = specifier.propertyName?.text ?? specifier.name.text;
|
|
467
|
-
const exportedName = specifier.name.text;
|
|
468
|
-
if (declaration.moduleSpecifier) {
|
|
469
|
-
const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
|
|
470
|
-
const target = dependency?.exports.get(localName);
|
|
471
|
-
if (target) record.exports.set(exportedName, target);
|
|
472
|
-
} else {
|
|
473
|
-
const symbol = symbolByName.get(localName);
|
|
474
|
-
if (symbol) {
|
|
475
|
-
const finalName = record.finalNames.get(symbol.id) ?? symbol.name;
|
|
476
|
-
record.exports.set(exportedName, finalName);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
} else if (!declaration.exportClause && declaration.moduleSpecifier) {
|
|
481
|
-
// `export * from "..."`: copy every re-exported name.
|
|
482
|
-
const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
|
|
483
|
-
if (dependency) for (const [name, value] of dependency.exports) record.exports.set(name, value);
|
|
484
|
-
}
|
|
485
|
-
continue;
|
|
486
|
-
}
|
|
487
|
-
if (statement.kind === SyntaxKind.ExportAssignment) {
|
|
488
|
-
record.exports.set("default", `${record.prefix}default`);
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
if (hasModifier(statement, ModifierKind.Default)) {
|
|
492
|
-
const name = declarationName(statement) ?? declarationName((statement as { declaration?: Node }).declaration ?? statement);
|
|
493
|
-
if (name) {
|
|
494
|
-
const symbol = symbolByName.get(name.text);
|
|
495
|
-
if (symbol) record.exports.set("default", record.finalNames.get(symbol.id) ?? symbol.name);
|
|
496
|
-
}
|
|
497
|
-
continue;
|
|
498
|
-
}
|
|
499
|
-
if (hasModifier(statement, ModifierKind.Export)) {
|
|
500
|
-
const names = exportedNames(statement);
|
|
501
|
-
for (const name of names) {
|
|
502
|
-
const symbol = symbolByName.get(name);
|
|
503
|
-
if (symbol) record.exports.set(name, record.finalNames.get(symbol.id) ?? symbol.name);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// Phase 3: rewrite imported names and record re-exports. Namespace imports
|
|
510
|
-
// are lowered to a synthetic object literal holding every export, built
|
|
511
|
-
// from the dependency's (already renamed) final names.
|
|
512
|
-
const namespaceStatements = new Map<Statement, Statement>();
|
|
513
|
-
for (const record of records) {
|
|
514
|
-
const scope = moduleScope(record);
|
|
515
|
-
if (!scope) continue;
|
|
516
|
-
for (const statement of record.sourceFile.statements) {
|
|
517
|
-
if (statement.kind !== SyntaxKind.ImportDeclaration) continue;
|
|
518
|
-
const declaration = statement as ImportDeclaration;
|
|
519
|
-
const dependency = dependencyOf(record, declaration.moduleSpecifier.value);
|
|
520
|
-
const clause = declaration.importClause;
|
|
521
|
-
if (!clause || !dependency) continue;
|
|
522
|
-
if (clause.name) {
|
|
523
|
-
const target = dependency.exports.get("default") ?? dependency.exports.get("default");
|
|
524
|
-
const local = scope.symbols.get(clause.name.text);
|
|
525
|
-
if (target && local) renameReferences(local, target);
|
|
526
|
-
}
|
|
527
|
-
const bindings = clause.namedBindings;
|
|
528
|
-
if (bindings && bindings.kind === SyntaxKind.NamedImports) {
|
|
529
|
-
for (const specifier of bindings.elements) {
|
|
530
|
-
const importedName = specifier.propertyName?.text ?? specifier.name.text;
|
|
531
|
-
const target = dependency.exports.get(importedName);
|
|
532
|
-
const local = scope.symbols.get(specifier.name.text);
|
|
533
|
-
if (target && local) renameReferences(local, target);
|
|
534
|
-
}
|
|
535
|
-
} else if (bindings && bindings.kind === SyntaxKind.NamespaceImport) {
|
|
536
|
-
const local = scope.symbols.get(bindings.name.text);
|
|
537
|
-
const finalName = `${record.prefix}${bindings.name.text}`;
|
|
538
|
-
if (local) renameReferences(local, finalName);
|
|
539
|
-
namespaceStatements.set(statement, namespaceImportToStatement(statement, finalName, dependency));
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Phase 4: concatenate statements, dropping imports and pure export wrappers.
|
|
545
|
-
const merged: Statement[] = [];
|
|
546
|
-
const first = records[records.length - 1]!;
|
|
547
|
-
for (const record of records) {
|
|
548
|
-
for (const statement of record.sourceFile.statements) {
|
|
549
|
-
if (statement.kind === SyntaxKind.ImportDeclaration) {
|
|
550
|
-
// External (extension / built-in) imports stay in place for codegen.
|
|
551
|
-
const declaration = statement as ImportDeclaration;
|
|
552
|
-
const resolution = classifyDependency(
|
|
553
|
-
dirname(record.path),
|
|
554
|
-
declaration.moduleSpecifier.value,
|
|
555
|
-
externalSpecifiers,
|
|
556
|
-
);
|
|
557
|
-
if (resolution.kind === "external") {
|
|
558
|
-
merged.push(statement);
|
|
559
|
-
} else {
|
|
560
|
-
const synthetic = namespaceStatements.get(statement);
|
|
561
|
-
if (synthetic) merged.push(synthetic);
|
|
562
|
-
}
|
|
563
|
-
continue;
|
|
564
|
-
}
|
|
565
|
-
if (statement.kind === SyntaxKind.ExportDeclaration) {
|
|
566
|
-
const declaration = statement as ExportDeclaration;
|
|
567
|
-
const inner = (declaration as unknown as { declaration?: Statement }).declaration;
|
|
568
|
-
if (inner) merged.push(inner);
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
if (statement.kind === SyntaxKind.ExportAssignment) {
|
|
572
|
-
const assignment = statement as ExportAssignment;
|
|
573
|
-
merged.push(exportAssignmentToStatement(record, assignment));
|
|
574
|
-
continue;
|
|
575
|
-
}
|
|
576
|
-
merged.push(statement);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
// Phase 5: rename every top-level binding (declaration + references) to its
|
|
581
|
-
// unique final name, now that import references have been rewritten.
|
|
582
|
-
for (const record of records) {
|
|
583
|
-
for (const symbol of topLevelSymbols(record)) {
|
|
584
|
-
if (symbol.kind === SymbolKind.Import) continue;
|
|
585
|
-
const finalName = record.finalNames.get(symbol.id);
|
|
586
|
-
if (finalName) renameSymbol(symbol, finalName);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const sourceFile: SourceFileNode = {
|
|
591
|
-
kind: SyntaxKind.SourceFile,
|
|
592
|
-
statements: merged,
|
|
593
|
-
fileName: first.path,
|
|
594
|
-
text: records.map((record) => record.text).join("\n"),
|
|
595
|
-
start: 0,
|
|
596
|
-
end: 0,
|
|
597
|
-
};
|
|
598
|
-
return { sourceFile, text: sourceFile.text, moduleCount: records.length };
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function exportedNames(statement: Statement): string[] {
|
|
602
|
-
const names: string[] = [];
|
|
603
|
-
if (statement.kind === SyntaxKind.VariableStatement) {
|
|
604
|
-
for (const declaration of (statement as VariableStatement).declarationList.declarations) {
|
|
605
|
-
collectBindingIdentifiers(declaration.name, names);
|
|
606
|
-
}
|
|
607
|
-
} else {
|
|
608
|
-
const name = declarationName(statement);
|
|
609
|
-
if (name) names.push(name.text);
|
|
610
|
-
}
|
|
611
|
-
return names;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
function collectBindingIdentifiers(name: import("../ast/declarations.js").BindingName, out: string[]): void {
|
|
615
|
-
if (name.kind === SyntaxKind.Identifier) {
|
|
616
|
-
out.push(name.text);
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
const elements = name.kind === SyntaxKind.ArrayBindingPattern ? name.elements : name.elements;
|
|
620
|
-
for (const element of elements) {
|
|
621
|
-
if (element) collectBindingIdentifiers(element.name, out);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
/** Lower `import * as ns from "./mod"` to `const m0_ns = { ...exports }`. */
|
|
626
|
-
function namespaceImportToStatement(
|
|
627
|
-
statement: Statement,
|
|
628
|
-
finalName: string,
|
|
629
|
-
dependency: ModuleRecord,
|
|
630
|
-
): Statement {
|
|
631
|
-
const properties: PropertyAssignment[] = [];
|
|
632
|
-
for (const [exportedName, target] of dependency.exports) {
|
|
633
|
-
properties.push({
|
|
634
|
-
kind: SyntaxKind.PropertyAssignment,
|
|
635
|
-
name: { kind: SyntaxKind.Identifier, text: exportedName, start: statement.start, end: statement.start },
|
|
636
|
-
initializer: { kind: SyntaxKind.Identifier, text: target, start: statement.start, end: statement.start },
|
|
637
|
-
start: statement.start,
|
|
638
|
-
end: statement.start,
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
const initializer: ObjectLiteralExpression = {
|
|
642
|
-
kind: SyntaxKind.ObjectLiteralExpression,
|
|
643
|
-
properties,
|
|
644
|
-
start: statement.start,
|
|
645
|
-
end: statement.end,
|
|
646
|
-
};
|
|
647
|
-
const declaration: VariableDeclaration = {
|
|
648
|
-
kind: SyntaxKind.VariableDeclaration,
|
|
649
|
-
name: { kind: SyntaxKind.Identifier, text: finalName, start: statement.start, end: statement.start },
|
|
650
|
-
exclamation: false,
|
|
651
|
-
initializer,
|
|
652
|
-
start: statement.start,
|
|
653
|
-
end: statement.end,
|
|
654
|
-
};
|
|
655
|
-
const list: VariableDeclarationList = {
|
|
656
|
-
kind: SyntaxKind.VariableDeclarationList,
|
|
657
|
-
declarationKind: "const" as const,
|
|
658
|
-
declarations: [declaration],
|
|
659
|
-
start: statement.start,
|
|
660
|
-
end: statement.end,
|
|
661
|
-
};
|
|
662
|
-
return {
|
|
663
|
-
kind: SyntaxKind.VariableStatement,
|
|
664
|
-
declarationList: list,
|
|
665
|
-
modifiers: [],
|
|
666
|
-
start: statement.start,
|
|
667
|
-
end: statement.end,
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
17
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const name: Identifier = {
|
|
674
|
-
kind: SyntaxKind.Identifier,
|
|
675
|
-
text: `${record.prefix}default`,
|
|
676
|
-
start: assignment.start,
|
|
677
|
-
end: assignment.start,
|
|
678
|
-
};
|
|
679
|
-
record.exports.set("default", name.text);
|
|
680
|
-
const declaration: VariableDeclaration = {
|
|
681
|
-
kind: SyntaxKind.VariableDeclaration,
|
|
682
|
-
name,
|
|
683
|
-
exclamation: false,
|
|
684
|
-
initializer: assignment.expression,
|
|
685
|
-
start: assignment.start,
|
|
686
|
-
end: assignment.end,
|
|
687
|
-
};
|
|
688
|
-
const list: VariableDeclarationList = {
|
|
689
|
-
kind: SyntaxKind.VariableDeclarationList,
|
|
690
|
-
declarationKind: "const" as const,
|
|
691
|
-
declarations: [declaration],
|
|
692
|
-
start: assignment.start,
|
|
693
|
-
end: assignment.end,
|
|
694
|
-
};
|
|
695
|
-
const statement: VariableStatement = {
|
|
696
|
-
kind: SyntaxKind.VariableStatement,
|
|
697
|
-
declarationList: list,
|
|
698
|
-
modifiers: [],
|
|
699
|
-
start: assignment.start,
|
|
700
|
-
end: assignment.end,
|
|
701
|
-
};
|
|
702
|
-
return statement;
|
|
703
|
-
}
|
|
18
|
+
export { bundleModules } from "./bundler/merge.js";
|
|
19
|
+
export type { BundleResult } from "./bundler/types.js";
|