jiek 2.2.5 → 2.2.7-alpha.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/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/+/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/.internal/getWD-BRJ3PK1S.js +105 -0
- package/dist/.internal/getWD-Cmxzjf-f.js +95 -0
- package/dist/{cli.js → .internal/index-B6RQz1DZ.js} +1 -731
- package/dist/{cli.cjs → .internal/index-DlHFuTjM.js} +1 -753
- package/dist/.internal/jiek_create-require-CWFWNQHj.js +5 -0
- package/dist/.internal/jiek_create-require-CxSGbkTB.js +5 -0
- package/dist/.internal/package.json +10 -0
- package/dist/bin/build.cjs +505 -0
- package/dist/bin/index.cjs +488 -0
- package/dist/index.d.cts +1 -113
- package/dist/index.d.ts +1 -113
- package/dist/rollup/index.cjs +282 -4569
- package/dist/rollup/index.d.cts +7 -1
- package/dist/rollup/index.d.ts +7 -1
- package/dist/rollup/index.js +270 -4554
- package/package.json +25 -28
- 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 +218 -209
- package/src/commands/meta.ts +1 -1
- package/src/commands/publish.ts +101 -31
- package/src/rollup/base.ts +2 -2
- package/src/rollup/index.ts +309 -115
- 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
package/src/commands/publish.ts
CHANGED
@@ -7,12 +7,16 @@ import process from 'node:process'
|
|
7
7
|
import { type BumperType, TAGS, bump } from '@jiek/utils/bumper'
|
8
8
|
import { program } from 'commander'
|
9
9
|
import detectIndent from 'detect-indent'
|
10
|
+
import type { JSONPath } from 'jsonc-parser'
|
10
11
|
import { applyEdits, modify } from 'jsonc-parser'
|
11
12
|
|
12
|
-
import type { ProjectsGraph } from '
|
13
|
-
import { getSelectedProjectsGraph } from '
|
14
|
-
import {
|
15
|
-
import {
|
13
|
+
import type { ProjectsGraph } from '#~/utils/filterSupport'
|
14
|
+
import { getSelectedProjectsGraph } from '#~/utils/filterSupport'
|
15
|
+
import { loadConfig } from '#~/utils/loadConfig'
|
16
|
+
import type { ResolveExportsOptions } from '#~/utils/resolveExports'
|
17
|
+
import { resolveExports } from '#~/utils/resolveExports'
|
18
|
+
|
19
|
+
import { getInternalModuleName } from '#~/utils/getInternalModuleName'
|
16
20
|
import { outdirDescription } from './descriptions'
|
17
21
|
|
18
22
|
declare module 'jiek' {
|
@@ -108,27 +112,44 @@ async function prepublish({ bumper }: {
|
|
108
112
|
)
|
109
113
|
|
110
114
|
const generateNewManifest = (dir: string, manifest: NonNullable<ProjectsGraph['value']>[string]) => {
|
111
|
-
const {
|
115
|
+
const {
|
116
|
+
name,
|
117
|
+
type,
|
118
|
+
exports: entrypoints = {},
|
119
|
+
imports: internalEntrypoints = {}
|
120
|
+
} = manifest
|
112
121
|
if (!name) {
|
113
122
|
throw new Error(`package.json in ${dir} must have a name field`)
|
114
123
|
}
|
115
124
|
|
116
125
|
const pkgIsModule = type === 'module'
|
117
126
|
const newManifest = { ...manifest }
|
118
|
-
const
|
119
|
-
entrypoints,
|
127
|
+
const commonOptions = {
|
120
128
|
pkgIsModule,
|
121
129
|
pkgName: name,
|
122
130
|
config: loadConfig(dir),
|
123
131
|
dir,
|
124
|
-
defaultOutdir: outdir,
|
125
132
|
noFilter: true,
|
126
133
|
isPublish: true
|
134
|
+
} satisfies Partial<ResolveExportsOptions>
|
135
|
+
const [resolvedEntrypoints, exports, resolvedOutdir] = resolveExports({
|
136
|
+
entrypoints,
|
137
|
+
defaultOutdir: outdir,
|
138
|
+
...commonOptions
|
127
139
|
})
|
128
140
|
newManifest.exports = {
|
129
141
|
...resolvedEntrypoints,
|
130
142
|
...exports
|
131
143
|
}
|
144
|
+
const [resolvedInternalEntrypoints, imports] = resolveExports({
|
145
|
+
entrypoints: internalEntrypoints,
|
146
|
+
defaultOutdir: `${outdir}/.internal`,
|
147
|
+
...commonOptions
|
148
|
+
})
|
149
|
+
newManifest.imports = {
|
150
|
+
...resolvedInternalEntrypoints,
|
151
|
+
...imports
|
152
|
+
}
|
132
153
|
return [newManifest, resolvedOutdir] as const
|
133
154
|
}
|
134
155
|
|
@@ -146,26 +167,33 @@ async function prepublish({ bumper }: {
|
|
146
167
|
insertSpaces: boolean
|
147
168
|
}
|
148
169
|
}) => {
|
170
|
+
const internalModuleName = getInternalModuleName(manifest.name!)
|
171
|
+
|
149
172
|
let newJSONString = oldJSONString
|
150
|
-
|
151
|
-
newJSONString
|
152
|
-
modify(
|
173
|
+
const update = (path: JSONPath, value: unknown) => {
|
174
|
+
newJSONString = applyEdits(
|
153
175
|
newJSONString,
|
154
|
-
|
155
|
-
{
|
156
|
-
'<5.0': {
|
157
|
-
'*': [
|
158
|
-
'*',
|
159
|
-
`./*`,
|
160
|
-
`./*/index.d.ts`,
|
161
|
-
`./*/index.d.mts`,
|
162
|
-
`./*/index.d.cts`
|
163
|
-
]
|
164
|
-
}
|
165
|
-
},
|
166
|
-
{ formattingOptions }
|
176
|
+
modify(newJSONString, path, value, { formattingOptions })
|
167
177
|
)
|
168
|
-
|
178
|
+
}
|
179
|
+
|
180
|
+
update(['publishConfig', 'typesVersions'], {
|
181
|
+
'<5.0': {
|
182
|
+
'*': [
|
183
|
+
'*',
|
184
|
+
'./*',
|
185
|
+
'./*/index.d.ts',
|
186
|
+
'./*/index.d.mts',
|
187
|
+
'./*/index.d.cts'
|
188
|
+
]
|
189
|
+
}
|
190
|
+
})
|
191
|
+
update(['dependencies', internalModuleName], `file:./${outdir}/.internal`)
|
192
|
+
update(['dependenciesMeta', internalModuleName], {
|
193
|
+
'injected': true
|
194
|
+
})
|
195
|
+
update(['imports'], undefined)
|
196
|
+
|
169
197
|
for (const [key, value] of Object.entries(manifest)) {
|
170
198
|
if (key === 'version') continue
|
171
199
|
if (JSON.stringify(value) === JSON.stringify(oldJSON[key])) continue
|
@@ -207,9 +235,13 @@ async function prepublish({ bumper }: {
|
|
207
235
|
const indexExports = index as Record<string, string>
|
208
236
|
indexPublishConfig.main = indexExports.require ?? indexExports.default
|
209
237
|
indexPublishConfig.module = indexExports.import ?? indexExports.module ?? indexExports.default
|
238
|
+
indexPublishConfig.types = indexExports.types
|
210
239
|
break
|
211
240
|
}
|
212
241
|
}
|
242
|
+
indexPublishConfig.types = indexPublishConfig[
|
243
|
+
manifest?.type === 'module' ? 'module' : 'main'
|
244
|
+
].replace(/\.([cm]?)js$/, '.d.$1ts')
|
213
245
|
for (const [k, v] of Object.entries(indexPublishConfig)) {
|
214
246
|
if (v === undefined) continue
|
215
247
|
newJSONString = applyEdits(
|
@@ -434,19 +466,57 @@ async function prepublish({ bumper }: {
|
|
434
466
|
}
|
435
467
|
throw new Error(`file type of ${path} is not supported`)
|
436
468
|
}
|
469
|
+
|
470
|
+
if ('imports' in manifest && manifest.imports) {
|
471
|
+
Object
|
472
|
+
.entries(manifest.imports)
|
473
|
+
.forEach(([key, value]) => {
|
474
|
+
if (typeof value !== 'object') return
|
475
|
+
const [start] = key.split('*')
|
476
|
+
manifest.imports![key] = JSON.parse(
|
477
|
+
JSON
|
478
|
+
.stringify(value)
|
479
|
+
.replaceAll(`${resolvedOutdir}/.internal/`, start)
|
480
|
+
)
|
481
|
+
})
|
482
|
+
fs.writeFileSync(
|
483
|
+
resolveByDir(resolvedOutdir, resolvedOutdir, '.internal', 'package.json'),
|
484
|
+
JSON.stringify(
|
485
|
+
{
|
486
|
+
name: getInternalModuleName(manifest.name!),
|
487
|
+
exports: JSON.parse(
|
488
|
+
JSON
|
489
|
+
.stringify(manifest.imports)
|
490
|
+
.replaceAll('#', './')
|
491
|
+
.replaceAll('~', '+')
|
492
|
+
) as Record<string, unknown>
|
493
|
+
},
|
494
|
+
null,
|
495
|
+
2
|
496
|
+
)
|
497
|
+
)
|
498
|
+
}
|
437
499
|
})
|
438
500
|
}
|
439
501
|
|
440
502
|
async function postpublish() {
|
441
503
|
await forEachSelectedProjectsGraphEntries(dir => {
|
442
504
|
const jiekTempDir = path.resolve(dir, 'node_modules/.jiek/.tmp')
|
443
|
-
const
|
444
|
-
const
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
505
|
+
const packageJSONPath = path.resolve(dir, 'package.json')
|
506
|
+
const { name, version } = JSON.parse(fs.readFileSync(packageJSONPath, 'utf-8')) as {
|
507
|
+
name: string
|
508
|
+
version: string
|
509
|
+
}
|
510
|
+
const jiekTempPackageJSONPath = path.resolve(jiekTempDir, 'package.json')
|
511
|
+
if (fs.existsSync(jiekTempPackageJSONPath)) {
|
512
|
+
fs.copyFileSync(jiekTempPackageJSONPath, packageJSONPath)
|
513
|
+
fs.rmSync(jiekTempPackageJSONPath)
|
514
|
+
/* eslint-disable no-console */
|
449
515
|
console.log(`${dir}/package.json has been restored`)
|
516
|
+
console.log(
|
517
|
+
`if you want to check the compatibility of the package, you can visit: https://arethetypeswrong.github.io/?p=${name}%40${version}`
|
518
|
+
)
|
519
|
+
/* eslint-enable no-console */
|
450
520
|
} else {
|
451
521
|
throw new Error(
|
452
522
|
`jiek temp \`${dir}/package.json\` not found, please confirm the jiek pre-publish command has been executed`
|
package/src/rollup/base.ts
CHANGED
@@ -54,9 +54,9 @@ export interface TemplateOptions {
|
|
54
54
|
* When use esbuild type builder, it will inject `supported.import-attributes` option.
|
55
55
|
* When use swc type builder, it will inject `jsc.experimental.keepImportAttributes` option.
|
56
56
|
*
|
57
|
-
* And it will auto set the rollup output externalImportAttributes and importAttributesKey options.
|
57
|
+
* And it will auto set the rollup output `externalImportAttributes` and `importAttributesKey` options.
|
58
58
|
*
|
59
|
-
* @default
|
59
|
+
* @default false
|
60
60
|
*/
|
61
61
|
keepImportAttributes?: boolean | 'assert'
|
62
62
|
}
|