@rollipop/rolldown 0.0.0-beta.0 → 0.0.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/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/README.md +1 -11
- package/package.json +2 -126
- package/LICENSE +0 -25
- package/bin/cli.mjs +0 -3
- package/dist/cli-setup.d.mts +0 -1
- package/dist/cli-setup.mjs +0 -17
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -1581
- package/dist/config.d.mts +0 -10
- package/dist/config.mjs +0 -14
- package/dist/experimental-index.d.mts +0 -239
- package/dist/experimental-index.mjs +0 -299
- package/dist/experimental-runtime-types.d.ts +0 -92
- package/dist/filter-index.d.mts +0 -4
- package/dist/filter-index.mjs +0 -369
- package/dist/get-log-filter.d.mts +0 -7
- package/dist/get-log-filter.mjs +0 -48
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +0 -38
- package/dist/parallel-plugin-worker.d.mts +0 -1
- package/dist/parallel-plugin-worker.mjs +0 -32
- package/dist/parallel-plugin.d.mts +0 -14
- package/dist/parallel-plugin.mjs +0 -7
- package/dist/parse-ast-index.d.mts +0 -8
- package/dist/parse-ast-index.mjs +0 -4
- package/dist/plugins-index.d.mts +0 -31
- package/dist/plugins-index.mjs +0 -40
- package/dist/shared/binding-DmMMxMk0.mjs +0 -584
- package/dist/shared/binding-kAegJ1Bj.d.mts +0 -1775
- package/dist/shared/bindingify-input-options-D0BAGfk2.mjs +0 -1622
- package/dist/shared/constructors-F44lhsH3.d.mts +0 -30
- package/dist/shared/constructors-Rl_oLd2F.mjs +0 -67
- package/dist/shared/define-config-BF4P-Pum.mjs +0 -7
- package/dist/shared/define-config-DJ1-iIdx.d.mts +0 -2562
- package/dist/shared/load-config-BEpugZky.mjs +0 -114
- package/dist/shared/logging-DsnCZi19.d.mts +0 -42
- package/dist/shared/logs-cyjC0SDv.mjs +0 -183
- package/dist/shared/misc-DpjTMcQQ.mjs +0 -22
- package/dist/shared/normalize-string-or-regex-DbTZ9prS.mjs +0 -670
- package/dist/shared/parse-ast-index-BuuhACPk.mjs +0 -99
- package/dist/shared/prompt-5sWCM0jm.mjs +0 -847
- package/dist/shared/rolldown-build-viDZfkdI.mjs +0 -2292
- package/dist/shared/rolldown-il0-nWH9.mjs +0 -11
- package/dist/shared/watch-BSdMzY6q.mjs +0 -352
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { t as rolldown } from "./rolldown-il0-nWH9.mjs";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { readdir } from "node:fs/promises";
|
|
5
|
-
import { pathToFileURL } from "node:url";
|
|
6
|
-
import { cwd } from "node:process";
|
|
7
|
-
|
|
8
|
-
//#region src/utils/load-config.ts
|
|
9
|
-
async function bundleTsConfig(configFile, isEsm) {
|
|
10
|
-
const dirnameVarName = "injected_original_dirname";
|
|
11
|
-
const filenameVarName = "injected_original_filename";
|
|
12
|
-
const importMetaUrlVarName = "injected_original_import_meta_url";
|
|
13
|
-
const bundle = await rolldown({
|
|
14
|
-
input: configFile,
|
|
15
|
-
platform: "node",
|
|
16
|
-
resolve: { mainFields: ["main"] },
|
|
17
|
-
transform: { define: {
|
|
18
|
-
__dirname: dirnameVarName,
|
|
19
|
-
__filename: filenameVarName,
|
|
20
|
-
"import.meta.url": importMetaUrlVarName,
|
|
21
|
-
"import.meta.dirname": dirnameVarName,
|
|
22
|
-
"import.meta.filename": filenameVarName
|
|
23
|
-
} },
|
|
24
|
-
treeshake: false,
|
|
25
|
-
external: [/^[\w@][^:]/],
|
|
26
|
-
plugins: [{
|
|
27
|
-
name: "inject-file-scope-variables",
|
|
28
|
-
transform: {
|
|
29
|
-
filter: { id: /\.[cm]?[jt]s$/ },
|
|
30
|
-
async handler(code, id) {
|
|
31
|
-
return {
|
|
32
|
-
code: `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};` + code,
|
|
33
|
-
map: null
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}]
|
|
38
|
-
});
|
|
39
|
-
const outputDir = path.dirname(configFile);
|
|
40
|
-
const fileName = (await bundle.write({
|
|
41
|
-
dir: outputDir,
|
|
42
|
-
format: isEsm ? "esm" : "cjs",
|
|
43
|
-
sourcemap: "inline",
|
|
44
|
-
entryFileNames: `rolldown.config.[hash]${path.extname(configFile).replace("ts", "js")}`
|
|
45
|
-
})).output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
|
|
46
|
-
return path.join(outputDir, fileName);
|
|
47
|
-
}
|
|
48
|
-
const SUPPORTED_JS_CONFIG_FORMATS = [
|
|
49
|
-
".js",
|
|
50
|
-
".mjs",
|
|
51
|
-
".cjs"
|
|
52
|
-
];
|
|
53
|
-
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
54
|
-
".ts",
|
|
55
|
-
".mts",
|
|
56
|
-
".cts"
|
|
57
|
-
];
|
|
58
|
-
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
59
|
-
const DEFAULT_CONFIG_BASE = "rolldown.config";
|
|
60
|
-
async function findConfigFileNameInCwd() {
|
|
61
|
-
const filesInWorkingDirectory = new Set(await readdir(cwd()));
|
|
62
|
-
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
63
|
-
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
|
|
64
|
-
if (filesInWorkingDirectory.has(fileName)) return fileName;
|
|
65
|
-
}
|
|
66
|
-
throw new Error("No `rolldown.config` configuration file found.");
|
|
67
|
-
}
|
|
68
|
-
async function loadTsConfig(configFile) {
|
|
69
|
-
const file = await bundleTsConfig(configFile, isFilePathESM(configFile));
|
|
70
|
-
try {
|
|
71
|
-
return (await import(pathToFileURL(file).href)).default;
|
|
72
|
-
} finally {
|
|
73
|
-
fs.unlink(file, () => {});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function isFilePathESM(filePath) {
|
|
77
|
-
if (/\.m[jt]s$/.test(filePath)) return true;
|
|
78
|
-
else if (/\.c[jt]s$/.test(filePath)) return false;
|
|
79
|
-
else {
|
|
80
|
-
const pkg = findNearestPackageData(path.dirname(filePath));
|
|
81
|
-
if (pkg) return pkg.type === "module";
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function findNearestPackageData(basedir) {
|
|
86
|
-
while (basedir) {
|
|
87
|
-
const pkgPath = path.join(basedir, "package.json");
|
|
88
|
-
if (tryStatSync(pkgPath)?.isFile()) try {
|
|
89
|
-
return JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
90
|
-
} catch {}
|
|
91
|
-
const nextBasedir = path.dirname(basedir);
|
|
92
|
-
if (nextBasedir === basedir) break;
|
|
93
|
-
basedir = nextBasedir;
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
function tryStatSync(file) {
|
|
98
|
-
try {
|
|
99
|
-
return fs.statSync(file, { throwIfNoEntry: false });
|
|
100
|
-
} catch {}
|
|
101
|
-
}
|
|
102
|
-
async function loadConfig(configPath) {
|
|
103
|
-
const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
|
|
104
|
-
try {
|
|
105
|
-
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
|
|
106
|
-
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(path.resolve(configPath));
|
|
107
|
-
else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
108
|
-
} catch (err) {
|
|
109
|
-
throw new Error("Error happened while loading config.", { cause: err });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
//#endregion
|
|
114
|
-
export { loadConfig as t };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region src/log/logging.d.ts
|
|
2
|
-
/** @inline */
|
|
3
|
-
type LogLevel = "info" | "debug" | "warn";
|
|
4
|
-
/** @inline */
|
|
5
|
-
type LogLevelOption = LogLevel | "silent";
|
|
6
|
-
/** @inline */
|
|
7
|
-
type LogLevelWithError = LogLevel | "error";
|
|
8
|
-
interface RollupLog {
|
|
9
|
-
binding?: string;
|
|
10
|
-
cause?: unknown;
|
|
11
|
-
code?: string;
|
|
12
|
-
exporter?: string;
|
|
13
|
-
frame?: string;
|
|
14
|
-
hook?: string;
|
|
15
|
-
id?: string;
|
|
16
|
-
ids?: string[];
|
|
17
|
-
loc?: {
|
|
18
|
-
column: number;
|
|
19
|
-
file?: string;
|
|
20
|
-
line: number;
|
|
21
|
-
};
|
|
22
|
-
message: string;
|
|
23
|
-
meta?: any;
|
|
24
|
-
names?: string[];
|
|
25
|
-
plugin?: string;
|
|
26
|
-
pluginCode?: unknown;
|
|
27
|
-
pos?: number;
|
|
28
|
-
reexporter?: string;
|
|
29
|
-
stack?: string;
|
|
30
|
-
url?: string;
|
|
31
|
-
}
|
|
32
|
-
/** @inline */
|
|
33
|
-
type RollupLogWithString = RollupLog | string;
|
|
34
|
-
/** @category Plugin APIs */
|
|
35
|
-
interface RollupError extends RollupLog {
|
|
36
|
-
name?: string;
|
|
37
|
-
stack?: string;
|
|
38
|
-
watchFiles?: string[];
|
|
39
|
-
}
|
|
40
|
-
type LogOrStringHandler = (level: LogLevelWithError, log: RollupLogWithString) => void;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { RollupLog as a, RollupError as i, LogLevelOption as n, RollupLogWithString as o, LogOrStringHandler as r, LogLevel as t };
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
//#region src/utils/code-frame.ts
|
|
2
|
-
function spaces(index) {
|
|
3
|
-
let result = "";
|
|
4
|
-
while (index--) result += " ";
|
|
5
|
-
return result;
|
|
6
|
-
}
|
|
7
|
-
function tabsToSpaces(value) {
|
|
8
|
-
return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
|
|
9
|
-
}
|
|
10
|
-
const LINE_TRUNCATE_LENGTH = 120;
|
|
11
|
-
const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
12
|
-
const ELLIPSIS = "...";
|
|
13
|
-
function getCodeFrame(source, line, column) {
|
|
14
|
-
let lines = source.split("\n");
|
|
15
|
-
if (line > lines.length) return "";
|
|
16
|
-
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
|
|
17
|
-
const frameStart = Math.max(0, line - 3);
|
|
18
|
-
let frameEnd = Math.min(line + 2, lines.length);
|
|
19
|
-
lines = lines.slice(frameStart, frameEnd);
|
|
20
|
-
while (!/\S/.test(lines[lines.length - 1])) {
|
|
21
|
-
lines.pop();
|
|
22
|
-
frameEnd -= 1;
|
|
23
|
-
}
|
|
24
|
-
const digits = String(frameEnd).length;
|
|
25
|
-
return lines.map((sourceLine, index) => {
|
|
26
|
-
const isErrorLine = frameStart + index + 1 === line;
|
|
27
|
-
let lineNumber = String(index + frameStart + 1);
|
|
28
|
-
while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
|
|
29
|
-
let displayedLine = tabsToSpaces(sourceLine);
|
|
30
|
-
if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
|
|
31
|
-
if (isErrorLine) {
|
|
32
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
|
|
33
|
-
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
34
|
-
}
|
|
35
|
-
return `${lineNumber}: ${displayedLine}`;
|
|
36
|
-
}).join("\n");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/log/locate-character/index.js
|
|
41
|
-
/** @typedef {import('./types').Location} Location */
|
|
42
|
-
/**
|
|
43
|
-
* @param {import('./types').Range} range
|
|
44
|
-
* @param {number} index
|
|
45
|
-
*/
|
|
46
|
-
function rangeContains(range, index) {
|
|
47
|
-
return range.start <= index && index < range.end;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* @param {string} source
|
|
51
|
-
* @param {import('./types').Options} [options]
|
|
52
|
-
*/
|
|
53
|
-
function getLocator(source, options = {}) {
|
|
54
|
-
const { offsetLine = 0, offsetColumn = 0 } = options;
|
|
55
|
-
let start = 0;
|
|
56
|
-
const ranges = source.split("\n").map((line, i$1) => {
|
|
57
|
-
const end = start + line.length + 1;
|
|
58
|
-
/** @type {import('./types').Range} */
|
|
59
|
-
const range = {
|
|
60
|
-
start,
|
|
61
|
-
end,
|
|
62
|
-
line: i$1
|
|
63
|
-
};
|
|
64
|
-
start = end;
|
|
65
|
-
return range;
|
|
66
|
-
});
|
|
67
|
-
let i = 0;
|
|
68
|
-
/**
|
|
69
|
-
* @param {string | number} search
|
|
70
|
-
* @param {number} [index]
|
|
71
|
-
* @returns {Location | undefined}
|
|
72
|
-
*/
|
|
73
|
-
function locator(search, index) {
|
|
74
|
-
if (typeof search === "string") search = source.indexOf(search, index ?? 0);
|
|
75
|
-
if (search === -1) return void 0;
|
|
76
|
-
let range = ranges[i];
|
|
77
|
-
const d = search >= range.end ? 1 : -1;
|
|
78
|
-
while (range) {
|
|
79
|
-
if (rangeContains(range, search)) return {
|
|
80
|
-
line: offsetLine + range.line,
|
|
81
|
-
column: offsetColumn + search - range.start,
|
|
82
|
-
character: search
|
|
83
|
-
};
|
|
84
|
-
i += d;
|
|
85
|
-
range = ranges[i];
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return locator;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @param {string} source
|
|
92
|
-
* @param {string | number} search
|
|
93
|
-
* @param {import('./types').Options} [options]
|
|
94
|
-
* @returns {Location | undefined}
|
|
95
|
-
*/
|
|
96
|
-
function locate(source, search, options) {
|
|
97
|
-
return getLocator(source, options)(search, options && options.startIndex);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/log/logs.ts
|
|
102
|
-
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER";
|
|
103
|
-
function logParseError(message, id, pos) {
|
|
104
|
-
return {
|
|
105
|
-
code: PARSE_ERROR,
|
|
106
|
-
id,
|
|
107
|
-
message,
|
|
108
|
-
pos
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function logInvalidLogPosition(pluginName) {
|
|
112
|
-
return {
|
|
113
|
-
code: INVALID_LOG_POSITION,
|
|
114
|
-
message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
118
|
-
return {
|
|
119
|
-
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
120
|
-
message: `The "${hookName}" hook used by the output plugin ${pluginName} 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.`
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function logCycleLoading(pluginName, moduleId) {
|
|
124
|
-
return {
|
|
125
|
-
code: CYCLE_LOADING,
|
|
126
|
-
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function logMultiplyNotifyOption() {
|
|
130
|
-
return {
|
|
131
|
-
code: MULTIPLY_NOTIFY_OPTION,
|
|
132
|
-
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function logPluginError(error, plugin, { hook, id } = {}) {
|
|
136
|
-
try {
|
|
137
|
-
const code = error.code;
|
|
138
|
-
if (!error.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error.pluginCode = code;
|
|
139
|
-
error.code = PLUGIN_ERROR;
|
|
140
|
-
error.plugin = plugin;
|
|
141
|
-
if (hook) error.hook = hook;
|
|
142
|
-
if (id) error.id = id;
|
|
143
|
-
} catch (_) {} finally {
|
|
144
|
-
return error;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function error(base) {
|
|
148
|
-
if (!(base instanceof Error)) {
|
|
149
|
-
base = Object.assign(new Error(base.message), base);
|
|
150
|
-
Object.defineProperty(base, "name", {
|
|
151
|
-
value: "RollupError",
|
|
152
|
-
writable: true
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
throw base;
|
|
156
|
-
}
|
|
157
|
-
function augmentCodeLocation(properties, pos, source, id) {
|
|
158
|
-
if (typeof pos === "object") {
|
|
159
|
-
const { line, column } = pos;
|
|
160
|
-
properties.loc = {
|
|
161
|
-
column,
|
|
162
|
-
file: id,
|
|
163
|
-
line
|
|
164
|
-
};
|
|
165
|
-
} else {
|
|
166
|
-
properties.pos = pos;
|
|
167
|
-
const location = locate(source, pos, { offsetLine: 1 });
|
|
168
|
-
if (!location) return;
|
|
169
|
-
const { line, column } = location;
|
|
170
|
-
properties.loc = {
|
|
171
|
-
column,
|
|
172
|
-
file: id,
|
|
173
|
-
line
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
if (properties.frame === void 0) {
|
|
177
|
-
const { line, column } = properties.loc;
|
|
178
|
-
properties.frame = getCodeFrame(source, line, column);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
//#endregion
|
|
183
|
-
export { logInvalidLogPosition as a, logPluginError as c, logInputHookInOutputPlugin as i, locate as l, error as n, logMultiplyNotifyOption as o, logCycleLoading as r, logParseError as s, augmentCodeLocation as t, getCodeFrame as u };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/utils/misc.ts
|
|
2
|
-
function arraify(value) {
|
|
3
|
-
return Array.isArray(value) ? value : [value];
|
|
4
|
-
}
|
|
5
|
-
function isPromiseLike(value) {
|
|
6
|
-
return value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
7
|
-
}
|
|
8
|
-
function unimplemented(info) {
|
|
9
|
-
if (info) throw new Error(`unimplemented: ${info}`);
|
|
10
|
-
throw new Error("unimplemented");
|
|
11
|
-
}
|
|
12
|
-
function unreachable(info) {
|
|
13
|
-
if (info) throw new Error(`unreachable: ${info}`);
|
|
14
|
-
throw new Error("unreachable");
|
|
15
|
-
}
|
|
16
|
-
function unsupported(info) {
|
|
17
|
-
throw new Error(`UNSUPPORTED: ${info}`);
|
|
18
|
-
}
|
|
19
|
-
function noop(..._args) {}
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { unreachable as a, unimplemented as i, isPromiseLike as n, unsupported as o, noop as r, arraify as t };
|