@rollipop/rolldown 0.0.0-beta.0
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/LICENSE +25 -0
- package/README.md +11 -0
- package/bin/cli.mjs +3 -0
- package/dist/cli-setup.d.mts +1 -0
- package/dist/cli-setup.mjs +17 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1581 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +14 -0
- package/dist/experimental-index.d.mts +239 -0
- package/dist/experimental-index.mjs +299 -0
- package/dist/experimental-runtime-types.d.ts +92 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +369 -0
- package/dist/get-log-filter.d.mts +7 -0
- package/dist/get-log-filter.mjs +48 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +38 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/parallel-plugin-worker.mjs +32 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/parallel-plugin.mjs +7 -0
- package/dist/parse-ast-index.d.mts +8 -0
- package/dist/parse-ast-index.mjs +4 -0
- package/dist/plugins-index.d.mts +31 -0
- package/dist/plugins-index.mjs +40 -0
- package/dist/shared/binding-DmMMxMk0.mjs +584 -0
- package/dist/shared/binding-kAegJ1Bj.d.mts +1775 -0
- package/dist/shared/bindingify-input-options-D0BAGfk2.mjs +1622 -0
- package/dist/shared/constructors-F44lhsH3.d.mts +30 -0
- package/dist/shared/constructors-Rl_oLd2F.mjs +67 -0
- package/dist/shared/define-config-BF4P-Pum.mjs +7 -0
- package/dist/shared/define-config-DJ1-iIdx.d.mts +2562 -0
- package/dist/shared/load-config-BEpugZky.mjs +114 -0
- package/dist/shared/logging-DsnCZi19.d.mts +42 -0
- package/dist/shared/logs-cyjC0SDv.mjs +183 -0
- package/dist/shared/misc-DpjTMcQQ.mjs +22 -0
- package/dist/shared/normalize-string-or-regex-DbTZ9prS.mjs +670 -0
- package/dist/shared/parse-ast-index-BuuhACPk.mjs +99 -0
- package/dist/shared/prompt-5sWCM0jm.mjs +847 -0
- package/dist/shared/rolldown-build-viDZfkdI.mjs +2292 -0
- package/dist/shared/rolldown-il0-nWH9.mjs +11 -0
- package/dist/shared/watch-BSdMzY6q.mjs +352 -0
- package/package.json +128 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-DmMMxMk0.mjs";
|
|
2
|
+
import { l as locate, n as error, s as logParseError, t as augmentCodeLocation, u as getCodeFrame } from "./logs-cyjC0SDv.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.108.0/node_modules/oxc-parser/src-js/wrap.js
|
|
5
|
+
function wrap$1(result) {
|
|
6
|
+
let program, module, comments, errors;
|
|
7
|
+
return {
|
|
8
|
+
get program() {
|
|
9
|
+
if (!program) program = jsonParseAst(result.program);
|
|
10
|
+
return program;
|
|
11
|
+
},
|
|
12
|
+
get module() {
|
|
13
|
+
if (!module) module = result.module;
|
|
14
|
+
return module;
|
|
15
|
+
},
|
|
16
|
+
get comments() {
|
|
17
|
+
if (!comments) comments = result.comments;
|
|
18
|
+
return comments;
|
|
19
|
+
},
|
|
20
|
+
get errors() {
|
|
21
|
+
if (!errors) errors = result.errors;
|
|
22
|
+
return errors;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function jsonParseAst(programJson) {
|
|
27
|
+
const { node: program, fixes } = JSON.parse(programJson);
|
|
28
|
+
for (const fixPath of fixes) applyFix(program, fixPath);
|
|
29
|
+
return program;
|
|
30
|
+
}
|
|
31
|
+
function applyFix(program, fixPath) {
|
|
32
|
+
let node = program;
|
|
33
|
+
for (const key of fixPath) node = node[key];
|
|
34
|
+
if (node.bigint) node.value = BigInt(node.bigint);
|
|
35
|
+
else try {
|
|
36
|
+
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/utils/parse.ts
|
|
42
|
+
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
43
|
+
/**
|
|
44
|
+
* Parse asynchronously.
|
|
45
|
+
*
|
|
46
|
+
* Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
|
|
47
|
+
*/
|
|
48
|
+
async function parse(filename, sourceText, options) {
|
|
49
|
+
return wrap$1(await (0, import_binding.parse)(filename, sourceText, options));
|
|
50
|
+
}
|
|
51
|
+
/** Parse synchronously. */
|
|
52
|
+
function parseSync(filename, sourceText, options) {
|
|
53
|
+
return wrap$1((0, import_binding.parseSync)(filename, sourceText, options));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/parse-ast-index.ts
|
|
58
|
+
function wrap(result, filename, sourceText) {
|
|
59
|
+
if (result.errors.length > 0) return normalizeParseError(filename, sourceText, result.errors);
|
|
60
|
+
return result.program;
|
|
61
|
+
}
|
|
62
|
+
function normalizeParseError(filename, sourceText, errors) {
|
|
63
|
+
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
|
|
64
|
+
const pos = errors[0]?.labels?.[0]?.start;
|
|
65
|
+
for (let i = 0; i < errors.length; i++) {
|
|
66
|
+
if (i >= 5) {
|
|
67
|
+
message += "\n...";
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
const e = errors[i];
|
|
71
|
+
message += e.message + "\n" + e.labels.map((label) => {
|
|
72
|
+
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
73
|
+
if (!location) return;
|
|
74
|
+
return getCodeFrame(sourceText, location.line, location.column);
|
|
75
|
+
}).filter(Boolean).join("\n");
|
|
76
|
+
}
|
|
77
|
+
const log = logParseError(message, filename, pos);
|
|
78
|
+
if (pos !== void 0 && filename) augmentCodeLocation(log, pos, sourceText, filename);
|
|
79
|
+
return error(log);
|
|
80
|
+
}
|
|
81
|
+
const defaultParserOptions = {
|
|
82
|
+
lang: "js",
|
|
83
|
+
preserveParens: false
|
|
84
|
+
};
|
|
85
|
+
function parseAst(sourceText, options, filename) {
|
|
86
|
+
return wrap(parseSync(filename ?? "file.js", sourceText, {
|
|
87
|
+
...defaultParserOptions,
|
|
88
|
+
...options
|
|
89
|
+
}), filename, sourceText);
|
|
90
|
+
}
|
|
91
|
+
async function parseAstAsync(sourceText, options, filename) {
|
|
92
|
+
return wrap(await parse(filename ?? "file.js", sourceText, {
|
|
93
|
+
...defaultParserOptions,
|
|
94
|
+
...options
|
|
95
|
+
}), filename, sourceText);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { parseSync as i, parseAstAsync as n, parse as r, parseAst as t };
|