rolldown 1.0.0-beta.35 → 1.0.0-beta.36

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.
Files changed (44) hide show
  1. package/dist/cli.mjs +17 -28
  2. package/dist/config.d.mts +2 -2
  3. package/dist/config.mjs +3 -3
  4. package/dist/experimental-index.d.mts +8 -5
  5. package/dist/experimental-index.mjs +6 -4
  6. package/dist/filter-index.d.mts +2 -2
  7. package/dist/index.d.mts +2 -2
  8. package/dist/index.mjs +2 -2
  9. package/dist/parallel-plugin-worker.mjs +3 -4
  10. package/dist/parallel-plugin.d.mts +2 -2
  11. package/dist/parse-ast-index.d.mts +1 -1
  12. package/dist/parse-ast-index.mjs +1 -1
  13. package/dist/shared/{binding-9k0egz6L.d.mts → binding-wK0CRIMb.d.mts} +1 -0
  14. package/dist/shared/{define-config-DhrkZ_o7.d.cts → define-config-wxvILtDx.d.mts} +3 -3
  15. package/dist/shared/{load-config-C93_L4MP.mjs → load-config-Jqw6FAJp.mjs} +4 -6
  16. package/dist/shared/parse-ast-index-CkDFQ-07.mjs +10847 -0
  17. package/dist/shared/{prompt-C5jz26Zn.mjs → prompt-DuG2i9ud.mjs} +4 -7
  18. package/dist/shared/{src-D954P1TH.mjs → src-WjgJWoNk.mjs} +69 -42
  19. package/package.json +32 -46
  20. package/dist/cli.cjs +0 -1773
  21. package/dist/cli.d.cts +0 -1
  22. package/dist/config.cjs +0 -12
  23. package/dist/config.d.cts +0 -10
  24. package/dist/experimental-index.cjs +0 -154
  25. package/dist/experimental-index.d.cts +0 -99
  26. package/dist/filter-index.cjs +0 -106
  27. package/dist/filter-index.d.cts +0 -4
  28. package/dist/index.cjs +0 -9
  29. package/dist/index.d.cts +0 -3
  30. package/dist/parallel-plugin-worker.cjs +0 -33
  31. package/dist/parallel-plugin-worker.d.cts +0 -1
  32. package/dist/parallel-plugin.cjs +0 -8
  33. package/dist/parallel-plugin.d.cts +0 -14
  34. package/dist/parse-ast-index.cjs +0 -4
  35. package/dist/parse-ast-index.d.cts +0 -8
  36. package/dist/shared/binding-D13M6Llu.d.cts +0 -1425
  37. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  38. package/dist/shared/define-config-3arq8OPE.d.mts +0 -1421
  39. package/dist/shared/load-config-S_ofSLrj.cjs +0 -130
  40. package/dist/shared/misc-DksvspN4.cjs +0 -58
  41. package/dist/shared/parse-ast-index-BadydpMA.mjs +0 -725
  42. package/dist/shared/parse-ast-index-cePJvlvW.cjs +0 -871
  43. package/dist/shared/prompt-Q05EYrFb.cjs +0 -858
  44. package/dist/shared/src-BBMxhaqf.cjs +0 -4673
