jiek 2.2.6 → 2.2.7-alpha.3
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 +31 -0
- package/bin-helper/index.d.cts +1 -0
- package/bin-helper/index.d.ts +1 -0
- package/bin-helper/package.json +5 -1
- package/dist/.internal/.chunks/getWD.D6wq8Qc2.js +95 -0
- package/dist/.internal/.chunks/getWD.ZF0avqDB.cjs +105 -0
- package/dist/{cli.js → .internal/.chunks/index.B6RQz1DZ.js} +1 -735
- package/dist/{cli.cjs → .internal/.chunks/index.DlHFuTjM.cjs} +1 -757
- package/dist/.internal/.chunks/jiek_create-require.CWFWNQHj.cjs +5 -0
- package/dist/.internal/.chunks/jiek_create-require.CxSGbkTB.js +5 -0
- 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 +12 -0
- package/dist/.internal/bridge.d.cts +39 -0
- package/dist/.internal/bridge.d.ts +39 -0
- package/dist/.internal/bridge.js +9 -0
- package/dist/.internal/commands/build/analyzer.cjs +201 -0
- package/dist/.internal/commands/build/analyzer.d.cts +30 -0
- package/dist/.internal/commands/build/analyzer.d.ts +30 -0
- package/dist/.internal/commands/build/analyzer.js +195 -0
- package/dist/.internal/commands/descriptions.cjs +21 -0
- package/dist/.internal/commands/descriptions.d.cts +5 -0
- package/dist/.internal/commands/descriptions.d.ts +5 -0
- package/dist/.internal/commands/descriptions.js +17 -0
- package/dist/.internal/commands/meta.cjs +16 -0
- package/dist/.internal/commands/meta.d.cts +3 -0
- package/dist/.internal/commands/meta.d.ts +3 -0
- package/dist/.internal/commands/meta.js +15 -0
- package/dist/.internal/commands/utils/optionParser.cjs +8 -0
- package/dist/.internal/commands/utils/optionParser.d.cts +3 -0
- package/dist/.internal/commands/utils/optionParser.d.ts +3 -0
- package/dist/.internal/commands/utils/optionParser.js +6 -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/server.cjs +33 -0
- package/dist/.internal/server.d.cts +8 -0
- package/dist/.internal/server.d.ts +8 -0
- package/dist/.internal/server.js +27 -0
- package/dist/.internal/utils/checkDependency.cjs +39 -0
- package/dist/.internal/utils/checkDependency.d.cts +3 -0
- package/dist/.internal/utils/checkDependency.d.ts +3 -0
- package/dist/.internal/utils/checkDependency.js +34 -0
- package/dist/.internal/utils/filterSupport.cjs +20 -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 +10 -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/getRoot.cjs +17 -0
- package/dist/.internal/utils/getRoot.d.cts +3 -0
- package/dist/.internal/utils/getRoot.d.ts +3 -0
- package/dist/.internal/utils/getRoot.js +11 -0
- package/dist/.internal/utils/getWD.cjs +15 -0
- package/dist/.internal/utils/getWD.d.cts +6 -0
- package/dist/.internal/utils/getWD.d.ts +6 -0
- package/dist/.internal/utils/getWD.js +10 -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 +100 -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 +94 -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/.internal/utils/tsRegister.cjs +25 -0
- package/dist/.internal/utils/tsRegister.d.cts +3 -0
- package/dist/.internal/utils/tsRegister.d.ts +3 -0
- package/dist/.internal/utils/tsRegister.js +26 -0
- package/dist/bin/build.cjs +515 -0
- package/dist/bin/index.cjs +497 -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 +20 -26
- package/src/bin/build.cts +11 -0
- package/src/bin/index.cts +6 -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 +112 -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/bin-helper.cjs +0 -43
- package/cli/package.json +0 -1
- package/cli-only-build/package.json +0 -1
- package/dist/cli-only-build.cjs +0 -977
- package/dist/cli-only-build.js +0 -969
- package/dist/cli.d.cts +0 -14
- package/dist/cli.d.ts +0 -14
- package/src/bin/build.ts +0 -0
- package/src/cli-only-build.ts +0 -11
- package/src/cli.ts +0 -6
- /package/{bin-helper.js → bin-helper/index.js} +0 -0
- /package/src/{parseArgv.ts → bin/parseArgv.ts} +0 -0
@@ -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,25 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var jiek_createRequire = require('../.chunks/jiek_create-require.CWFWNQHj.cjs');
|
4
|
+
|
5
|
+
function packageIsExist(name) {
|
6
|
+
try {
|
7
|
+
jiek_createRequire.require.resolve(name);
|
8
|
+
return true;
|
9
|
+
} catch (e) {
|
10
|
+
return false;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
exports.tsRegisterName = void 0;
|
14
|
+
const registers = [
|
15
|
+
process.env.JIEK_TS_REGISTER,
|
16
|
+
"esbuild-register",
|
17
|
+
"@swc-node/register",
|
18
|
+
"ts-node/register"
|
19
|
+
].filter(Boolean);
|
20
|
+
for (const register of registers) {
|
21
|
+
if (packageIsExist(register)) {
|
22
|
+
exports.tsRegisterName = register;
|
23
|
+
break;
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { r as require } from '../.chunks/jiek_create-require.CxSGbkTB.js';
|
2
|
+
import 'node:module';
|
3
|
+
|
4
|
+
function packageIsExist(name) {
|
5
|
+
try {
|
6
|
+
require.resolve(name);
|
7
|
+
return true;
|
8
|
+
} catch (e) {
|
9
|
+
return false;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
let tsRegisterName;
|
13
|
+
const registers = [
|
14
|
+
process.env.JIEK_TS_REGISTER,
|
15
|
+
"esbuild-register",
|
16
|
+
"@swc-node/register",
|
17
|
+
"ts-node/register"
|
18
|
+
].filter(Boolean);
|
19
|
+
for (const register of registers) {
|
20
|
+
if (packageIsExist(register)) {
|
21
|
+
tsRegisterName = register;
|
22
|
+
break;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
export { tsRegisterName };
|