jiek 2.3.3 → 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.
Files changed (77) hide show
  1. package/dist/.internal/.chunks/{filterSupport.4rM7f6jB.cjs → getWD.Bdo2NGCR.cjs} +30 -30
  2. package/dist/.internal/.chunks/{filterSupport.BXWpLBpT.js → getWD.DGvwAHMY.js} +29 -29
  3. package/dist/.internal/.chunks/{loadConfig.OOKddvHF.cjs → loadConfig.8xhNFEJe.cjs} +30 -12
  4. package/dist/.internal/.chunks/{loadConfig.CFfzkm_p.js → loadConfig.BjzxLOdC.js} +26 -9
  5. package/dist/.internal/bin/common.cjs +90 -97
  6. package/dist/.internal/bin/common.js +91 -98
  7. package/dist/.internal/bin/parseArgv.cjs +2 -2
  8. package/dist/.internal/bin/parseArgv.js +2 -2
  9. package/dist/.internal/commands/utils/createAreaManagement.cjs +108 -0
  10. package/dist/.internal/commands/utils/createAreaManagement.d.cts +18 -0
  11. package/dist/.internal/commands/utils/createAreaManagement.d.ts +18 -0
  12. package/dist/.internal/commands/utils/createAreaManagement.js +106 -0
  13. package/dist/.internal/polyfill.cjs +13 -0
  14. package/dist/.internal/polyfill.d.cts +1 -0
  15. package/dist/.internal/polyfill.d.ts +1 -0
  16. package/dist/.internal/polyfill.js +11 -0
  17. package/dist/.internal/utils/filterSupport.cjs +1 -1
  18. package/dist/.internal/utils/filterSupport.js +2 -2
  19. package/dist/.internal/utils/loadConfig.cjs +3 -3
  20. package/dist/.internal/utils/loadConfig.d.cts +1 -0
  21. package/dist/.internal/utils/loadConfig.d.ts +1 -0
  22. package/dist/.internal/utils/loadConfig.js +4 -4
  23. package/dist/.internal/utils/pascalCase.cjs +5 -0
  24. package/dist/.internal/utils/pascalCase.d.cts +3 -0
  25. package/dist/.internal/utils/pascalCase.d.ts +3 -0
  26. package/dist/.internal/utils/pascalCase.js +3 -0
  27. package/dist/.internal/utils/reveal.cjs +9 -0
  28. package/dist/.internal/utils/reveal.d.cts +3 -0
  29. package/dist/.internal/utils/reveal.d.ts +3 -0
  30. package/dist/.internal/utils/reveal.js +7 -0
  31. package/dist/bin/index.cjs +101 -43
  32. package/dist/index.d.cts +7 -0
  33. package/dist/index.d.ts +7 -0
  34. package/dist/rollup/index.cjs +16 -18
  35. package/dist/rollup/index.js +13 -15
  36. package/package.json +2 -2
  37. package/src/bin/build.cts +0 -5
  38. package/src/bin/common.ts +0 -3
  39. package/src/bin/index.cts +0 -7
  40. package/src/bin/parseArgv.ts +0 -26
  41. package/src/bridge.ts +0 -46
  42. package/src/commands/base.ts +0 -18
  43. package/src/commands/build/analyzer.ts +0 -122
  44. package/src/commands/build/client/analyzer.tsx +0 -121
  45. package/src/commands/build/client/index.ts +0 -26
  46. package/src/commands/build.ts +0 -544
  47. package/src/commands/descriptions.ts +0 -17
  48. package/src/commands/meta.ts +0 -5
  49. package/src/commands/publish.ts +0 -628
  50. package/src/commands/utils/optionParser.ts +0 -4
  51. package/src/index.ts +0 -12
  52. package/src/inner.ts +0 -11
  53. package/src/rollup/base.ts +0 -152
  54. package/src/rollup/bundle-analyzer.ts +0 -62
  55. package/src/rollup/index.ts +0 -893
  56. package/src/rollup/plugins/create-require.ts +0 -23
  57. package/src/rollup/plugins/progress.ts +0 -26
  58. package/src/rollup/plugins/replace.ts +0 -185
  59. package/src/rollup/plugins/skip.ts +0 -21
  60. package/src/rollup/plugins/with-external.ts +0 -23
  61. package/src/rollup/utils/commonOptions.ts +0 -9
  62. package/src/rollup/utils/externalResolver.ts +0 -47
  63. package/src/rollup/utils/globalResolver.ts +0 -13
  64. package/src/rollup/utils/withMinify.ts +0 -18
  65. package/src/rollup-plugin-utils.ts +0 -32
  66. package/src/server.ts +0 -30
  67. package/src/utils/checkDependency.ts +0 -26
  68. package/src/utils/filterSupport.ts +0 -90
  69. package/src/utils/getInternalModuleName.ts +0 -5
  70. package/src/utils/getRoot.ts +0 -14
  71. package/src/utils/getWD.ts +0 -31
  72. package/src/utils/intersection.ts +0 -1
  73. package/src/utils/loadConfig.ts +0 -108
  74. package/src/utils/recursiveListFiles.ts +0 -13
  75. package/src/utils/resolveExports.ts +0 -165
  76. package/src/utils/ts.ts +0 -94
  77. package/src/utils/tsRegister.ts +0 -22