@@ -1,130 +0,0 @@
1
- const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
- const require_src = require('./src-BBMxhaqf.cjs');
3
- let node_fs = require("node:fs");
4
- node_fs = require_chunk.__toESM(node_fs);
5
- let node_path = require("node:path");
6
- node_path = require_chunk.__toESM(node_path);
7
- let node_url = require("node:url");
8
- node_url = require_chunk.__toESM(node_url);
9
- let node_fs_promises = require("node:fs/promises");
10
- node_fs_promises = require_chunk.__toESM(node_fs_promises);
11
- let node_process = require("node:process");
12
- node_process = require_chunk.__toESM(node_process);
13
-
14
- //#region src/utils/load-config.ts
15
- async function bundleTsConfig(configFile, isEsm) {
16
- const dirnameVarName = "injected_original_dirname";
17
- const filenameVarName = "injected_original_filename";
18
- const importMetaUrlVarName = "injected_original_import_meta_url";
19
- const bundle = await require_src.rolldown({
20
- input: configFile,
21
- platform: "node",
22
- resolve: { mainFields: ["main"] },
23
- define: {
24
- __dirname: dirnameVarName,
25
- __filename: filenameVarName,
26
- "import.meta.url": importMetaUrlVarName,
27
- "import.meta.dirname": dirnameVarName,
28
- "import.meta.filename": filenameVarName
29
- },
30
- treeshake: false,
31
- external: [/^[\w@][^:]/],
32
- plugins: [{
33
- name: "inject-file-scope-variables",
34
- transform: {
35
- filter: { id: /\.[cm]?[jt]s$/ },
36
- async handler(code, id) {
37
- const injectValues = `const ${dirnameVarName} = ${JSON.stringify(node_path.default.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify((0, node_url.pathToFileURL)(id).href)};`;
38
- return {
39
- code: injectValues + code,
40
- map: null
41
- };
42
- }
43
- }
44
- }]
45
- });
46
- const outputDir = node_path.default.dirname(configFile);
47
- const result = await bundle.write({
48
- dir: outputDir,
49
- format: isEsm ? "esm" : "cjs",
50
- sourcemap: "inline",
51
- entryFileNames: `rolldown.config.[hash]${node_path.default.extname(configFile).replace("ts", "js")}`
52
- });
53
- const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
54
- return node_path.default.join(outputDir, fileName);
55
- }
56
- const SUPPORTED_JS_CONFIG_FORMATS = [
57
- ".js",
58
- ".mjs",
59
- ".cjs"
60
- ];
61
- const SUPPORTED_TS_CONFIG_FORMATS = [
62
- ".ts",
63
- ".mts",
64
- ".cts"
65
- ];
66
- const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
67
- const DEFAULT_CONFIG_BASE = "rolldown.config";
68
- async function findConfigFileNameInCwd() {
69
- const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)((0, node_process.cwd)()));
70
- for (const extension of SUPPORTED_CONFIG_FORMATS) {
71
- const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
72
- if (filesInWorkingDirectory.has(fileName)) return fileName;
73
- }
74
- throw new Error("No `rolldown.config` configuration file found.");
75
- }
76
- async function loadTsConfig(configFile) {
77
- const isEsm = isFilePathESM(configFile);
78
- const file = await bundleTsConfig(configFile, isEsm);
79
- try {
80
- return (await import((0, node_url.pathToFileURL)(file).href)).default;
81
- } finally {
82
- node_fs.default.unlink(file, () => {});
83
- }
84
- }
85
- function isFilePathESM(filePath) {
86
- if (/\.m[jt]s$/.test(filePath)) return true;
87
- else if (/\.c[jt]s$/.test(filePath)) return false;
88
- else {
89
- const pkg = findNearestPackageData(node_path.default.dirname(filePath));
90
- if (pkg) return pkg.type === "module";
91
- return false;
92
- }
93
- }
94
- function findNearestPackageData(basedir) {
95
- while (basedir) {
96
- const pkgPath = node_path.default.join(basedir, "package.json");
97
- if (tryStatSync(pkgPath)?.isFile()) try {
98
- return JSON.parse(node_fs.default.readFileSync(pkgPath, "utf-8"));
99
- } catch {}
100
- const nextBasedir = node_path.default.dirname(basedir);
101
- if (nextBasedir === basedir) break;
102
- basedir = nextBasedir;
103
- }
104
- return null;
105
- }
106
- function tryStatSync(file) {
107
- try {
108
- return node_fs.default.statSync(file, { throwIfNoEntry: false });
109
- } catch {}
110
- }
111
- async function loadConfig(configPath) {
112
- const ext = node_path.default.extname(configPath = configPath || await findConfigFileNameInCwd());
113
- try {
114
- if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import((0, node_url.pathToFileURL)(configPath).href)).default;
115
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
116
- const rawConfigPath = node_path.default.resolve(configPath);
117
- return await loadTsConfig(rawConfigPath);
118
- } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
119
- } catch (err) {
120
- throw new Error("Error happened while loading config.", { cause: err });
121
- }
122
- }
123
-
124
- //#endregion
125
- Object.defineProperty(exports, 'loadConfig', {
126
- enumerable: true,
127
- get: function () {
128
- return loadConfig;
129
- }
130
- });
@@ -1,58 +0,0 @@
1
-
2
- //#region src/utils/misc.ts
3
- function arraify(value) {
4
- return Array.isArray(value) ? value : [value];
5
- }
6
- function isPromiseLike(value) {
7
- return value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
8
- }
9
- function unimplemented(info) {
10
- if (info) throw new Error(`unimplemented: ${info}`);
11
- throw new Error("unimplemented");
12
- }
13
- function unreachable(info) {
14
- if (info) throw new Error(`unreachable: ${info}`);
15
- throw new Error("unreachable");
16
- }
17
- function unsupported(info) {
18
- throw new Error(`UNSUPPORTED: ${info}`);
19
- }
20
- function noop(..._args) {}
21
-
22
- //#endregion
23
- Object.defineProperty(exports, 'arraify', {
24
- enumerable: true,
25
- get: function () {
26
- return arraify;
27
- }
28
- });
29
- Object.defineProperty(exports, 'isPromiseLike', {
30
- enumerable: true,
31
- get: function () {
32
- return isPromiseLike;
33
- }
34
- });
35
- Object.defineProperty(exports, 'noop', {
36
- enumerable: true,
37
- get: function () {
38
- return noop;
39
- }
40
- });
41
- Object.defineProperty(exports, 'unimplemented', {
42
- enumerable: true,
43
- get: function () {
44
- return unimplemented;
45
- }
46
- });
47
- Object.defineProperty(exports, 'unreachable', {
48
- enumerable: true,
49
- get: function () {
50
- return unreachable;
51
- }
52
- });
53
- Object.defineProperty(exports, 'unsupported', {
54
- enumerable: true,
55
- get: function () {
56
- return unsupported;
57
- }
58
- });