@bemedev/dev-utils 0.8.3 → 1.0.1
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/README.md +8 -19
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +1 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +3 -3
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +1 -1
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +0 -1
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +1 -51
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs +0 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/index.d.ts +0 -1
- package/lib/build-tests/cli/index.js.map +1 -1
- package/lib/build-tests/cli/post.cjs +0 -1
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +1 -5
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +0 -1
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +1 -5
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +1 -15
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +1 -1
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +0 -1
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +1 -1
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +2 -2
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +0 -1
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +3 -3
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +0 -1
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +3 -7
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/imports/index.d.ts +1 -1
- package/lib/build-tests/index.d.ts +5 -5
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +1 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/rolldown-config/config.cjs +6 -11
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +1 -1
- package/lib/rolldown-config/config.js +1 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +5 -5
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +0 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +2 -2
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/index.d.ts +3 -3
- package/lib/rolldown-config/input.cjs +1 -2
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +1 -1
- package/lib/rolldown-config/input.js +1 -1
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +1 -15
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +6 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +9 -7
- package/lib/rolldown-config/plugins/circulars.js +5 -3
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +4 -9
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +4 -13
- package/lib/rolldown-config/plugins/clean.js +4 -7
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +1 -1
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -6
- package/lib/rolldown-config/plugins/externals.js +1 -0
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +1 -8
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +2 -27
- package/lib/rolldown-config/plugins/index.js +0 -6
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +45 -33
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +39 -46
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +4 -2
- package/lib/rolldown-config/plugins/typescript.config.js +41 -47
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
- package/lib/rolldown-config/plugins/typescript.js +44 -30
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +13 -13
- package/lib/{rolldown-config/utils.cjs → utils/array.cjs} +2 -2
- package/lib/utils/array.cjs.map +1 -0
- package/lib/utils/array.d.ts +2 -0
- package/lib/{rolldown-config/utils.js → utils/array.js} +2 -2
- package/lib/utils/array.js.map +1 -0
- package/lib/utils/identity.d.ts +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +4 -3
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +1 -1
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +5 -1
- package/lib/vitest-exclude/index.d.ts +1 -1
- package/lib/vitest-exclude/types.d.ts +8 -11
- package/lib/vitest-exclude/vitest.cjs +6 -9
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +15 -30
- package/lib/vitest-exclude/vitest.js +6 -9
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +1 -2
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
- package/lib/vitest-exclude/vitest.utils.js +1 -1
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +1 -5
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +3 -7
- package/lib/vitest-extended/acceptation.js +1 -4
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/bemedev/globals/types.d.ts +4 -1
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs +4 -3
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs.map +1 -1
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -9
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.js +4 -3
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +22 -24
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +34 -56
- package/lib/vitest-extended/createTests.js +22 -23
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +10 -6
- package/lib/vitest-extended/done.cjs +6 -4
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +8 -13
- package/lib/vitest-extended/done.js +6 -3
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +0 -1
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +1 -1
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +10 -4
- package/lib/vitest-extended/each/index.d.ts +2 -2
- package/lib/vitest-extended/each/pass.cjs +13 -16
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +26 -28
- package/lib/vitest-extended/each/pass.js +13 -15
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +18 -6
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +2 -2
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +2 -2
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +0 -1
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +2 -2
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/index.d.ts +6 -6
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +1 -1
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +1 -1
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +1 -1
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +1 -1
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +40 -42
- package/package.json +14 -10
- package/lib/rolldown-config/plugins/alias.cjs +0 -17
- package/lib/rolldown-config/plugins/alias.cjs.map +0 -1
- package/lib/rolldown-config/plugins/alias.d.ts +0 -25
- package/lib/rolldown-config/plugins/alias.js +0 -14
- package/lib/rolldown-config/plugins/alias.js.map +0 -1
- package/lib/rolldown-config/plugins/tsPaths.cjs +0 -17
- package/lib/rolldown-config/plugins/tsPaths.cjs.map +0 -1
- package/lib/rolldown-config/plugins/tsPaths.d.ts +0 -9
- package/lib/rolldown-config/plugins/tsPaths.js +0 -14
- package/lib/rolldown-config/plugins/tsPaths.js.map +0 -1
- package/lib/rolldown-config/utils.cjs.map +0 -1
- package/lib/rolldown-config/utils.d.ts +0 -2
- package/lib/rolldown-config/utils.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
let rollup_plugin_node_externals = require("rollup-plugin-node-externals");
|
|
4
3
|
//#region src/rolldown-config/plugins/externals.ts
|
|
5
4
|
/**
|
|
6
5
|
* Creates a configured node externals plugin instance
|
|
6
|
+
*
|
|
7
7
|
* @param options - Configuration options for node externals
|
|
8
8
|
* @returns Rolldown plugin
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance\n * @param options - Configuration options for node externals\n * @returns Rolldown plugin\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"externals.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance\n *\n * @param options - Configuration options for node externals\n * @returns Rolldown plugin\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,UACd,UAAgC,CAAC,GACX;CACtB,QAAA,GAAA,6BAAA,cAAA,CAAqB,OAAO;AAC9B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { RolldownPluginOption } from
|
|
2
|
-
import { nodeExternals } from
|
|
1
|
+
import type { RolldownPluginOption } from "rolldown";
|
|
2
|
+
import { nodeExternals } from "rollup-plugin-node-externals";
|
|
3
3
|
export type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
* Creates a configured node externals plugin instance
|
|
6
|
+
*
|
|
7
|
+
* @param options - Configuration options for node externals
|
|
8
|
+
* @returns Rolldown plugin
|
|
9
|
+
*/
|
|
9
10
|
export declare function externals(options?: NodeExternalsOptions): RolldownPluginOption;
|
|
@@ -2,6 +2,7 @@ import { nodeExternals } from "rollup-plugin-node-externals";
|
|
|
2
2
|
//#region src/rolldown-config/plugins/externals.ts
|
|
3
3
|
/**
|
|
4
4
|
* Creates a configured node externals plugin instance
|
|
5
|
+
*
|
|
5
6
|
* @param options - Configuration options for node externals
|
|
6
7
|
* @returns Rolldown plugin
|
|
7
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals.js","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance\n * @param options - Configuration options for node externals\n * @returns Rolldown plugin\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"externals.js","names":[],"sources":["../../../src/rolldown-config/plugins/externals.ts"],"sourcesContent":["import type { RolldownPluginOption } from 'rolldown';\nimport { nodeExternals } from 'rollup-plugin-node-externals';\n\nexport type NodeExternalsOptions = Parameters<typeof nodeExternals>[0];\n\n/**\n * Creates a configured node externals plugin instance\n *\n * @param options - Configuration options for node externals\n * @returns Rolldown plugin\n */\nexport function externals(\n options: NodeExternalsOptions = {},\n): RolldownPluginOption {\n return nodeExternals(options);\n}\n"],"mappings":";;;;;;;;AAWA,SAAgB,UACd,UAAgC,CAAC,GACX;CACtB,OAAO,cAAc,OAAO;AAC9B"}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_config_plugins_alias = require("./alias.cjs");
|
|
3
2
|
const require_rolldown_config_plugins_circulars = require("./circulars.cjs");
|
|
4
3
|
const require_rolldown_config_plugins_clean = require("./clean.cjs");
|
|
5
4
|
const require_rolldown_config_plugins_externals = require("./externals.cjs");
|
|
6
|
-
const require_rolldown_config_plugins_tsPaths = require("./tsPaths.cjs");
|
|
7
|
-
const require_rolldown_config_plugins_typescript = require("./typescript.cjs");
|
|
8
5
|
//#region src/rolldown-config/plugins/index.ts
|
|
9
6
|
const PLUGIN_BUILDERS = {
|
|
10
|
-
|
|
11
|
-
typescript: require_rolldown_config_plugins_typescript.typescript,
|
|
12
|
-
tsPaths: require_rolldown_config_plugins_tsPaths.tsPaths,
|
|
7
|
+
typescript: require("./typescript.cjs").typescript,
|
|
13
8
|
circulars: require_rolldown_config_plugins_circulars.circulars,
|
|
14
9
|
externals: require_rolldown_config_plugins_externals.externals,
|
|
15
10
|
clean: require_rolldown_config_plugins_clean.clean
|
|
16
11
|
};
|
|
17
12
|
const DEFAULT_PLUGINS_ORDER = [
|
|
18
|
-
"alias",
|
|
19
13
|
"typescript",
|
|
20
|
-
"tsPaths",
|
|
21
14
|
"circulars",
|
|
22
15
|
"externals",
|
|
23
16
|
"clean"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import { circulars } from './circulars';\nimport { clean } from './clean';\nimport { externals } from './externals';\nimport { typescript } from './typescript';\n\nexport const PLUGIN_BUILDERS = { typescript, circulars, externals, clean };\n\nexport const DEFAULT_PLUGINS_ORDER = [\n 'typescript',\n 'circulars',\n 'externals',\n 'clean',\n];\n"],"mappings":";;;;;AAKA,MAAa,kBAAkB;CAAE,sCAAA,CAAA,CAAA;CAAY,WAAA,0CAAA;CAAW,WAAA,0CAAA;CAAW,OAAA,sCAAA;AAAM;AAEzE,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;AACF"}
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { externals } from './externals';
|
|
4
|
-
import { tsPaths } from './tsPaths';
|
|
5
|
-
export declare const PLUGIN_BUILDERS: {
|
|
6
|
-
alias: typeof alias;
|
|
7
|
-
typescript: ({ exclude, include, declarationMap, dir, }?: {
|
|
8
|
-
exclude?: string | string[];
|
|
9
|
-
include?: Record<string, string>;
|
|
10
|
-
declarationMap?: boolean;
|
|
11
|
-
dir?: string;
|
|
12
|
-
}) => import("rolldown").RolldownPluginOption;
|
|
13
|
-
tsPaths: typeof tsPaths;
|
|
14
|
-
circulars: typeof circulars;
|
|
15
|
-
externals: typeof externals;
|
|
16
|
-
clean: (options: import("./clean").EndPluginOptions) => {
|
|
17
|
-
name: string;
|
|
18
|
-
onLog: {
|
|
19
|
-
handler: (this: import("rolldown").MinimalPluginContext, _: import("rolldown").LogLevel, { code, names }: import("rolldown").RolldownLog) => false | undefined;
|
|
20
|
-
};
|
|
21
|
-
closeBundle: {
|
|
22
|
-
order: "post";
|
|
23
|
-
handler: () => void;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export declare const DEFAULT_PLUGINS_ORDER: string[];
|
|
1
|
+
export declare const PLUGIN_BUILDERS: {};
|
|
2
|
+
export declare const DEFAULT_PLUGINS_ORDER: unknown;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import { alias } from "./alias.js";
|
|
2
1
|
import { circulars } from "./circulars.js";
|
|
3
2
|
import { clean } from "./clean.js";
|
|
4
3
|
import { externals } from "./externals.js";
|
|
5
|
-
import { tsPaths } from "./tsPaths.js";
|
|
6
4
|
import { typescript } from "./typescript.js";
|
|
7
5
|
//#region src/rolldown-config/plugins/index.ts
|
|
8
6
|
const PLUGIN_BUILDERS = {
|
|
9
|
-
alias,
|
|
10
7
|
typescript,
|
|
11
|
-
tsPaths,
|
|
12
8
|
circulars,
|
|
13
9
|
externals,
|
|
14
10
|
clean
|
|
15
11
|
};
|
|
16
12
|
const DEFAULT_PLUGINS_ORDER = [
|
|
17
|
-
"alias",
|
|
18
13
|
"typescript",
|
|
19
|
-
"tsPaths",
|
|
20
14
|
"circulars",
|
|
21
15
|
"externals",
|
|
22
16
|
"clean"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/rolldown-config/plugins/index.ts"],"sourcesContent":["import { circulars } from './circulars';\nimport { clean } from './clean';\nimport { externals } from './externals';\nimport { typescript } from './typescript';\n\nexport const PLUGIN_BUILDERS = { typescript, circulars, externals, clean };\n\nexport const DEFAULT_PLUGINS_ORDER = [\n 'typescript',\n 'circulars',\n 'externals',\n 'clean',\n];\n"],"mappings":";;;;;AAKA,MAAa,kBAAkB;CAAE;CAAY;CAAW;CAAW;AAAM;AAEzE,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;AACF"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_rolldown_config_utils = require("../utils.cjs");
|
|
2
|
+
const require_utils_array = require("../../utils/array.cjs");
|
|
4
3
|
require("../constants.cjs");
|
|
5
4
|
const require_rolldown_config_plugins_typescript_config = require("./typescript.config.cjs");
|
|
6
5
|
let fs = require("fs");
|
|
7
|
-
let
|
|
8
|
-
|
|
6
|
+
let path = require("path");
|
|
7
|
+
let glob = require("glob");
|
|
8
|
+
let oxc_transform = require("oxc-transform");
|
|
9
9
|
let tsc_alias = require("tsc-alias");
|
|
10
10
|
//#region src/rolldown-config/plugins/typescript.ts
|
|
11
|
-
const typescript
|
|
11
|
+
const typescript = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
12
12
|
let done = false;
|
|
13
13
|
return {
|
|
14
14
|
name: "bemedev-dts",
|
|
15
15
|
options(opts) {
|
|
16
|
-
opts.external = [...
|
|
16
|
+
opts.external = [...require_utils_array.toArray(opts.external).filter((v) => typeof v === "string" || v instanceof RegExp), "source-map-support"];
|
|
17
17
|
return opts;
|
|
18
18
|
},
|
|
19
19
|
closeBundle: {
|
|
@@ -21,34 +21,46 @@ const typescript$1 = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
|
21
21
|
async handler() {
|
|
22
22
|
if (done) return;
|
|
23
23
|
const cwd = process.cwd();
|
|
24
|
-
const tsconfigPath =
|
|
24
|
+
const tsconfigPath = require_rolldown_config_plugins_typescript_config.findConfigFile(cwd, "tsconfig.json");
|
|
25
25
|
const configFile = require_rolldown_config_plugins_typescript_config.readTsConfig(tsconfigPath);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
const outDir = configFile.compilerOptions.outDir ?? dir ?? "lib";
|
|
27
|
+
const rootDir = configFile.compilerOptions.rootDir ?? (0, path.join)(cwd, "src");
|
|
28
|
+
let files;
|
|
29
|
+
if (include && Object.keys(include).length > 0) files = Object.values(include);
|
|
30
|
+
else files = (0, glob.globSync)((0, path.join)(rootDir, "**/*.{ts,tsx,cts,mts}"), { ignore: require_utils_array.toArray(exclude) });
|
|
31
|
+
files = files.filter((file) => !file.endsWith(".d.ts") && !file.endsWith(".d.cts") && !file.endsWith(".d.mts"));
|
|
32
|
+
const errors = [];
|
|
33
|
+
for (const file of files) try {
|
|
34
|
+
const result = (0, oxc_transform.transformSync)(file, (0, fs.readFileSync)(file, "utf-8"), {
|
|
35
|
+
typescript: { declaration: { sourcemap: !!declarationMap } },
|
|
36
|
+
sourcemap: !!declarationMap
|
|
37
|
+
});
|
|
38
|
+
if (result.errors && result.errors.length > 0) errors.push(...result.errors);
|
|
39
|
+
const relativePath = (0, path.relative)(rootDir, file);
|
|
40
|
+
let dtsName = relativePath;
|
|
41
|
+
if (relativePath.endsWith(".tsx")) dtsName = relativePath.slice(0, -4) + ".d.ts";
|
|
42
|
+
else if (relativePath.endsWith(".ts")) dtsName = relativePath.slice(0, -3) + ".d.ts";
|
|
43
|
+
else if (relativePath.endsWith(".cts")) dtsName = relativePath.slice(0, -4) + ".d.cts";
|
|
44
|
+
else if (relativePath.endsWith(".mts")) dtsName = relativePath.slice(0, -4) + ".d.mts";
|
|
45
|
+
const outPath = (0, path.join)(outDir, dtsName);
|
|
46
|
+
const outMapPath = outPath + ".map";
|
|
47
|
+
(0, fs.mkdirSync)((0, path.dirname)(outPath), { recursive: true });
|
|
48
|
+
let dtsCode = result.declaration ?? "";
|
|
49
|
+
if (declarationMap && result.declarationMap) {
|
|
50
|
+
dtsCode += `\n//# sourceMappingURL=${(0, path.basename)(dtsName)}.map\n`;
|
|
51
|
+
(0, fs.writeFileSync)(outMapPath, JSON.stringify(result.declarationMap), "utf-8");
|
|
39
52
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (errors.length > 0) console.error(typescript.default.formatDiagnosticsWithColorAndContext(errors, host));
|
|
53
|
+
(0, fs.writeFileSync)(outPath, dtsCode, "utf-8");
|
|
54
|
+
} catch (err) {
|
|
55
|
+
console.error(`[bemedev-dts] Failed to process ${file}:`, err);
|
|
56
|
+
}
|
|
57
|
+
if (errors.length > 0) {
|
|
58
|
+
console.error(`[bemedev-dts] Generation completed with errors:`);
|
|
59
|
+
for (const err of errors) {
|
|
60
|
+
console.error(`Error in ${err.filename || "unknown file"}: ${err.message}`);
|
|
61
|
+
if (err.codeframe) console.error(err.codeframe);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
52
64
|
await (0, tsc_alias.replaceTscAliasPaths)({
|
|
53
65
|
configFile: tsconfigPath,
|
|
54
66
|
outDir
|
|
@@ -60,6 +72,6 @@ const typescript$1 = ({ exclude, include, declarationMap, dir } = {}) => {
|
|
|
60
72
|
};
|
|
61
73
|
};
|
|
62
74
|
//#endregion
|
|
63
|
-
exports.typescript = typescript
|
|
75
|
+
exports.typescript = typescript;
|
|
64
76
|
|
|
65
77
|
//# sourceMappingURL=typescript.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.cjs","names":["
|
|
1
|
+
{"version":3,"file":"typescript.cjs","names":["toArray","findConfigFile","readTsConfig"],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, relative } from 'node:path';\n\nimport { globSync } from 'glob';\nimport { transformSync } from 'oxc-transform';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\n\nimport { toArray } from '#utils';\n\nimport { DEFAULT_DIR } from '../constants';\nimport { findConfigFile, readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = findConfigFile(cwd, 'tsconfig.json')!;\n\n const configFile = readTsConfig(tsconfigPath);\n const outDir =\n configFile.compilerOptions.outDir ?? dir ?? DEFAULT_DIR;\n const rootDir =\n configFile.compilerOptions.rootDir ?? join(cwd, 'src');\n\n let files: string[];\n if (include && Object.keys(include).length > 0) {\n files = Object.values(include);\n } else {\n files = globSync(join(rootDir, '**/*.{ts,tsx,cts,mts}'), {\n ignore: toArray(exclude),\n });\n }\n\n files = files.filter(\n file =>\n !file.endsWith('.d.ts') &&\n !file.endsWith('.d.cts') &&\n !file.endsWith('.d.mts'),\n );\n\n const errors: any[] = [];\n\n for (const file of files) {\n try {\n const content = readFileSync(file, 'utf-8');\n const result = transformSync(file, content, {\n typescript: { declaration: { sourcemap: !!declarationMap } },\n sourcemap: !!declarationMap,\n });\n\n if (result.errors && result.errors.length > 0) {\n errors.push(...result.errors);\n }\n\n // Compute output path relative to rootDir\n const relativePath = relative(rootDir, file);\n let dtsName = relativePath;\n if (relativePath.endsWith('.tsx')) {\n dtsName = relativePath.slice(0, -4) + '.d.ts';\n } else if (relativePath.endsWith('.ts')) {\n dtsName = relativePath.slice(0, -3) + '.d.ts';\n } else if (relativePath.endsWith('.cts')) {\n dtsName = relativePath.slice(0, -4) + '.d.cts';\n } else if (relativePath.endsWith('.mts')) {\n dtsName = relativePath.slice(0, -4) + '.d.mts';\n }\n\n const outPath = join(outDir, dtsName);\n const outMapPath = outPath + '.map';\n\n // Ensure output directory exists\n mkdirSync(dirname(outPath), { recursive: true });\n\n let dtsCode = result.declaration ?? '';\n if (declarationMap && result.declarationMap) {\n dtsCode += `\\n//# sourceMappingURL=${basename(dtsName)}.map\\n`;\n writeFileSync(\n outMapPath,\n JSON.stringify(result.declarationMap),\n 'utf-8',\n );\n }\n\n writeFileSync(outPath, dtsCode, 'utf-8');\n } catch (err: any) {\n console.error(`[bemedev-dts] Failed to process ${file}:`, err);\n }\n }\n\n if (errors.length > 0) {\n console.error(`[bemedev-dts] Generation completed with errors:`);\n for (const err of errors) {\n console.error(\n `Error in ${err.filename || 'unknown file'}: ${err.message}`,\n );\n if (err.codeframe) {\n console.error(err.codeframe);\n }\n }\n }\n\n await replaceTscAliasPaths({ configFile: tsconfigPath, outDir });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":"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"}
|
|
@@ -1,58 +1,51 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
let fs = require("fs");
|
|
4
3
|
let path = require("path");
|
|
5
|
-
let
|
|
6
|
-
typescript = require_runtime.__toESM(typescript, 1);
|
|
4
|
+
let module$1 = require("module");
|
|
7
5
|
//#region src/rolldown-config/plugins/typescript.config.ts
|
|
8
|
-
|
|
6
|
+
function stripComments(jsonString) {
|
|
7
|
+
return jsonString.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m);
|
|
8
|
+
}
|
|
9
|
+
function findConfigFile(searchPath, configName = "tsconfig.json") {
|
|
10
|
+
let dir = searchPath;
|
|
11
|
+
while (true) {
|
|
12
|
+
const filePath = (0, path.join)(dir, configName);
|
|
13
|
+
if ((0, fs.existsSync)(filePath)) return filePath;
|
|
14
|
+
const parentDir = (0, path.dirname)(dir);
|
|
15
|
+
if (parentDir === dir) break;
|
|
16
|
+
dir = parentDir;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const readTsConfig = (path$1) => {
|
|
20
|
+
if (!(0, fs.existsSync)(path$1)) throw new Error(`tsconfig.json not found at ${path$1}`);
|
|
21
|
+
const cleanJson = stripComments((0, fs.readFileSync)(path$1, "utf-8"));
|
|
22
|
+
let config;
|
|
9
23
|
try {
|
|
10
|
-
|
|
11
|
-
} catch {
|
|
12
|
-
|
|
24
|
+
config = JSON.parse(cleanJson);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
throw new Error(`Failed to parse tsconfig.json at ${path$1}: ${e.message}`, { cause: e });
|
|
13
27
|
}
|
|
14
|
-
};
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
for (const entry of entries) {
|
|
26
|
-
const fullPath = (0, path.join)(dir, entry);
|
|
27
|
-
let stat;
|
|
28
|
-
try {
|
|
29
|
-
stat = (0, fs.statSync)(fullPath);
|
|
30
|
-
} catch {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (stat.isDirectory()) walk(fullPath, currentDepth + 1);
|
|
34
|
-
else if (!extensions || extensions.some((ext) => entry.endsWith(ext))) results.push(fullPath);
|
|
28
|
+
let compilerOptions = config.compilerOptions || {};
|
|
29
|
+
const configDir = (0, path.dirname)(path$1);
|
|
30
|
+
const extendsPaths = Array.isArray(config.extends) ? config.extends : config.extends ? [config.extends] : [];
|
|
31
|
+
for (const extPath of extendsPaths) {
|
|
32
|
+
let baseConfigPath;
|
|
33
|
+
if (extPath.startsWith(".")) baseConfigPath = (0, path.resolve)(configDir, extPath);
|
|
34
|
+
else {
|
|
35
|
+
baseConfigPath = findConfigFile((0, path.join)(configDir, "node_modules"), extPath);
|
|
36
|
+
if (!baseConfigPath) baseConfigPath = (0, module$1.createRequire)(require("url").pathToFileURL(__filename).href).resolve(extPath, { paths: [configDir] });
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
readFile: _readFile
|
|
45
|
-
};
|
|
46
|
-
const readTsConfig = (path$1) => {
|
|
47
|
-
const configFile = typescript.default.readConfigFile(path$1, _readFile);
|
|
48
|
-
if (configFile.error) throw new Error(typescript.default.formatDiagnostic(configFile.error, {
|
|
49
|
-
getCanonicalFileName: (f) => f,
|
|
50
|
-
getCurrentDirectory: () => process.cwd(),
|
|
51
|
-
getNewLine: () => "\n"
|
|
52
|
-
}));
|
|
53
|
-
return typescript.default.parseJsonConfigFileContent(configFile.config, _host, (0, path.dirname)(path$1));
|
|
38
|
+
if (baseConfigPath && (0, fs.existsSync)(baseConfigPath)) compilerOptions = {
|
|
39
|
+
...readTsConfig(baseConfigPath).compilerOptions,
|
|
40
|
+
...compilerOptions
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (compilerOptions.rootDir) compilerOptions.rootDir = (0, path.resolve)(configDir, compilerOptions.rootDir);
|
|
44
|
+
if (compilerOptions.outDir) compilerOptions.outDir = (0, path.resolve)(configDir, compilerOptions.outDir);
|
|
45
|
+
return { compilerOptions };
|
|
54
46
|
};
|
|
55
47
|
//#endregion
|
|
48
|
+
exports.findConfigFile = findConfigFile;
|
|
56
49
|
exports.readTsConfig = readTsConfig;
|
|
57
50
|
|
|
58
51
|
//# sourceMappingURL=typescript.config.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.config.cjs","names":["
|
|
1
|
+
{"version":3,"file":"typescript.config.cjs","names":["path"],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\n\nfunction stripComments(jsonString: string): string {\n return jsonString.replace(\n /\\\\\"|\"(?:\\\\\"|[^\"])*\"|(\\/\\/.*|\\/\\*[\\s\\S]*?\\*\\/)/g,\n (m, g) => (g ? '' : m),\n );\n}\n\nexport function findConfigFile(\n searchPath: string,\n configName: string = 'tsconfig.json',\n): string | undefined {\n let dir = searchPath;\n while (true) {\n const filePath = join(dir, configName);\n if (existsSync(filePath)) {\n return filePath;\n }\n const parentDir = dirname(dir);\n if (parentDir === dir) {\n break;\n }\n dir = parentDir;\n }\n return undefined;\n}\n\nexport const readTsConfig = (path: string): { compilerOptions: any } => {\n if (!existsSync(path)) {\n throw new Error(`tsconfig.json not found at ${path}`);\n }\n const content = readFileSync(path, 'utf-8');\n const cleanJson = stripComments(content);\n let config: any;\n try {\n config = JSON.parse(cleanJson);\n } catch (e: any) {\n throw new Error(\n `Failed to parse tsconfig.json at ${path}: ${e.message}`,\n { cause: e },\n );\n }\n\n let compilerOptions = config.compilerOptions || {};\n const configDir = dirname(path);\n\n const extendsPaths = Array.isArray(config.extends)\n ? config.extends\n : config.extends\n ? [config.extends]\n : [];\n\n for (const extPath of extendsPaths) {\n let baseConfigPath: string | undefined;\n if (extPath.startsWith('.')) {\n baseConfigPath = resolve(configDir, extPath);\n } else {\n baseConfigPath = findConfigFile(\n join(configDir, 'node_modules'),\n extPath,\n );\n if (!baseConfigPath) {\n baseConfigPath = createRequire(import.meta.url).resolve(extPath, {\n paths: [configDir],\n });\n }\n }\n\n if (baseConfigPath && existsSync(baseConfigPath)) {\n const baseConfig = readTsConfig(baseConfigPath);\n compilerOptions = {\n ...baseConfig.compilerOptions,\n ...compilerOptions,\n };\n }\n }\n\n if (compilerOptions.rootDir) {\n compilerOptions.rootDir = resolve(configDir, compilerOptions.rootDir);\n }\n\n if (compilerOptions.outDir) {\n compilerOptions.outDir = resolve(configDir, compilerOptions.outDir);\n }\n\n return { compilerOptions };\n};\n"],"mappings":";;;;;AAIA,SAAS,cAAc,YAA4B;CACjD,OAAO,WAAW,QAChB,mDACC,GAAG,MAAO,IAAI,KAAK,CACtB;AACF;AAEA,SAAgB,eACd,YACA,aAAqB,iBACD;CACpB,IAAI,MAAM;CACV,OAAO,MAAM;EACX,MAAM,YAAA,GAAA,KAAA,KAAA,CAAgB,KAAK,UAAU;EACrC,KAAA,GAAA,GAAA,WAAA,CAAe,QAAQ,GACrB,OAAO;EAET,MAAM,aAAA,GAAA,KAAA,QAAA,CAAoB,GAAG;EAC7B,IAAI,cAAc,KAChB;EAEF,MAAM;CACR;AAEF;AAEA,MAAa,gBAAgB,WAA2C;CACtE,IAAI,EAAA,GAAA,GAAA,WAAA,CAAYA,MAAI,GAClB,MAAM,IAAI,MAAM,8BAA8BA,QAAM;CAGtD,MAAM,YAAY,eAAA,GAAA,GAAA,aAAA,CADWA,QAAM,OACG,CAAC;CACvC,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,SAAS;CAC/B,SAAS,GAAQ;EACf,MAAM,IAAI,MACR,oCAAoCA,OAAK,IAAI,EAAE,WAC/C,EAAE,OAAO,EAAE,CACb;CACF;CAEA,IAAI,kBAAkB,OAAO,mBAAmB,CAAC;CACjD,MAAM,aAAA,GAAA,KAAA,QAAA,CAAoBA,MAAI;CAE9B,MAAM,eAAe,MAAM,QAAQ,OAAO,OAAO,IAC7C,OAAO,UACP,OAAO,UACL,CAAC,OAAO,OAAO,IACf,CAAC;CAEP,KAAK,MAAM,WAAW,cAAc;EAClC,IAAI;EACJ,IAAI,QAAQ,WAAW,GAAG,GACxB,kBAAA,GAAA,KAAA,QAAA,CAAyB,WAAW,OAAO;OACtC;GACL,iBAAiB,gBAAA,GAAA,KAAA,KAAA,CACV,WAAW,cAAc,GAC9B,OACF;GACA,IAAI,CAAC,gBACH,kBAAA,GAAA,SAAA,cAAA,CAAA,QAAA,KAAA,CAAA,CAAA,cAAA,UAAA,CAAA,CAAA,IAA8C,CAAC,CAAC,QAAQ,SAAS,EAC/D,OAAO,CAAC,SAAS,EACnB,CAAC;EAEL;EAEA,IAAI,mBAAA,GAAA,GAAA,WAAA,CAA6B,cAAc,GAE7C,kBAAkB;GAChB,GAFiB,aAAa,cAElB,CAAC,CAAC;GACd,GAAG;EACL;CAEJ;CAEA,IAAI,gBAAgB,SAClB,gBAAgB,WAAA,GAAA,KAAA,QAAA,CAAkB,WAAW,gBAAgB,OAAO;CAGtE,IAAI,gBAAgB,QAClB,gBAAgB,UAAA,GAAA,KAAA,QAAA,CAAiB,WAAW,gBAAgB,MAAM;CAGpE,OAAO,EAAE,gBAAgB;AAC3B"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const readTsConfig: (path: string) =>
|
|
1
|
+
export declare function findConfigFile(searchPath: string, configName?: string): string | undefined;
|
|
2
|
+
export declare const readTsConfig: (path: string) => {
|
|
3
|
+
compilerOptions: any;
|
|
4
|
+
};
|
|
@@ -1,55 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { createRequire } from "module";
|
|
2
|
+
import { existsSync, readFileSync } from "fs";
|
|
3
|
+
import { dirname, join, resolve } from "path";
|
|
4
4
|
//#region src/rolldown-config/plugins/typescript.config.ts
|
|
5
|
-
|
|
5
|
+
function stripComments(jsonString) {
|
|
6
|
+
return jsonString.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m);
|
|
7
|
+
}
|
|
8
|
+
function findConfigFile(searchPath, configName = "tsconfig.json") {
|
|
9
|
+
let dir = searchPath;
|
|
10
|
+
while (true) {
|
|
11
|
+
const filePath = join(dir, configName);
|
|
12
|
+
if (existsSync(filePath)) return filePath;
|
|
13
|
+
const parentDir = dirname(dir);
|
|
14
|
+
if (parentDir === dir) break;
|
|
15
|
+
dir = parentDir;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const readTsConfig = (path) => {
|
|
19
|
+
if (!existsSync(path)) throw new Error(`tsconfig.json not found at ${path}`);
|
|
20
|
+
const cleanJson = stripComments(readFileSync(path, "utf-8"));
|
|
21
|
+
let config;
|
|
6
22
|
try {
|
|
7
|
-
|
|
8
|
-
} catch {
|
|
9
|
-
|
|
23
|
+
config = JSON.parse(cleanJson);
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw new Error(`Failed to parse tsconfig.json at ${path}: ${e.message}`, { cause: e });
|
|
10
26
|
}
|
|
11
|
-
};
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
for (const entry of entries) {
|
|
23
|
-
const fullPath = join(dir, entry);
|
|
24
|
-
let stat;
|
|
25
|
-
try {
|
|
26
|
-
stat = statSync(fullPath);
|
|
27
|
-
} catch {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (stat.isDirectory()) walk(fullPath, currentDepth + 1);
|
|
31
|
-
else if (!extensions || extensions.some((ext) => entry.endsWith(ext))) results.push(fullPath);
|
|
27
|
+
let compilerOptions = config.compilerOptions || {};
|
|
28
|
+
const configDir = dirname(path);
|
|
29
|
+
const extendsPaths = Array.isArray(config.extends) ? config.extends : config.extends ? [config.extends] : [];
|
|
30
|
+
for (const extPath of extendsPaths) {
|
|
31
|
+
let baseConfigPath;
|
|
32
|
+
if (extPath.startsWith(".")) baseConfigPath = resolve(configDir, extPath);
|
|
33
|
+
else {
|
|
34
|
+
baseConfigPath = findConfigFile(join(configDir, "node_modules"), extPath);
|
|
35
|
+
if (!baseConfigPath) baseConfigPath = createRequire(import.meta.url).resolve(extPath, { paths: [configDir] });
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readFile: _readFile
|
|
42
|
-
};
|
|
43
|
-
const readTsConfig = (path) => {
|
|
44
|
-
const configFile = ts.readConfigFile(path, _readFile);
|
|
45
|
-
if (configFile.error) throw new Error(ts.formatDiagnostic(configFile.error, {
|
|
46
|
-
getCanonicalFileName: (f) => f,
|
|
47
|
-
getCurrentDirectory: () => process.cwd(),
|
|
48
|
-
getNewLine: () => "\n"
|
|
49
|
-
}));
|
|
50
|
-
return ts.parseJsonConfigFileContent(configFile.config, _host, dirname(path));
|
|
37
|
+
if (baseConfigPath && existsSync(baseConfigPath)) compilerOptions = {
|
|
38
|
+
...readTsConfig(baseConfigPath).compilerOptions,
|
|
39
|
+
...compilerOptions
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (compilerOptions.rootDir) compilerOptions.rootDir = resolve(configDir, compilerOptions.rootDir);
|
|
43
|
+
if (compilerOptions.outDir) compilerOptions.outDir = resolve(configDir, compilerOptions.outDir);
|
|
44
|
+
return { compilerOptions };
|
|
51
45
|
};
|
|
52
46
|
//#endregion
|
|
53
|
-
export { readTsConfig };
|
|
47
|
+
export { findConfigFile, readTsConfig };
|
|
54
48
|
|
|
55
49
|
//# sourceMappingURL=typescript.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync,
|
|
1
|
+
{"version":3,"file":"typescript.config.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.config.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\n\nfunction stripComments(jsonString: string): string {\n return jsonString.replace(\n /\\\\\"|\"(?:\\\\\"|[^\"])*\"|(\\/\\/.*|\\/\\*[\\s\\S]*?\\*\\/)/g,\n (m, g) => (g ? '' : m),\n );\n}\n\nexport function findConfigFile(\n searchPath: string,\n configName: string = 'tsconfig.json',\n): string | undefined {\n let dir = searchPath;\n while (true) {\n const filePath = join(dir, configName);\n if (existsSync(filePath)) {\n return filePath;\n }\n const parentDir = dirname(dir);\n if (parentDir === dir) {\n break;\n }\n dir = parentDir;\n }\n return undefined;\n}\n\nexport const readTsConfig = (path: string): { compilerOptions: any } => {\n if (!existsSync(path)) {\n throw new Error(`tsconfig.json not found at ${path}`);\n }\n const content = readFileSync(path, 'utf-8');\n const cleanJson = stripComments(content);\n let config: any;\n try {\n config = JSON.parse(cleanJson);\n } catch (e: any) {\n throw new Error(\n `Failed to parse tsconfig.json at ${path}: ${e.message}`,\n { cause: e },\n );\n }\n\n let compilerOptions = config.compilerOptions || {};\n const configDir = dirname(path);\n\n const extendsPaths = Array.isArray(config.extends)\n ? config.extends\n : config.extends\n ? [config.extends]\n : [];\n\n for (const extPath of extendsPaths) {\n let baseConfigPath: string | undefined;\n if (extPath.startsWith('.')) {\n baseConfigPath = resolve(configDir, extPath);\n } else {\n baseConfigPath = findConfigFile(\n join(configDir, 'node_modules'),\n extPath,\n );\n if (!baseConfigPath) {\n baseConfigPath = createRequire(import.meta.url).resolve(extPath, {\n paths: [configDir],\n });\n }\n }\n\n if (baseConfigPath && existsSync(baseConfigPath)) {\n const baseConfig = readTsConfig(baseConfigPath);\n compilerOptions = {\n ...baseConfig.compilerOptions,\n ...compilerOptions,\n };\n }\n }\n\n if (compilerOptions.rootDir) {\n compilerOptions.rootDir = resolve(configDir, compilerOptions.rootDir);\n }\n\n if (compilerOptions.outDir) {\n compilerOptions.outDir = resolve(configDir, compilerOptions.outDir);\n }\n\n return { compilerOptions };\n};\n"],"mappings":";;;;AAIA,SAAS,cAAc,YAA4B;CACjD,OAAO,WAAW,QAChB,mDACC,GAAG,MAAO,IAAI,KAAK,CACtB;AACF;AAEA,SAAgB,eACd,YACA,aAAqB,iBACD;CACpB,IAAI,MAAM;CACV,OAAO,MAAM;EACX,MAAM,WAAW,KAAK,KAAK,UAAU;EACrC,IAAI,WAAW,QAAQ,GACrB,OAAO;EAET,MAAM,YAAY,QAAQ,GAAG;EAC7B,IAAI,cAAc,KAChB;EAEF,MAAM;CACR;AAEF;AAEA,MAAa,gBAAgB,SAA2C;CACtE,IAAI,CAAC,WAAW,IAAI,GAClB,MAAM,IAAI,MAAM,8BAA8B,MAAM;CAGtD,MAAM,YAAY,cADF,aAAa,MAAM,OACG,CAAC;CACvC,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,SAAS;CAC/B,SAAS,GAAQ;EACf,MAAM,IAAI,MACR,oCAAoC,KAAK,IAAI,EAAE,WAC/C,EAAE,OAAO,EAAE,CACb;CACF;CAEA,IAAI,kBAAkB,OAAO,mBAAmB,CAAC;CACjD,MAAM,YAAY,QAAQ,IAAI;CAE9B,MAAM,eAAe,MAAM,QAAQ,OAAO,OAAO,IAC7C,OAAO,UACP,OAAO,UACL,CAAC,OAAO,OAAO,IACf,CAAC;CAEP,KAAK,MAAM,WAAW,cAAc;EAClC,IAAI;EACJ,IAAI,QAAQ,WAAW,GAAG,GACxB,iBAAiB,QAAQ,WAAW,OAAO;OACtC;GACL,iBAAiB,eACf,KAAK,WAAW,cAAc,GAC9B,OACF;GACA,IAAI,CAAC,gBACH,iBAAiB,cAAc,OAAO,KAAK,GAAG,CAAC,CAAC,QAAQ,SAAS,EAC/D,OAAO,CAAC,SAAS,EACnB,CAAC;EAEL;EAEA,IAAI,kBAAkB,WAAW,cAAc,GAE7C,kBAAkB;GAChB,GAFiB,aAAa,cAElB,CAAC,CAAC;GACd,GAAG;EACL;CAEJ;CAEA,IAAI,gBAAgB,SAClB,gBAAgB,UAAU,QAAQ,WAAW,gBAAgB,OAAO;CAGtE,IAAI,gBAAgB,QAClB,gBAAgB,SAAS,QAAQ,WAAW,gBAAgB,MAAM;CAGpE,OAAO,EAAE,gBAAgB;AAC3B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { RolldownPluginOption } from
|
|
1
|
+
import type { RolldownPluginOption } from "rolldown";
|
|
2
2
|
type Props = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exclude?: string | string[];
|
|
4
|
+
include?: Record<string, string>;
|
|
5
|
+
declarationMap?: boolean;
|
|
6
|
+
dir?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const typescript: ({ exclude, include, declarationMap, dir
|
|
8
|
+
export declare const typescript: ({ exclude, include, declarationMap, dir }?: Props) => RolldownPluginOption;
|
|
9
9
|
export {};
|