jiek 2.2.7 → 2.3.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/bin/build.cjs +2 -0
- package/bin/index.cjs +2 -0
- package/bin-helper/index.cjs +19 -31
- package/dist/.internal/.chunks/filterSupport.4rM7f6jB.cjs +114 -0
- package/dist/.internal/.chunks/filterSupport.BXWpLBpT.js +104 -0
- package/dist/{cli.js → .internal/.chunks/index.B6RQz1DZ.js} +1 -737
- package/dist/.internal/.chunks/index.BHuJRlvZ.js +9059 -0
- package/dist/.internal/.chunks/index.Daihq2aI.cjs +9071 -0
- package/dist/{cli.cjs → .internal/.chunks/index.DlHFuTjM.cjs} +1 -759
- package/dist/.internal/.chunks/loadConfig.CFfzkm_p.js +110 -0
- package/dist/.internal/.chunks/loadConfig.OOKddvHF.cjs +117 -0
- package/dist/{cli-only-build.cjs → .internal/bin/common.cjs} +225 -444
- package/dist/.internal/bin/common.d.cts +18 -0
- package/dist/.internal/bin/common.d.ts +18 -0
- package/dist/{cli-only-build.js → .internal/bin/common.js} +220 -438
- package/dist/.internal/bin/parseArgv.cjs +33 -0
- package/dist/.internal/bin/parseArgv.d.cts +5 -0
- package/dist/.internal/bin/parseArgv.d.ts +5 -0
- package/dist/.internal/bin/parseArgv.js +27 -0
- package/dist/.internal/bridge.cjs +30 -0
- package/dist/.internal/bridge.d.cts +39 -0
- package/dist/.internal/bridge.d.ts +39 -0
- package/dist/.internal/bridge.js +27 -0
- package/dist/.internal/rollup/base.cjs +10 -0
- package/dist/{cli-only-build.d.cts → .internal/rollup/base.d.cts} +8 -15
- package/dist/{cli-only-build.d.ts → .internal/rollup/base.d.ts} +8 -15
- package/dist/.internal/rollup/base.js +7 -0
- package/dist/.internal/rollup/bundle-analyzer.cjs +51 -0
- package/dist/.internal/rollup/bundle-analyzer.d.cts +92 -0
- package/dist/.internal/rollup/bundle-analyzer.d.ts +92 -0
- package/dist/.internal/rollup/bundle-analyzer.js +45 -0
- package/dist/.internal/utils/filterSupport.cjs +18 -0
- package/dist/.internal/utils/filterSupport.d.cts +15 -0
- package/dist/.internal/utils/filterSupport.d.ts +15 -0
- package/dist/.internal/utils/filterSupport.js +8 -0
- package/dist/.internal/utils/getInternalModuleName.cjs +5 -0
- package/dist/.internal/utils/getInternalModuleName.d.cts +3 -0
- package/dist/.internal/utils/getInternalModuleName.d.ts +3 -0
- package/dist/.internal/utils/getInternalModuleName.js +3 -0
- package/dist/.internal/utils/intersection.cjs +5 -0
- package/dist/.internal/utils/intersection.d.cts +3 -0
- package/dist/.internal/utils/intersection.d.ts +3 -0
- package/dist/.internal/utils/intersection.js +3 -0
- package/dist/.internal/utils/loadConfig.cjs +14 -0
- package/dist/.internal/utils/loadConfig.d.cts +10 -0
- package/dist/.internal/utils/loadConfig.d.ts +10 -0
- package/dist/.internal/utils/loadConfig.js +9 -0
- package/dist/.internal/utils/recursiveListFiles.cjs +19 -0
- package/dist/.internal/utils/recursiveListFiles.d.cts +3 -0
- package/dist/.internal/utils/recursiveListFiles.d.ts +3 -0
- package/dist/.internal/utils/recursiveListFiles.js +13 -0
- package/dist/.internal/utils/resolveExports.cjs +118 -0
- package/dist/.internal/utils/resolveExports.d.cts +26 -0
- package/dist/.internal/utils/resolveExports.d.ts +26 -0
- package/dist/.internal/utils/resolveExports.js +111 -0
- package/dist/.internal/utils/ts.cjs +68 -0
- package/dist/.internal/utils/ts.d.cts +3 -0
- package/dist/.internal/utils/ts.d.ts +3 -0
- package/dist/.internal/utils/ts.js +62 -0
- package/dist/bin/build.cjs +10 -0
- package/dist/bin/index.cjs +501 -0
- package/dist/index.d.cts +12 -114
- package/dist/index.d.ts +12 -114
- package/dist/rollup/index.cjs +280 -4573
- package/dist/rollup/index.d.cts +7 -1
- package/dist/rollup/index.d.ts +7 -1
- package/dist/rollup/index.js +268 -4558
- package/package.json +15 -23
- package/src/bin/build.cts +5 -0
- package/src/bin/common.ts +3 -0
- package/src/bin/index.cts +7 -0
- package/src/bridge.ts +1 -1
- package/src/commands/base.ts +3 -3
- package/src/commands/build/analyzer.ts +5 -5
- package/src/commands/build/client/analyzer.tsx +1 -1
- package/src/commands/build/client/index.ts +5 -7
- package/src/commands/build.ts +226 -211
- package/src/commands/meta.ts +1 -1
- package/src/commands/publish.ts +113 -32
- package/src/index.ts +6 -1
- package/src/rollup/base.ts +2 -2
- package/src/rollup/index.ts +321 -124
- package/src/rollup/plugins/with-external.ts +23 -0
- package/src/rollup/utils/externalResolver.ts +20 -8
- package/src/utils/checkDependency.ts +1 -1
- package/src/utils/filterSupport.ts +17 -16
- package/src/utils/getInternalModuleName.ts +5 -0
- package/src/utils/intersection.ts +1 -0
- package/src/utils/{recusiveListFiles.ts → recursiveListFiles.ts} +2 -2
- package/src/utils/{getExports.ts → resolveExports.ts} +16 -14
- package/bin/jiek-build.js +0 -16
- package/bin/jiek.js +0 -13
- package/cli/package.json +0 -1
- package/cli-only-build/package.json +0 -1
- package/dist/cli.d.cts +0 -14
- package/dist/cli.d.ts +0 -14
- package/src/cli-only-build.ts +0 -11
- package/src/cli.ts +0 -6
- /package/{src/bin/build.ts → .jiek-production-tag} +0 -0
- /package/src/{parseArgv.ts → bin/parseArgv.ts} +0 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
export { f as filterPackagesGraph, a as getSelectedProjectsGraph, t as type } from '../.chunks/filterSupport.BXWpLBpT.js';
|
2
|
+
import 'node:fs';
|
3
|
+
import 'node:path';
|
4
|
+
import 'node:process';
|
5
|
+
import 'commander';
|
6
|
+
import 'js-yaml';
|
7
|
+
import 'node:module';
|
8
|
+
import '@jiek/utils/getWorkspaceDir';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
require('../.chunks/filterSupport.4rM7f6jB.cjs');
|
4
|
+
require('node:fs');
|
5
|
+
require('node:path');
|
6
|
+
require('commander');
|
7
|
+
require('js-yaml');
|
8
|
+
var loadConfig = require('../.chunks/loadConfig.OOKddvHF.cjs');
|
9
|
+
require('node:process');
|
10
|
+
require('@jiek/utils/getWorkspaceDir');
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
exports.loadConfig = loadConfig.loadConfig;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import '../.chunks/filterSupport.BXWpLBpT.js';
|
2
|
+
import 'node:fs';
|
3
|
+
import 'node:path';
|
4
|
+
import 'commander';
|
5
|
+
import 'js-yaml';
|
6
|
+
export { l as loadConfig } from '../.chunks/loadConfig.CFfzkm_p.js';
|
7
|
+
import 'node:module';
|
8
|
+
import 'node:process';
|
9
|
+
import '@jiek/utils/getWorkspaceDir';
|
@@ -0,0 +1,19 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var fs = require('node:fs');
|
4
|
+
var path = require('node:path');
|
5
|
+
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
7
|
+
|
8
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
9
|
+
|
10
|
+
const recursiveListFiles = (dir) => fs__default.default.readdirSync(dir).reduce((acc, file) => {
|
11
|
+
const filePath = path.resolve(dir, file);
|
12
|
+
if (fs__default.default.statSync(filePath).isDirectory()) {
|
13
|
+
if (filePath.endsWith("/node_modules")) return acc;
|
14
|
+
return [...acc, ...recursiveListFiles(filePath)];
|
15
|
+
}
|
16
|
+
return [...acc, filePath];
|
17
|
+
}, []);
|
18
|
+
|
19
|
+
exports.recursiveListFiles = recursiveListFiles;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import fs from 'node:fs';
|
2
|
+
import { resolve } from 'node:path';
|
3
|
+
|
4
|
+
const recursiveListFiles = (dir) => fs.readdirSync(dir).reduce((acc, file) => {
|
5
|
+
const filePath = resolve(dir, file);
|
6
|
+
if (fs.statSync(filePath).isDirectory()) {
|
7
|
+
if (filePath.endsWith("/node_modules")) return acc;
|
8
|
+
return [...acc, ...recursiveListFiles(filePath)];
|
9
|
+
}
|
10
|
+
return [...acc, filePath];
|
11
|
+
}, []);
|
12
|
+
|
13
|
+
export { recursiveListFiles };
|
@@ -0,0 +1,118 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var path = require('node:path');
|
4
|
+
var process = require('node:process');
|
5
|
+
var entrypoints = require('@jiek/pkger/entrypoints');
|
6
|
+
var index = require('../.chunks/index.DlHFuTjM.cjs');
|
7
|
+
var intersection = require('./intersection.cjs');
|
8
|
+
require('util');
|
9
|
+
require('path');
|
10
|
+
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
12
|
+
|
13
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
14
|
+
|
15
|
+
const {
|
16
|
+
JIEK_OUT_DIR,
|
17
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
18
|
+
} = process__default.default.env;
|
19
|
+
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
20
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
21
|
+
function getOutDirs({
|
22
|
+
cwd = process__default.default.cwd(),
|
23
|
+
defaultOutdir = OUTDIR,
|
24
|
+
config,
|
25
|
+
pkgName
|
26
|
+
}) {
|
27
|
+
const { build = {} } = config ?? {};
|
28
|
+
const outdir = build?.output?.dir;
|
29
|
+
function resolveOutdir(type) {
|
30
|
+
const dir = (typeof outdir === "object" ? outdir[type] ?? outdir[{
|
31
|
+
js: "dts",
|
32
|
+
dts: "js"
|
33
|
+
}[type]] : outdir) ?? defaultOutdir;
|
34
|
+
return (path.isAbsolute(dir) ? dir : `./${path.relative(cwd, path.resolve(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
|
35
|
+
}
|
36
|
+
return {
|
37
|
+
js: resolveOutdir("js"),
|
38
|
+
dts: resolveOutdir("dts")
|
39
|
+
};
|
40
|
+
}
|
41
|
+
function resolveExports({
|
42
|
+
entrypoints: entrypoints$1,
|
43
|
+
pkgName,
|
44
|
+
pkgIsModule,
|
45
|
+
entries,
|
46
|
+
config,
|
47
|
+
dir,
|
48
|
+
defaultOutdir = OUTDIR,
|
49
|
+
// FIXME dts support
|
50
|
+
outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
|
51
|
+
noFilter,
|
52
|
+
isPublish
|
53
|
+
}) {
|
54
|
+
const {
|
55
|
+
build = {},
|
56
|
+
publish: {
|
57
|
+
withSuffix = false,
|
58
|
+
withSource = true
|
59
|
+
} = {}
|
60
|
+
} = config ?? {};
|
61
|
+
const {
|
62
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
63
|
+
} = build;
|
64
|
+
const [, resolvedEntrypoints] = entrypoints.resolveEntrypoints(entrypoints$1);
|
65
|
+
if (entries) {
|
66
|
+
Object.entries(resolvedEntrypoints).forEach(([key]) => {
|
67
|
+
if (!entries.some((e) => index.micromatchExports.isMatch(key, e, { matchBase: true }))) {
|
68
|
+
delete resolvedEntrypoints[key];
|
69
|
+
}
|
70
|
+
});
|
71
|
+
}
|
72
|
+
const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : entrypoints.filterLeafs(
|
73
|
+
resolvedEntrypoints,
|
74
|
+
{
|
75
|
+
skipValue: [
|
76
|
+
// ignore values that filename starts with `.jk-noentry`
|
77
|
+
/(^|\/)\.jk-noentry/,
|
78
|
+
...entrypoints.DEFAULT_SKIP_VALUES
|
79
|
+
]
|
80
|
+
}
|
81
|
+
);
|
82
|
+
const crossModuleWithConditional = crossModuleConvertor ? {
|
83
|
+
import: (opts) => {
|
84
|
+
if (pkgIsModule) return false;
|
85
|
+
if (opts.src.endsWith(".cts")) return false;
|
86
|
+
if (intersection.intersection(
|
87
|
+
new Set(opts.conditionals),
|
88
|
+
/* @__PURE__ */ new Set(["import", "module"])
|
89
|
+
).size !== 0) return false;
|
90
|
+
return opts.dist.replace(/\.js$/, ".mjs");
|
91
|
+
},
|
92
|
+
require: (opts) => {
|
93
|
+
if (!pkgIsModule) return false;
|
94
|
+
if (opts.src.endsWith(".mts")) return false;
|
95
|
+
if (intersection.intersection(
|
96
|
+
new Set(opts.conditionals),
|
97
|
+
/* @__PURE__ */ new Set(["require", "node"])
|
98
|
+
).size !== 0) return false;
|
99
|
+
return opts.dist.replace(/\.js$/, ".cjs");
|
100
|
+
}
|
101
|
+
} : {};
|
102
|
+
return [
|
103
|
+
filteredResolvedEntrypoints,
|
104
|
+
entrypoints.entrypoints2Exports(filteredResolvedEntrypoints, {
|
105
|
+
outdir,
|
106
|
+
sourceTag: pkgName,
|
107
|
+
withSuffix: isPublish ? withSuffix : void 0,
|
108
|
+
withSource: isPublish ? withSource : void 0,
|
109
|
+
withConditional: {
|
110
|
+
...crossModuleWithConditional
|
111
|
+
}
|
112
|
+
}),
|
113
|
+
outdir
|
114
|
+
];
|
115
|
+
}
|
116
|
+
|
117
|
+
exports.getOutDirs = getOutDirs;
|
118
|
+
exports.resolveExports = resolveExports;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Config } from 'jiek';
|
2
|
+
|
3
|
+
declare function getOutDirs({ cwd, defaultOutdir, config, pkgName }: {
|
4
|
+
cwd?: string;
|
5
|
+
defaultOutdir?: string;
|
6
|
+
config?: Config;
|
7
|
+
pkgName?: string;
|
8
|
+
}): {
|
9
|
+
js: string;
|
10
|
+
dts: string;
|
11
|
+
};
|
12
|
+
interface ResolveExportsOptions {
|
13
|
+
entrypoints: string | string[] | Record<string, unknown>;
|
14
|
+
pkgName: string;
|
15
|
+
pkgIsModule: boolean;
|
16
|
+
entries?: string[];
|
17
|
+
config?: Config;
|
18
|
+
dir?: string;
|
19
|
+
outdir?: string;
|
20
|
+
defaultOutdir?: string;
|
21
|
+
noFilter?: boolean;
|
22
|
+
isPublish?: boolean;
|
23
|
+
}
|
24
|
+
declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish }: ResolveExportsOptions): readonly [any, any, string];
|
25
|
+
|
26
|
+
export { type ResolveExportsOptions, getOutDirs, resolveExports };
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Config } from 'jiek';
|
2
|
+
|
3
|
+
declare function getOutDirs({ cwd, defaultOutdir, config, pkgName }: {
|
4
|
+
cwd?: string;
|
5
|
+
defaultOutdir?: string;
|
6
|
+
config?: Config;
|
7
|
+
pkgName?: string;
|
8
|
+
}): {
|
9
|
+
js: string;
|
10
|
+
dts: string;
|
11
|
+
};
|
12
|
+
interface ResolveExportsOptions {
|
13
|
+
entrypoints: string | string[] | Record<string, unknown>;
|
14
|
+
pkgName: string;
|
15
|
+
pkgIsModule: boolean;
|
16
|
+
entries?: string[];
|
17
|
+
config?: Config;
|
18
|
+
dir?: string;
|
19
|
+
outdir?: string;
|
20
|
+
defaultOutdir?: string;
|
21
|
+
noFilter?: boolean;
|
22
|
+
isPublish?: boolean;
|
23
|
+
}
|
24
|
+
declare function resolveExports({ entrypoints, pkgName, pkgIsModule, entries, config, dir, defaultOutdir, outdir, noFilter, isPublish }: ResolveExportsOptions): readonly [any, any, string];
|
25
|
+
|
26
|
+
export { type ResolveExportsOptions, getOutDirs, resolveExports };
|
@@ -0,0 +1,111 @@
|
|
1
|
+
import { isAbsolute, relative, resolve } from 'node:path';
|
2
|
+
import process from 'node:process';
|
3
|
+
import { resolveEntrypoints, filterLeafs, DEFAULT_SKIP_VALUES, entrypoints2Exports } from '@jiek/pkger/entrypoints';
|
4
|
+
import { m as micromatchExports } from '../.chunks/index.B6RQz1DZ.js';
|
5
|
+
import { intersection } from './intersection.js';
|
6
|
+
import 'util';
|
7
|
+
import 'path';
|
8
|
+
|
9
|
+
const {
|
10
|
+
JIEK_OUT_DIR,
|
11
|
+
JIEK_CROSS_MODULE_CONVERTOR
|
12
|
+
} = process.env;
|
13
|
+
const OUTDIR = JIEK_OUT_DIR ?? "dist";
|
14
|
+
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === void 0 ? true : JIEK_CROSS_MODULE_CONVERTOR === "true";
|
15
|
+
function getOutDirs({
|
16
|
+
cwd = process.cwd(),
|
17
|
+
defaultOutdir = OUTDIR,
|
18
|
+
config,
|
19
|
+
pkgName
|
20
|
+
}) {
|
21
|
+
const { build = {} } = config ?? {};
|
22
|
+
const outdir = build?.output?.dir;
|
23
|
+
function resolveOutdir(type) {
|
24
|
+
const dir = (typeof outdir === "object" ? outdir[type] ?? outdir[{
|
25
|
+
js: "dts",
|
26
|
+
dts: "js"
|
27
|
+
}[type]] : outdir) ?? defaultOutdir;
|
28
|
+
return (isAbsolute(dir) ? dir : `./${relative(cwd, resolve(cwd, dir))}`).replace("{{PKG_NAME}}", pkgName);
|
29
|
+
}
|
30
|
+
return {
|
31
|
+
js: resolveOutdir("js"),
|
32
|
+
dts: resolveOutdir("dts")
|
33
|
+
};
|
34
|
+
}
|
35
|
+
function resolveExports({
|
36
|
+
entrypoints,
|
37
|
+
pkgName,
|
38
|
+
pkgIsModule,
|
39
|
+
entries,
|
40
|
+
config,
|
41
|
+
dir,
|
42
|
+
defaultOutdir = OUTDIR,
|
43
|
+
// FIXME dts support
|
44
|
+
outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
|
45
|
+
noFilter,
|
46
|
+
isPublish
|
47
|
+
}) {
|
48
|
+
const {
|
49
|
+
build = {},
|
50
|
+
publish: {
|
51
|
+
withSuffix = false,
|
52
|
+
withSource = true
|
53
|
+
} = {}
|
54
|
+
} = config ?? {};
|
55
|
+
const {
|
56
|
+
crossModuleConvertor = crossModuleConvertorDefault
|
57
|
+
} = build;
|
58
|
+
const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints);
|
59
|
+
if (entries) {
|
60
|
+
Object.entries(resolvedEntrypoints).forEach(([key]) => {
|
61
|
+
if (!entries.some((e) => micromatchExports.isMatch(key, e, { matchBase: true }))) {
|
62
|
+
delete resolvedEntrypoints[key];
|
63
|
+
}
|
64
|
+
});
|
65
|
+
}
|
66
|
+
const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : filterLeafs(
|
67
|
+
resolvedEntrypoints,
|
68
|
+
{
|
69
|
+
skipValue: [
|
70
|
+
// ignore values that filename starts with `.jk-noentry`
|
71
|
+
/(^|\/)\.jk-noentry/,
|
72
|
+
...DEFAULT_SKIP_VALUES
|
73
|
+
]
|
74
|
+
}
|
75
|
+
);
|
76
|
+
const crossModuleWithConditional = crossModuleConvertor ? {
|
77
|
+
import: (opts) => {
|
78
|
+
if (pkgIsModule) return false;
|
79
|
+
if (opts.src.endsWith(".cts")) return false;
|
80
|
+
if (intersection(
|
81
|
+
new Set(opts.conditionals),
|
82
|
+
/* @__PURE__ */ new Set(["import", "module"])
|
83
|
+
).size !== 0) return false;
|
84
|
+
return opts.dist.replace(/\.js$/, ".mjs");
|
85
|
+
},
|
86
|
+
require: (opts) => {
|
87
|
+
if (!pkgIsModule) return false;
|
88
|
+
if (opts.src.endsWith(".mts")) return false;
|
89
|
+
if (intersection(
|
90
|
+
new Set(opts.conditionals),
|
91
|
+
/* @__PURE__ */ new Set(["require", "node"])
|
92
|
+
).size !== 0) return false;
|
93
|
+
return opts.dist.replace(/\.js$/, ".cjs");
|
94
|
+
}
|
95
|
+
} : {};
|
96
|
+
return [
|
97
|
+
filteredResolvedEntrypoints,
|
98
|
+
entrypoints2Exports(filteredResolvedEntrypoints, {
|
99
|
+
outdir,
|
100
|
+
sourceTag: pkgName,
|
101
|
+
withSuffix: isPublish ? withSuffix : void 0,
|
102
|
+
withSource: isPublish ? withSource : void 0,
|
103
|
+
withConditional: {
|
104
|
+
...crossModuleWithConditional
|
105
|
+
}
|
106
|
+
}),
|
107
|
+
outdir
|
108
|
+
];
|
109
|
+
}
|
110
|
+
|
111
|
+
export { getOutDirs, resolveExports };
|
@@ -0,0 +1,68 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var fs = require('node:fs');
|
4
|
+
var path = require('node:path');
|
5
|
+
var jsoncParser = require('jsonc-parser');
|
6
|
+
var index = require('../.chunks/index.DlHFuTjM.cjs');
|
7
|
+
require('util');
|
8
|
+
require('path');
|
9
|
+
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
11
|
+
|
12
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
13
|
+
|
14
|
+
const getTSConfig = (p) => !fs__default.default.existsSync(p) || !fs__default.default.statSync(p).isFile() ? {} : jsoncParser.parse(fs__default.default.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
|
15
|
+
const getExtendTSConfig = (tsconfigPath) => {
|
16
|
+
tsconfigPath = path.resolve(tsconfigPath);
|
17
|
+
const tsconfigPathDirname = path.dirname(tsconfigPath);
|
18
|
+
const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
|
19
|
+
const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
|
20
|
+
const extendsPaths = resolvePaths(
|
21
|
+
exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
|
22
|
+
);
|
23
|
+
if (extendsPaths.length === 0) return tsconfig;
|
24
|
+
return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
|
25
|
+
...acc,
|
26
|
+
...curr,
|
27
|
+
compilerOptions: {
|
28
|
+
...acc.compilerOptions,
|
29
|
+
...compilerOptions
|
30
|
+
}
|
31
|
+
}), {});
|
32
|
+
};
|
33
|
+
const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
34
|
+
tsconfigPath = path.resolve(tsconfigPath);
|
35
|
+
filePath = path.resolve(filePath);
|
36
|
+
const tsconfigPathDirname = path.dirname(tsconfigPath);
|
37
|
+
const tsconfig = getExtendTSConfig(tsconfigPath);
|
38
|
+
const resolvePaths = (paths) => paths?.map((p) => path.resolve(tsconfigPathDirname, p)) ?? [];
|
39
|
+
const [
|
40
|
+
references,
|
41
|
+
files,
|
42
|
+
include,
|
43
|
+
exclude
|
44
|
+
] = [
|
45
|
+
tsconfig.references?.map(({ path }) => path),
|
46
|
+
tsconfig.files,
|
47
|
+
tsconfig.include,
|
48
|
+
tsconfig.exclude
|
49
|
+
].map(resolvePaths);
|
50
|
+
if (exclude.length > 0 && exclude.some((i) => index.micromatchExports.isMatch(filePath, i))) return;
|
51
|
+
if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
|
52
|
+
let isInclude = false;
|
53
|
+
isInclude || (isInclude = files.length > 0 && files.includes(filePath));
|
54
|
+
isInclude || (isInclude = include.length > 0 && include.some((i) => index.micromatchExports.isMatch(filePath, i)));
|
55
|
+
if (isInclude) {
|
56
|
+
return tsconfig.compilerOptions ?? {};
|
57
|
+
} else {
|
58
|
+
if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0) return;
|
59
|
+
}
|
60
|
+
references.reverse();
|
61
|
+
for (const ref of references) {
|
62
|
+
const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
|
63
|
+
if (compilerOptions) return compilerOptions;
|
64
|
+
}
|
65
|
+
return tsconfig.compilerOptions;
|
66
|
+
};
|
67
|
+
|
68
|
+
exports.getCompilerOptionsByFilePath = getCompilerOptionsByFilePath;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import fs from 'node:fs';
|
2
|
+
import { resolve, dirname } from 'node:path';
|
3
|
+
import { parse } from 'jsonc-parser';
|
4
|
+
import { m as micromatchExports } from '../.chunks/index.B6RQz1DZ.js';
|
5
|
+
import 'util';
|
6
|
+
import 'path';
|
7
|
+
|
8
|
+
const getTSConfig = (p) => !fs.existsSync(p) || !fs.statSync(p).isFile() ? {} : parse(fs.readFileSync(p, "utf-8"), [], { allowTrailingComma: true, allowEmptyContent: true });
|
9
|
+
const getExtendTSConfig = (tsconfigPath) => {
|
10
|
+
tsconfigPath = resolve(tsconfigPath);
|
11
|
+
const tsconfigPathDirname = dirname(tsconfigPath);
|
12
|
+
const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath);
|
13
|
+
const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
|
14
|
+
const extendsPaths = resolvePaths(
|
15
|
+
exts !== void 0 ? Array.isArray(exts) ? exts : [exts] : []
|
16
|
+
);
|
17
|
+
if (extendsPaths.length === 0) return tsconfig;
|
18
|
+
return extendsPaths.map(getExtendTSConfig).concat(tsconfig).reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
|
19
|
+
...acc,
|
20
|
+
...curr,
|
21
|
+
compilerOptions: {
|
22
|
+
...acc.compilerOptions,
|
23
|
+
...compilerOptions
|
24
|
+
}
|
25
|
+
}), {});
|
26
|
+
};
|
27
|
+
const getCompilerOptionsByFilePath = (tsconfigPath, filePath) => {
|
28
|
+
tsconfigPath = resolve(tsconfigPath);
|
29
|
+
filePath = resolve(filePath);
|
30
|
+
const tsconfigPathDirname = dirname(tsconfigPath);
|
31
|
+
const tsconfig = getExtendTSConfig(tsconfigPath);
|
32
|
+
const resolvePaths = (paths) => paths?.map((p) => resolve(tsconfigPathDirname, p)) ?? [];
|
33
|
+
const [
|
34
|
+
references,
|
35
|
+
files,
|
36
|
+
include,
|
37
|
+
exclude
|
38
|
+
] = [
|
39
|
+
tsconfig.references?.map(({ path }) => path),
|
40
|
+
tsconfig.files,
|
41
|
+
tsconfig.include,
|
42
|
+
tsconfig.exclude
|
43
|
+
].map(resolvePaths);
|
44
|
+
if (exclude.length > 0 && exclude.some((i) => micromatchExports.isMatch(filePath, i))) return;
|
45
|
+
if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return;
|
46
|
+
let isInclude = false;
|
47
|
+
isInclude || (isInclude = files.length > 0 && files.includes(filePath));
|
48
|
+
isInclude || (isInclude = include.length > 0 && include.some((i) => micromatchExports.isMatch(filePath, i)));
|
49
|
+
if (isInclude) {
|
50
|
+
return tsconfig.compilerOptions ?? {};
|
51
|
+
} else {
|
52
|
+
if (tsconfig.files && tsconfig.files.length > 0 || tsconfig.include && tsconfig.include.length > 0) return;
|
53
|
+
}
|
54
|
+
references.reverse();
|
55
|
+
for (const ref of references) {
|
56
|
+
const compilerOptions = getCompilerOptionsByFilePath(ref, filePath);
|
57
|
+
if (compilerOptions) return compilerOptions;
|
58
|
+
}
|
59
|
+
return tsconfig.compilerOptions;
|
60
|
+
};
|
61
|
+
|
62
|
+
export { getCompilerOptionsByFilePath };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
require('#~/bin/common');
|
4
|
+
var parseArgv = require('#~/bin/parseArgv');
|
5
|
+
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
7
|
+
|
8
|
+
var parseArgv__default = /*#__PURE__*/_interopDefault(parseArgv);
|
9
|
+
|
10
|
+
parseArgv__default.default();
|