@@ -1,108 +0,0 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
-
4
- import { program } from 'commander'
5
- import type { Config } from 'jiek'
6
- import { load } from 'js-yaml'
7
-
8
- import { getWD } from './getWD'
9
- import { tsRegisterName } from './tsRegister'
10
-
11
- let configName = 'jiek.config'
12
-
13
- function getConfigPath(root: string, dir?: string) {
14
- const isSupportTsLoader = !!tsRegisterName
15
- function configWithExtIsExist(ext: string) {
16
- const filenames = [
17
- path.resolve(process.cwd(), `${configName}.${ext}`),
18
- path.resolve(process.cwd(), `.${configName}.${ext}`),
19
- path.resolve(root, `${configName}.${ext}`),
20
- path.resolve(root, `.${configName}.${ext}`)
21
- ]
22
- if (dir) {
23
- filenames.unshift(...[
24
- path.resolve(dir, `${configName}.${ext}`),
25
- path.resolve(dir, `.${configName}.${ext}`)
26
- ])
27
- }
28
- for (const filename of filenames) {
29
- if (
30
- fs.existsSync(filename)
31
- && fs.lstatSync(filename)
32
- .isFile()
33
- ) {
34
- return filename
35
- }
36
- }
37
- return
38
- }
39
- configName = configWithExtIsExist('js') ?? configName
40
- configName = configWithExtIsExist('json') ?? configName
41
- configName = configWithExtIsExist('yaml') ?? configName
42
- if (isSupportTsLoader) {
43
- configName = configWithExtIsExist('ts') ?? configName
44
- }
45
- return path.resolve(root, configName)
46
- }
47
-
48
- interface LoadConfigOptions {
49
- dir?: string
50
- root?: string
51
- }
52
-
53
- export function loadConfig(options?: LoadConfigOptions): Config
54
- export function loadConfig(dir?: string): Config
55
- export function loadConfig(dirOrOptions?: string | LoadConfigOptions): Config {
56
- let dir: string | undefined
57
- let root: string
58
- if (typeof dirOrOptions === 'object') {
59
- dir = dirOrOptions.dir
60
- root = dirOrOptions.root ?? getWD().wd
61
- } else {
62
- dir = dirOrOptions
63
- root = getWD().wd
64
- }
65
-
66
- let configPath = program.getOptionValue('configPath')
67
-
68
- if (!configPath) {
69
- configPath = getConfigPath(root, dir)
70
- } else {
71
- if (!fs.existsSync(configPath)) {
72
- throw new Error(`config file not found: ${configPath}`)
73
- }
74
- if (!path.isAbsolute(configPath)) {
75
- configPath = path.resolve(root, configPath)
76
- }
77
- }
78
- const ext = path.extname(configPath)
79
-
80
- let module: any
81
- switch (ext) {
82
- case '.js':
83
- module = require(configPath)
84
- break
85
- case '.json':
86
- return require(configPath)
87
- case '.yaml':
88
- return load(fs.readFileSync(configPath, 'utf-8')) as Config
89
- case '.ts':
90
- if (tsRegisterName) {
91
- require(tsRegisterName)
92
- module = require(configPath)
93
- break
94
- }
95
- throw new Error(
96
- 'ts config file is not supported without ts register, '
97
- + 'please install esbuild-register or set JIEK_TS_REGISTER env for custom ts register'
98
- )
99
- case '.config':
100
- module = {}
101
- break
102
- default:
103
- throw new Error(`unsupported config file type: ${ext}`)
104
- }
105
- if (!module) throw new Error('config file is empty')
106
-
107
- return module.default ?? module
108
- }
@@ -1,13 +0,0 @@
1
- import fs from 'node:fs'
2
- import { resolve } from 'node:path'
3
-
4
- export const recursiveListFiles = (dir: string): string[] =>
5
- fs.readdirSync(dir).reduce((acc, file) => {
6
- const filePath = resolve(dir, file)
7
- if (fs.statSync(filePath).isDirectory()) {
8
- if (filePath.endsWith('/node_modules')) return acc
9
-
10
- return [...acc, ...recursiveListFiles(filePath)]
11
- }
12
- return [...acc, filePath]
13
- }, [] as string[])
@@ -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
- }
@@ -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
- }