jiek 2.3.2 → 2.3.4
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/dist/.internal/.chunks/{filterSupport.4rM7f6jB.cjs → getWD.Bdo2NGCR.cjs} +30 -30
- package/dist/.internal/.chunks/{filterSupport.BXWpLBpT.js → getWD.DGvwAHMY.js} +29 -29
- package/dist/.internal/.chunks/{loadConfig.OOKddvHF.cjs → loadConfig.8xhNFEJe.cjs} +30 -12
- package/dist/.internal/.chunks/{loadConfig.CFfzkm_p.js → loadConfig.BjzxLOdC.js} +26 -9
- package/dist/.internal/bin/common.cjs +92 -97
- package/dist/.internal/bin/common.d.cts +2 -0
- package/dist/.internal/bin/common.d.ts +2 -0
- package/dist/.internal/bin/common.js +93 -98
- package/dist/.internal/bin/parseArgv.cjs +2 -2
- package/dist/.internal/bin/parseArgv.js +2 -2
- package/dist/.internal/commands/utils/createAreaManagement.cjs +108 -0
- package/dist/.internal/commands/utils/createAreaManagement.d.cts +18 -0
- package/dist/.internal/commands/utils/createAreaManagement.d.ts +18 -0
- package/dist/.internal/commands/utils/createAreaManagement.js +106 -0
- package/dist/.internal/polyfill.cjs +13 -0
- package/dist/.internal/polyfill.d.cts +1 -0
- package/dist/.internal/polyfill.d.ts +1 -0
- package/dist/.internal/polyfill.js +11 -0
- package/dist/.internal/rollup/base.d.cts +27 -4
- package/dist/.internal/rollup/base.d.ts +27 -4
- package/dist/.internal/utils/filterSupport.cjs +1 -1
- package/dist/.internal/utils/filterSupport.js +2 -2
- package/dist/.internal/utils/loadConfig.cjs +3 -3
- package/dist/.internal/utils/loadConfig.d.cts +1 -0
- package/dist/.internal/utils/loadConfig.d.ts +1 -0
- package/dist/.internal/utils/loadConfig.js +4 -4
- package/dist/.internal/utils/pascalCase.cjs +5 -0
- package/dist/.internal/utils/pascalCase.d.cts +3 -0
- package/dist/.internal/utils/pascalCase.d.ts +3 -0
- package/dist/.internal/utils/pascalCase.js +3 -0
- package/dist/.internal/utils/reveal.cjs +9 -0
- package/dist/.internal/utils/reveal.d.cts +3 -0
- package/dist/.internal/utils/reveal.d.ts +3 -0
- package/dist/.internal/utils/reveal.js +7 -0
- package/dist/bin/index.cjs +101 -43
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/rollup/index.cjs +91 -31
- package/dist/rollup/index.js +90 -30
- package/package.json +6 -2
- package/src/bin/build.cts +0 -5
- package/src/bin/common.ts +0 -3
- package/src/bin/index.cts +0 -7
- package/src/bin/parseArgv.ts +0 -26
- package/src/bridge.ts +0 -46
- package/src/commands/base.ts +0 -18
- package/src/commands/build/analyzer.ts +0 -122
- package/src/commands/build/client/analyzer.tsx +0 -121
- package/src/commands/build/client/index.ts +0 -26
- package/src/commands/build.ts +0 -544
- package/src/commands/descriptions.ts +0 -17
- package/src/commands/meta.ts +0 -5
- package/src/commands/publish.ts +0 -628
- package/src/commands/utils/optionParser.ts +0 -4
- package/src/index.ts +0 -12
- package/src/inner.ts +0 -11
- package/src/rollup/base.ts +0 -151
- package/src/rollup/bundle-analyzer.ts +0 -62
- package/src/rollup/index.ts +0 -892
- package/src/rollup/plugins/create-require.ts +0 -23
- package/src/rollup/plugins/progress.ts +0 -26
- package/src/rollup/plugins/replace.ts +0 -96
- package/src/rollup/plugins/skip.ts +0 -21
- package/src/rollup/plugins/with-external.ts +0 -23
- package/src/rollup/utils/commonOptions.ts +0 -9
- package/src/rollup/utils/externalResolver.ts +0 -47
- package/src/rollup/utils/globalResolver.ts +0 -13
- package/src/rollup/utils/withMinify.ts +0 -18
- package/src/rollup-plugin-utils.ts +0 -32
- package/src/server.ts +0 -30
- package/src/utils/checkDependency.ts +0 -26
- package/src/utils/filterSupport.ts +0 -90
- package/src/utils/getInternalModuleName.ts +0 -5
- package/src/utils/getRoot.ts +0 -14
- package/src/utils/getWD.ts +0 -31
- package/src/utils/intersection.ts +0 -1
- package/src/utils/loadConfig.ts +0 -108
- package/src/utils/recursiveListFiles.ts +0 -13
- package/src/utils/resolveExports.ts +0 -165
- package/src/utils/ts.ts +0 -94
- package/src/utils/tsRegister.ts +0 -22
@@ -1,165 +0,0 @@
|
|
1
|
-
import { isAbsolute, relative, resolve } from 'node:path'
|
2
|
-
import process from 'node:process'
|
3
|
-
|
4
|
-
import {
|
5
|
-
type Entrypoints2ExportsOptions,
|
6
|
-
type RecursiveRecord,
|
7
|
-
entrypoints2Exports,
|
8
|
-
filterLeafs,
|
9
|
-
getDefaultSkipValues,
|
10
|
-
resolveEntrypoints
|
11
|
-
} from '@jiek/pkger/entrypoints'
|
12
|
-
import type { Config } from 'jiek'
|
13
|
-
import { isMatch } from 'micromatch'
|
14
|
-
|
15
|
-
import { intersection } from '#~/utils/intersection'
|
16
|
-
|
17
|
-
const {
|
18
|
-
JIEK_OUT_DIR,
|
19
|
-
JIEK_CROSS_MODULE_CONVERTOR
|
20
|
-
} = process.env
|
21
|
-
|
22
|
-
const OUTDIR = JIEK_OUT_DIR ?? 'dist'
|
23
|
-
const crossModuleConvertorDefault = JIEK_CROSS_MODULE_CONVERTOR === undefined
|
24
|
-
? true
|
25
|
-
: JIEK_CROSS_MODULE_CONVERTOR === 'true'
|
26
|
-
|
27
|
-
export function getOutDirs({
|
28
|
-
cwd = process.cwd(),
|
29
|
-
defaultOutdir = OUTDIR,
|
30
|
-
config,
|
31
|
-
pkgName
|
32
|
-
}: {
|
33
|
-
cwd?: string
|
34
|
-
defaultOutdir?: string
|
35
|
-
config?: Config
|
36
|
-
pkgName?: string
|
37
|
-
}) {
|
38
|
-
const { build = {} } = config ?? {}
|
39
|
-
const outdir = build?.output?.dir
|
40
|
-
function resolveOutdir(type: 'js' | 'dts') {
|
41
|
-
const dir = (typeof outdir === 'object'
|
42
|
-
? outdir[type] ?? outdir[
|
43
|
-
({
|
44
|
-
js: 'dts',
|
45
|
-
dts: 'js'
|
46
|
-
} as const)[type]
|
47
|
-
]
|
48
|
-
: outdir) ?? defaultOutdir
|
49
|
-
return (
|
50
|
-
isAbsolute(dir)
|
51
|
-
? dir
|
52
|
-
: `./${relative(cwd, resolve(cwd, dir))}`
|
53
|
-
).replace('{{PKG_NAME}}', pkgName!)
|
54
|
-
}
|
55
|
-
return {
|
56
|
-
js: resolveOutdir('js'),
|
57
|
-
dts: resolveOutdir('dts')
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
export interface ResolveExportsOptions {
|
62
|
-
entrypoints: string | string[] | Record<string, unknown>
|
63
|
-
pkgName: string
|
64
|
-
pkgIsModule: boolean
|
65
|
-
entries?: string[]
|
66
|
-
config?: Config
|
67
|
-
dir?: string
|
68
|
-
outdir?: string
|
69
|
-
defaultOutdir?: string
|
70
|
-
noFilter?: boolean
|
71
|
-
isPublish?: boolean
|
72
|
-
skipJS?: boolean
|
73
|
-
}
|
74
|
-
|
75
|
-
export function resolveExports({
|
76
|
-
entrypoints,
|
77
|
-
pkgName,
|
78
|
-
pkgIsModule,
|
79
|
-
entries,
|
80
|
-
config,
|
81
|
-
dir,
|
82
|
-
defaultOutdir = OUTDIR,
|
83
|
-
// FIXME dts support
|
84
|
-
outdir = getOutDirs({ pkgName, defaultOutdir, config, cwd: dir }).js,
|
85
|
-
noFilter,
|
86
|
-
isPublish,
|
87
|
-
skipJS
|
88
|
-
}: ResolveExportsOptions) {
|
89
|
-
const {
|
90
|
-
build = {},
|
91
|
-
publish: {
|
92
|
-
withSuffix = false,
|
93
|
-
withSource = true
|
94
|
-
} = {}
|
95
|
-
} = config ?? {}
|
96
|
-
const {
|
97
|
-
crossModuleConvertor = crossModuleConvertorDefault
|
98
|
-
} = build
|
99
|
-
const [, resolvedEntrypoints] = resolveEntrypoints(entrypoints, {
|
100
|
-
allowJS: !skipJS
|
101
|
-
})
|
102
|
-
if (entries) {
|
103
|
-
Object
|
104
|
-
.entries(resolvedEntrypoints)
|
105
|
-
.forEach(([key]) => {
|
106
|
-
if (!entries.some(e => isMatch(key, e, { matchBase: true }))) {
|
107
|
-
delete resolvedEntrypoints[key]
|
108
|
-
}
|
109
|
-
})
|
110
|
-
}
|
111
|
-
const filteredResolvedEntrypoints = noFilter ? resolvedEntrypoints : filterLeafs(
|
112
|
-
resolvedEntrypoints as RecursiveRecord<string>,
|
113
|
-
{
|
114
|
-
skipValue: [
|
115
|
-
// ignore values that filename starts with `.jk-noentry`
|
116
|
-
/(^|\/)\.jk-noentry/,
|
117
|
-
...getDefaultSkipValues({
|
118
|
-
allowJS: !skipJS
|
119
|
-
})
|
120
|
-
]
|
121
|
-
}
|
122
|
-
)
|
123
|
-
const crossModuleWithConditional: Entrypoints2ExportsOptions['withConditional'] = crossModuleConvertor
|
124
|
-
? {
|
125
|
-
import: opts => {
|
126
|
-
if (pkgIsModule) return false
|
127
|
-
if (opts.src.endsWith('.cts')) return false
|
128
|
-
if (
|
129
|
-
intersection(
|
130
|
-
new Set(opts.conditionals),
|
131
|
-
new Set(['import', 'module'])
|
132
|
-
).size !== 0
|
133
|
-
) return false
|
134
|
-
|
135
|
-
return opts.dist.replace(/\.js$/, '.mjs')
|
136
|
-
},
|
137
|
-
require: opts => {
|
138
|
-
if (!pkgIsModule) return false
|
139
|
-
if (opts.src.endsWith('.mts')) return false
|
140
|
-
if (
|
141
|
-
intersection(
|
142
|
-
new Set(opts.conditionals),
|
143
|
-
new Set(['require', 'node'])
|
144
|
-
).size !== 0
|
145
|
-
) return false
|
146
|
-
|
147
|
-
return opts.dist.replace(/\.js$/, '.cjs')
|
148
|
-
}
|
149
|
-
}
|
150
|
-
: {}
|
151
|
-
return [
|
152
|
-
filteredResolvedEntrypoints,
|
153
|
-
entrypoints2Exports(filteredResolvedEntrypoints, {
|
154
|
-
outdir,
|
155
|
-
sourceTag: pkgName,
|
156
|
-
withSuffix: isPublish ? withSuffix : undefined,
|
157
|
-
withSource: isPublish ? withSource : undefined,
|
158
|
-
withConditional: {
|
159
|
-
...crossModuleWithConditional
|
160
|
-
},
|
161
|
-
allowJS: !skipJS
|
162
|
-
}),
|
163
|
-
outdir
|
164
|
-
] as const
|
165
|
-
}
|
package/src/utils/ts.ts
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
import fs from 'node:fs'
|
2
|
-
import { dirname, resolve } from 'node:path'
|
3
|
-
|
4
|
-
import { parse } from 'jsonc-parser'
|
5
|
-
import { isMatch } from 'micromatch'
|
6
|
-
|
7
|
-
interface TSConfig {
|
8
|
-
extends?: string | string[]
|
9
|
-
compilerOptions?: Record<string, unknown>
|
10
|
-
references?: { path: string }[]
|
11
|
-
files?: string[]
|
12
|
-
include?: string[]
|
13
|
-
exclude?: string[]
|
14
|
-
}
|
15
|
-
|
16
|
-
const getTSConfig = (p: string): TSConfig =>
|
17
|
-
!fs.existsSync(p) || !fs.statSync(p).isFile()
|
18
|
-
? {}
|
19
|
-
: parse(fs.readFileSync(p, 'utf-8'), [], { allowTrailingComma: true, allowEmptyContent: true }) as TSConfig
|
20
|
-
|
21
|
-
const getExtendTSConfig = (tsconfigPath: string): TSConfig => {
|
22
|
-
tsconfigPath = resolve(tsconfigPath)
|
23
|
-
const tsconfigPathDirname = dirname(tsconfigPath)
|
24
|
-
const { extends: exts, ...tsconfig } = getTSConfig(tsconfigPath)
|
25
|
-
const resolvePaths = (paths: string[] | undefined) => paths?.map(p => resolve(tsconfigPathDirname, p)) ?? []
|
26
|
-
|
27
|
-
const extendsPaths = resolvePaths(
|
28
|
-
exts !== undefined ? Array.isArray(exts) ? exts : [exts] : []
|
29
|
-
)
|
30
|
-
if (extendsPaths.length === 0) return tsconfig
|
31
|
-
return extendsPaths
|
32
|
-
.map(getExtendTSConfig)
|
33
|
-
.concat(tsconfig)
|
34
|
-
// https://www.typescriptlang.org/tsconfig/#files:~:text=Currently%2C%20the%20only%20top%2Dlevel%20property%20that%20is%20excluded%20from%20inheritance%20is%20references.
|
35
|
-
// Currently, the only top-level property that is excluded from inheritance is references.
|
36
|
-
.reduce((acc, { compilerOptions = {}, references: _, ...curr }) => ({
|
37
|
-
...acc,
|
38
|
-
...curr,
|
39
|
-
compilerOptions: {
|
40
|
-
...acc.compilerOptions,
|
41
|
-
...compilerOptions
|
42
|
-
}
|
43
|
-
}), {})
|
44
|
-
}
|
45
|
-
|
46
|
-
export const getCompilerOptionsByFilePath = (
|
47
|
-
tsconfigPath: string,
|
48
|
-
filePath: string
|
49
|
-
): Record<string, unknown> | undefined => {
|
50
|
-
tsconfigPath = resolve(tsconfigPath)
|
51
|
-
filePath = resolve(filePath)
|
52
|
-
const tsconfigPathDirname = dirname(tsconfigPath)
|
53
|
-
// https://www.typescriptlang.org/tsconfig/#files:~:text=It%E2%80%99s%20worth%20noting%20that%20files%2C%20include%2C%20and%20exclude%20from%20the%20inheriting%20config%20file%20overwrite%20those%20from%20the%20base%20config%20file%2C%20and%20that%20circularity%20between%20configuration%20files%20is%20not%20allowed.
|
54
|
-
// It’s worth noting that files, include, and exclude from the inheriting config file overwrite
|
55
|
-
// those from the base config file, and that circularity between configuration files is not allowed.
|
56
|
-
const tsconfig = getExtendTSConfig(tsconfigPath)
|
57
|
-
|
58
|
-
const resolvePaths = (paths: string[] | undefined) => paths?.map(p => resolve(tsconfigPathDirname, p)) ?? []
|
59
|
-
|
60
|
-
const [
|
61
|
-
references,
|
62
|
-
files,
|
63
|
-
include,
|
64
|
-
exclude
|
65
|
-
] = [
|
66
|
-
tsconfig.references?.map(({ path }) => path),
|
67
|
-
tsconfig.files,
|
68
|
-
tsconfig.include,
|
69
|
-
tsconfig.exclude
|
70
|
-
].map(resolvePaths)
|
71
|
-
if (exclude.length > 0 && exclude.some(i => isMatch(filePath, i))) return
|
72
|
-
|
73
|
-
// when files or include is not empty, the tsconfig should be ignored
|
74
|
-
if (tsconfig.files?.length === 0 && tsconfig.include?.length === 0) return
|
75
|
-
let isInclude = false
|
76
|
-
isInclude ||= files.length > 0 && files.includes(filePath)
|
77
|
-
isInclude ||= include.length > 0 && include.some(i => isMatch(filePath, i))
|
78
|
-
if (isInclude) {
|
79
|
-
return tsconfig.compilerOptions ?? {}
|
80
|
-
} else {
|
81
|
-
// when files or include is not empty, but the file is not matched, the tsconfig should be ignored
|
82
|
-
if (
|
83
|
-
(tsconfig.files && tsconfig.files.length > 0)
|
84
|
-
|| (tsconfig.include && tsconfig.include.length > 0)
|
85
|
-
) return
|
86
|
-
}
|
87
|
-
|
88
|
-
references.reverse()
|
89
|
-
for (const ref of references) {
|
90
|
-
const compilerOptions = getCompilerOptionsByFilePath(ref, filePath)
|
91
|
-
if (compilerOptions) return compilerOptions
|
92
|
-
}
|
93
|
-
return tsconfig.compilerOptions
|
94
|
-
}
|
package/src/utils/tsRegister.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
function packageIsExist(name: string) {
|
2
|
-
try {
|
3
|
-
require.resolve(name)
|
4
|
-
return true
|
5
|
-
} catch (e) {
|
6
|
-
return false
|
7
|
-
}
|
8
|
-
}
|
9
|
-
|
10
|
-
export let tsRegisterName: string | undefined
|
11
|
-
const registers = [
|
12
|
-
process.env.JIEK_TS_REGISTER,
|
13
|
-
'esbuild-register',
|
14
|
-
'@swc-node/register',
|
15
|
-
'ts-node/register'
|
16
|
-
].filter(Boolean) as string[]
|
17
|
-
for (const register of registers) {
|
18
|
-
if (packageIsExist(register)) {
|
19
|
-
tsRegisterName = register
|
20
|
-
break
|
21
|
-
}
|
22
|
-
}
|