rolldown 1.0.0-beta.3-commit.e170e6e → 1.0.0-beta.30
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/bin/cli.mjs +2 -0
- package/dist/{cjs/cli.cjs → cli.cjs} +620 -620
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{esm/cli.mjs → cli.mjs} +596 -593
- package/dist/config.cjs +12 -0
- package/dist/config.d.cts +10 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.cjs +105 -0
- package/dist/experimental-index.d.cts +58 -0
- package/dist/experimental-index.d.mts +58 -0
- package/dist/experimental-index.mjs +82 -0
- package/dist/experimental-runtime-types.d.ts +66 -0
- package/dist/filter-index.cjs +105 -0
- package/dist/filter-index.d.cts +4 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -15
- package/dist/parallel-plugin-worker.d.cts +1 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -13
- package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
- package/dist/parallel-plugin.d.cts +14 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.d.cts +8 -0
- package/dist/parse-ast-index.d.mts +8 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding-BAyrv67G.d.cts +1309 -0
- package/dist/shared/binding-DUz1Q2JW.d.mts +1309 -0
- package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
- package/dist/shared/define-config-CMH1jWhX.d.cts +1331 -0
- package/dist/shared/define-config-D_KKKWbo.d.mts +1331 -0
- package/dist/shared/load-config-BWjPkvnW.mjs +119 -0
- package/dist/shared/load-config-BtTrX40c.cjs +125 -0
- package/dist/shared/misc-CQeo-AFx.mjs +22 -0
- package/dist/shared/misc-DksvspN4.cjs +58 -0
- package/dist/shared/parse-ast-index-DrqwhzH4.cjs +784 -0
- package/dist/shared/parse-ast-index-DyFjvjrb.mjs +656 -0
- package/dist/shared/{prompt-CxK9euq3.mjs → prompt-C5jz26Zn.mjs} +241 -240
- package/dist/shared/{prompt-ZZScCEWI.cjs → prompt-QNI93ne7.cjs} +245 -245
- package/dist/shared/src-CRRyjCYJ.cjs +4573 -0
- package/dist/shared/src-DR2upIfp.mjs +4381 -0
- package/package.json +69 -69
- package/bin/cli.js +0 -2
- package/dist/cjs/experimental-index.cjs +0 -85
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parse-ast-index.cjs +0 -4
- package/dist/esm/experimental-index.mjs +0 -57
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -3
- package/dist/shared/parse-ast-index-DIxeQDpE.mjs +0 -674
- package/dist/shared/parse-ast-index-Dh_sWnMa.cjs +0 -719
- package/dist/shared/src-CLo-BgXK.cjs +0 -3007
- package/dist/shared/src-CTS_IQ3m.mjs +0 -2826
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -13
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/binding.d.ts +0 -1435
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/constructors.d.ts +0 -21
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/load-config.d.ts +0 -5
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/index.d.ts +0 -30
- package/dist/types/log/log-handler.d.ts +0 -4
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logging.d.ts +0 -12
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/options/input-options.d.ts +0 -181
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-output-options.d.ts +0 -70
- package/dist/types/options/output-options.d.ts +0 -182
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -5
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -16
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/index.d.ts +0 -134
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -23
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/plugin-context-data.d.ts +0 -17
- package/dist/types/plugin/plugin-context.d.ts +0 -67
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -28
- package/dist/types/types/assert.d.ts +0 -14
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-side-effects.d.ts +0 -12
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-output.d.ts +0 -66
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/sourcemap.d.ts +0 -14
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-output-options.d.ts +0 -5
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/validator.d.ts +0 -6
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { rolldown } from "./src-DR2upIfp.mjs";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { readdir } from "node:fs/promises";
|
|
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
|
+
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
|
+
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};`;
|
|
32
|
+
return {
|
|
33
|
+
code: injectValues + code,
|
|
34
|
+
map: null
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}]
|
|
39
|
+
});
|
|
40
|
+
const outputDir = path.dirname(configFile);
|
|
41
|
+
const result = await bundle.write({
|
|
42
|
+
dir: outputDir,
|
|
43
|
+
format: isEsm ? "esm" : "cjs",
|
|
44
|
+
sourcemap: "inline",
|
|
45
|
+
entryFileNames: `rolldown.config.[hash]${path.extname(configFile).replace("ts", "js")}`
|
|
46
|
+
});
|
|
47
|
+
const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
|
|
48
|
+
return path.join(outputDir, fileName);
|
|
49
|
+
}
|
|
50
|
+
const SUPPORTED_JS_CONFIG_FORMATS = [
|
|
51
|
+
".js",
|
|
52
|
+
".mjs",
|
|
53
|
+
".cjs"
|
|
54
|
+
];
|
|
55
|
+
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
56
|
+
".ts",
|
|
57
|
+
".mts",
|
|
58
|
+
".cts"
|
|
59
|
+
];
|
|
60
|
+
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
61
|
+
const DEFAULT_CONFIG_BASE = "rolldown.config";
|
|
62
|
+
async function findConfigFileNameInCwd() {
|
|
63
|
+
const filesInWorkingDirectory = new Set(await readdir(cwd()));
|
|
64
|
+
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
65
|
+
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
|
|
66
|
+
if (filesInWorkingDirectory.has(fileName)) return fileName;
|
|
67
|
+
}
|
|
68
|
+
throw new Error("No `rolldown.config` configuration file found.");
|
|
69
|
+
}
|
|
70
|
+
async function loadTsConfig(configFile) {
|
|
71
|
+
const isEsm = isFilePathESM(configFile);
|
|
72
|
+
const file = await bundleTsConfig(configFile, isEsm);
|
|
73
|
+
try {
|
|
74
|
+
return (await import(pathToFileURL(file).href)).default;
|
|
75
|
+
} finally {
|
|
76
|
+
fs.unlink(file, () => {});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function isFilePathESM(filePath) {
|
|
80
|
+
if (/\.m[jt]s$/.test(filePath)) return true;
|
|
81
|
+
else if (/\.c[jt]s$/.test(filePath)) return false;
|
|
82
|
+
else {
|
|
83
|
+
const pkg = findNearestPackageData(path.dirname(filePath));
|
|
84
|
+
if (pkg) return pkg.type === "module";
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function findNearestPackageData(basedir) {
|
|
89
|
+
while (basedir) {
|
|
90
|
+
const pkgPath = path.join(basedir, "package.json");
|
|
91
|
+
if (tryStatSync(pkgPath)?.isFile()) try {
|
|
92
|
+
return JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
93
|
+
} catch {}
|
|
94
|
+
const nextBasedir = path.dirname(basedir);
|
|
95
|
+
if (nextBasedir === basedir) break;
|
|
96
|
+
basedir = nextBasedir;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
function tryStatSync(file) {
|
|
101
|
+
try {
|
|
102
|
+
return fs.statSync(file, { throwIfNoEntry: false });
|
|
103
|
+
} catch {}
|
|
104
|
+
}
|
|
105
|
+
async function loadConfig(configPath) {
|
|
106
|
+
const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
|
|
107
|
+
try {
|
|
108
|
+
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;
|
|
109
|
+
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
|
|
110
|
+
const rawConfigPath = path.resolve(configPath);
|
|
111
|
+
return await loadTsConfig(rawConfigPath);
|
|
112
|
+
} else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
throw new Error("Error happened while loading config.", { cause: err });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { loadConfig };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-DDkG_k5U.cjs');
|
|
2
|
+
const require_src = require('./src-CRRyjCYJ.cjs');
|
|
3
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
4
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
6
|
+
const node_fs_promises = require_chunk.__toESM(require("node:fs/promises"));
|
|
7
|
+
const node_process = require_chunk.__toESM(require("node:process"));
|
|
8
|
+
|
|
9
|
+
//#region src/utils/load-config.ts
|
|
10
|
+
async function bundleTsConfig(configFile, isEsm) {
|
|
11
|
+
const dirnameVarName = "injected_original_dirname";
|
|
12
|
+
const filenameVarName = "injected_original_filename";
|
|
13
|
+
const importMetaUrlVarName = "injected_original_import_meta_url";
|
|
14
|
+
const bundle = await require_src.rolldown({
|
|
15
|
+
input: configFile,
|
|
16
|
+
platform: "node",
|
|
17
|
+
resolve: { mainFields: ["main"] },
|
|
18
|
+
define: {
|
|
19
|
+
__dirname: dirnameVarName,
|
|
20
|
+
__filename: filenameVarName,
|
|
21
|
+
"import.meta.url": importMetaUrlVarName,
|
|
22
|
+
"import.meta.dirname": dirnameVarName,
|
|
23
|
+
"import.meta.filename": filenameVarName
|
|
24
|
+
},
|
|
25
|
+
treeshake: false,
|
|
26
|
+
external: [/^[\w@][^:]/],
|
|
27
|
+
plugins: [{
|
|
28
|
+
name: "inject-file-scope-variables",
|
|
29
|
+
transform: {
|
|
30
|
+
filter: { id: /\.[cm]?[jt]s$/ },
|
|
31
|
+
async handler(code, id) {
|
|
32
|
+
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)};`;
|
|
33
|
+
return {
|
|
34
|
+
code: injectValues + code,
|
|
35
|
+
map: null
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}]
|
|
40
|
+
});
|
|
41
|
+
const outputDir = node_path.default.dirname(configFile);
|
|
42
|
+
const result = await bundle.write({
|
|
43
|
+
dir: outputDir,
|
|
44
|
+
format: isEsm ? "esm" : "cjs",
|
|
45
|
+
sourcemap: "inline",
|
|
46
|
+
entryFileNames: `rolldown.config.[hash]${node_path.default.extname(configFile).replace("ts", "js")}`
|
|
47
|
+
});
|
|
48
|
+
const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
|
|
49
|
+
return node_path.default.join(outputDir, fileName);
|
|
50
|
+
}
|
|
51
|
+
const SUPPORTED_JS_CONFIG_FORMATS = [
|
|
52
|
+
".js",
|
|
53
|
+
".mjs",
|
|
54
|
+
".cjs"
|
|
55
|
+
];
|
|
56
|
+
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
57
|
+
".ts",
|
|
58
|
+
".mts",
|
|
59
|
+
".cts"
|
|
60
|
+
];
|
|
61
|
+
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
62
|
+
const DEFAULT_CONFIG_BASE = "rolldown.config";
|
|
63
|
+
async function findConfigFileNameInCwd() {
|
|
64
|
+
const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)((0, node_process.cwd)()));
|
|
65
|
+
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
66
|
+
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
|
|
67
|
+
if (filesInWorkingDirectory.has(fileName)) return fileName;
|
|
68
|
+
}
|
|
69
|
+
throw new Error("No `rolldown.config` configuration file found.");
|
|
70
|
+
}
|
|
71
|
+
async function loadTsConfig(configFile) {
|
|
72
|
+
const isEsm = isFilePathESM(configFile);
|
|
73
|
+
const file = await bundleTsConfig(configFile, isEsm);
|
|
74
|
+
try {
|
|
75
|
+
return (await import((0, node_url.pathToFileURL)(file).href)).default;
|
|
76
|
+
} finally {
|
|
77
|
+
node_fs.default.unlink(file, () => {});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function isFilePathESM(filePath) {
|
|
81
|
+
if (/\.m[jt]s$/.test(filePath)) return true;
|
|
82
|
+
else if (/\.c[jt]s$/.test(filePath)) return false;
|
|
83
|
+
else {
|
|
84
|
+
const pkg = findNearestPackageData(node_path.default.dirname(filePath));
|
|
85
|
+
if (pkg) return pkg.type === "module";
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function findNearestPackageData(basedir) {
|
|
90
|
+
while (basedir) {
|
|
91
|
+
const pkgPath = node_path.default.join(basedir, "package.json");
|
|
92
|
+
if (tryStatSync(pkgPath)?.isFile()) try {
|
|
93
|
+
return JSON.parse(node_fs.default.readFileSync(pkgPath, "utf-8"));
|
|
94
|
+
} catch {}
|
|
95
|
+
const nextBasedir = node_path.default.dirname(basedir);
|
|
96
|
+
if (nextBasedir === basedir) break;
|
|
97
|
+
basedir = nextBasedir;
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function tryStatSync(file) {
|
|
102
|
+
try {
|
|
103
|
+
return node_fs.default.statSync(file, { throwIfNoEntry: false });
|
|
104
|
+
} catch {}
|
|
105
|
+
}
|
|
106
|
+
async function loadConfig(configPath) {
|
|
107
|
+
const ext = node_path.default.extname(configPath = configPath || await findConfigFileNameInCwd());
|
|
108
|
+
try {
|
|
109
|
+
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;
|
|
110
|
+
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
|
|
111
|
+
const rawConfigPath = node_path.default.resolve(configPath);
|
|
112
|
+
return await loadTsConfig(rawConfigPath);
|
|
113
|
+
} else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
throw new Error("Error happened while loading config.", { cause: err });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
Object.defineProperty(exports, 'loadConfig', {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return loadConfig;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
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 { arraify, isPromiseLike, noop, unimplemented, unreachable, unsupported };
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
});
|