jiek 2.2.7 → 2.3.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 +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} +229 -445
- package/dist/.internal/bin/common.d.cts +22 -0
- package/dist/.internal/bin/common.d.ts +22 -0
- package/dist/{cli-only-build.js → .internal/bin/common.js} +224 -439
- 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 +124 -0
- package/dist/.internal/utils/resolveExports.d.cts +27 -0
- package/dist/.internal/utils/resolveExports.d.ts +27 -0
- package/dist/.internal/utils/resolveExports.js +117 -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 +522 -0
- package/dist/index.d.cts +16 -114
- package/dist/index.d.ts +16 -114
- package/dist/rollup/index.cjs +310 -4573
- package/dist/rollup/index.d.cts +7 -1
- package/dist/rollup/index.d.ts +7 -1
- package/dist/rollup/index.js +298 -4558
- package/package.json +16 -24
- 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 +244 -213
- package/src/commands/meta.ts +1 -1
- package/src/commands/publish.ts +190 -78
- package/src/index.ts +6 -1
- package/src/rollup/base.ts +2 -2
- package/src/rollup/index.ts +361 -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} +28 -19
- 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
package/src/commands/build.ts
CHANGED
@@ -5,24 +5,30 @@ import process from 'node:process'
|
|
5
5
|
import { MultiBar, Presets } from 'cli-progress'
|
6
6
|
import { program } from 'commander'
|
7
7
|
import { execaCommand } from 'execa'
|
8
|
+
import type { Config } from 'jiek'
|
8
9
|
|
9
|
-
import type { RollupBuildEvent } from '#~/bridge
|
10
|
-
import type { AnalyzerBuildOptions } from '#~/commands/build/analyzer
|
11
|
-
import { registerAnalyzerCommandOptions, useAnalyzer } from '#~/commands/build/analyzer
|
12
|
-
import { entriesDescription, filterDescription, outdirDescription } from '#~/commands/descriptions
|
13
|
-
import { IS_WORKSPACE } from '#~/commands/meta
|
14
|
-
import { parseBoolean } from '#~/commands/utils/optionParser
|
15
|
-
import type { TemplateOptions } from '#~/rollup/base
|
16
|
-
import { BUILDER_TYPES, BUILDER_TYPE_PACKAGE_NAME_MAP } from '#~/rollup/base
|
17
|
-
import { createServer } from '#~/server
|
18
|
-
import { checkDependency } from '#~/utils/checkDependency
|
19
|
-
import type {
|
20
|
-
import { filterPackagesGraph, getSelectedProjectsGraph } from '#~/utils/filterSupport
|
21
|
-
import {
|
22
|
-
import {
|
10
|
+
import type { RollupBuildEvent } from '#~/bridge'
|
11
|
+
import type { AnalyzerBuildOptions } from '#~/commands/build/analyzer'
|
12
|
+
import { registerAnalyzerCommandOptions, useAnalyzer } from '#~/commands/build/analyzer'
|
13
|
+
import { entriesDescription, filterDescription, outdirDescription } from '#~/commands/descriptions'
|
14
|
+
import { IS_WORKSPACE } from '#~/commands/meta'
|
15
|
+
import { parseBoolean } from '#~/commands/utils/optionParser'
|
16
|
+
import type { TemplateOptions } from '#~/rollup/base'
|
17
|
+
import { BUILDER_TYPES, BUILDER_TYPE_PACKAGE_NAME_MAP } from '#~/rollup/base'
|
18
|
+
import { createServer } from '#~/server'
|
19
|
+
import { checkDependency } from '#~/utils/checkDependency'
|
20
|
+
import type { Manifest } from '#~/utils/filterSupport'
|
21
|
+
import { filterPackagesGraph, getSelectedProjectsGraph } from '#~/utils/filterSupport'
|
22
|
+
import { getWD } from '#~/utils/getWD'
|
23
|
+
import { loadConfig } from '#~/utils/loadConfig'
|
24
|
+
import { tsRegisterName } from '#~/utils/tsRegister'
|
23
25
|
|
24
26
|
declare module 'jiek' {
|
25
|
-
|
27
|
+
interface Config {
|
28
|
+
/**
|
29
|
+
* Skip entries which end with '.js'.
|
30
|
+
*/
|
31
|
+
skipJS?: boolean
|
26
32
|
build?: TemplateOptions & {
|
27
33
|
/**
|
28
34
|
* Whether to run in silent mode, only active when configured in the workspace root or cwd.
|
@@ -38,7 +44,11 @@ const FILE_TEMPLATE = (manifest: unknown) => (`
|
|
38
44
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
39
45
|
`.trimStart())
|
40
46
|
|
41
|
-
const
|
47
|
+
const ROLLUP_BIN = require
|
48
|
+
.resolve('rollup')
|
49
|
+
.replace(/dist\/rollup.js$/, 'dist/bin/rollup')
|
50
|
+
|
51
|
+
const isDefault = process.env.JIEK_BIN__FILENAME === 'build.cjs'
|
42
52
|
|
43
53
|
const description = `
|
44
54
|
Build the package according to the 'exports' field from the package.json.
|
@@ -46,7 +56,13 @@ If you want to through the options to the \`rollup\` command, you can pass the o
|
|
46
56
|
${isDefault ? 'This command is the default command.' : ''}
|
47
57
|
`.trim()
|
48
58
|
|
49
|
-
interface BuildOptions extends
|
59
|
+
interface BuildOptions extends
|
60
|
+
AnalyzerBuildOptions,
|
61
|
+
Pick<
|
62
|
+
Config,
|
63
|
+
'skipJS'
|
64
|
+
>
|
65
|
+
{
|
50
66
|
/**
|
51
67
|
* Auto-detect the builder from the installed dependencies.
|
52
68
|
* If the builder is not installed, it will prompt the user to install it.
|
@@ -102,6 +118,8 @@ interface BuildOptions extends AnalyzerBuildOptions {
|
|
102
118
|
* - ./tsconfig.dts.json
|
103
119
|
*/
|
104
120
|
dtsconfig?: string
|
121
|
+
|
122
|
+
'features.keepImportAttributes'?: boolean | 'assert'
|
105
123
|
}
|
106
124
|
|
107
125
|
let DEFAULT_BUILDER_TYPE: typeof BUILDER_TYPES[number]
|
@@ -143,8 +161,7 @@ let command = isDefault
|
|
143
161
|
command = command
|
144
162
|
.description(description)
|
145
163
|
.option('-t, --type <TYPE>', `The type of build, support ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}.`, v => {
|
146
|
-
|
147
|
-
if (!BUILDER_TYPES.includes(v as any)) {
|
164
|
+
if (!BUILDER_TYPES.includes(v as typeof BUILDER_TYPES[number])) {
|
148
165
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}`)
|
149
166
|
}
|
150
167
|
return String(v)
|
@@ -173,6 +190,12 @@ command = command
|
|
173
190
|
parseBoolean
|
174
191
|
)
|
175
192
|
|
193
|
+
command = command
|
194
|
+
.option('--skipJS', 'Skip entries which end with ".js".', parseBoolean)
|
195
|
+
|
196
|
+
command = command
|
197
|
+
.option('--features.keepImportAttributes', 'Keep the import attributes in the output.')
|
198
|
+
|
176
199
|
command = command
|
177
200
|
.option('--tsconfig <TSCONFIG>', 'The path of the tsconfig file which is used to generate js and dts files.', String)
|
178
201
|
.option('--dtsconfig <DTSCONFIG>', 'The path of the tsconfig file which is used to generate dts files.', String)
|
@@ -205,7 +228,8 @@ command
|
|
205
228
|
noClean,
|
206
229
|
onlyMin,
|
207
230
|
tsconfig,
|
208
|
-
dtsconfig
|
231
|
+
dtsconfig,
|
232
|
+
skipJS
|
209
233
|
} = options
|
210
234
|
const resolvedType = type ?? DEFAULT_BUILDER_TYPE
|
211
235
|
if (!withoutJs) {
|
@@ -277,6 +301,10 @@ command
|
|
277
301
|
JIEK_MINIFY_TYPE: minifyType,
|
278
302
|
JIEK_TSCONFIG: tsconfig,
|
279
303
|
JIEK_DTSCONFIG: dtsconfig,
|
304
|
+
JIEK_SKIP_JS: String(skipJS),
|
305
|
+
JIEK_FEATURES: JSON.stringify({
|
306
|
+
keepImportAttributes: options['features.keepImportAttributes']
|
307
|
+
}),
|
280
308
|
...process.env
|
281
309
|
}
|
282
310
|
|
@@ -286,201 +314,202 @@ command
|
|
286
314
|
format: '- {bar} | {status} | {pkgName} | {input} | {message}'
|
287
315
|
}, Presets.shades_classic)
|
288
316
|
|
289
|
-
const
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
mkdirSync(
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
try {
|
304
|
-
mkdirSync(jiekTemp)
|
305
|
-
} catch {}
|
317
|
+
const { wd } = getWD()
|
318
|
+
const wdNodeModules = path.resolve(wd, 'node_modules')
|
319
|
+
if (!existsSync(wdNodeModules)) {
|
320
|
+
mkdirSync(wdNodeModules)
|
321
|
+
}
|
322
|
+
const resolveByJiekTemp = (...paths: string[]) => path.resolve(wdNodeModules, '.jiek', ...paths)
|
323
|
+
const jiekTemp = resolveByJiekTemp()
|
324
|
+
if (!existsSync(jiekTemp)) {
|
325
|
+
try {
|
326
|
+
mkdirSync(jiekTemp)
|
327
|
+
} catch (e) {
|
328
|
+
if ((e as { code: string }).code !== 'EEXIST') {
|
329
|
+
throw e
|
330
|
+
}
|
306
331
|
}
|
332
|
+
}
|
307
333
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
334
|
+
let i = 0
|
335
|
+
const buildPackage = async ([pkgCWD, manifest]: [
|
336
|
+
string,
|
337
|
+
Manifest
|
338
|
+
], {
|
339
|
+
resolveByJiekTemp
|
340
|
+
}: {
|
341
|
+
resolveByJiekTemp: (...paths: string[]) => string
|
342
|
+
}) => {
|
343
|
+
if (manifest.name == null) {
|
344
|
+
throw new Error('package.json must have a name field')
|
345
|
+
}
|
316
346
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
path,
|
361
|
-
conditions
|
362
|
-
}))
|
363
|
-
)
|
364
|
-
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`
|
365
|
-
if (watch) {
|
366
|
-
initMessage += ' and watching...'
|
367
|
-
}
|
368
|
-
// eslint-disable-next-line no-console
|
369
|
-
console.log(initMessage)
|
370
|
-
leafs.forEach(({ input }) => {
|
371
|
-
inputMaxLen = Math.max(inputMaxLen, input.length)
|
372
|
-
})
|
373
|
-
leafs.forEach(({ input, path }) => {
|
374
|
-
const key = `${input}:${path}`
|
375
|
-
// eslint-disable-next-line ts/strict-boolean-expressions
|
376
|
-
if (bars[key]) return
|
377
|
-
bars[key] = multiBars.create(50, 0, {
|
378
|
-
pkgName: manifest.name,
|
379
|
-
input: input.padEnd(inputMaxLen + 5),
|
380
|
-
status: 'waiting'.padEnd(10)
|
381
|
-
}, {
|
382
|
-
barsize: 20,
|
383
|
-
linewrap: true
|
384
|
-
})
|
385
|
-
})
|
386
|
-
break
|
387
|
-
}
|
388
|
-
case 'progress': {
|
389
|
-
const {
|
390
|
-
path,
|
391
|
-
tags,
|
347
|
+
// TODO support auto build child packages in workspaces
|
348
|
+
const escapeManifestName = manifest.name.replace(/^@/g, '').replace(/\//g, '+')
|
349
|
+
const configFile = resolveByJiekTemp(
|
350
|
+
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
351
|
+
)
|
352
|
+
writeFileSync(configFile, FILE_TEMPLATE(manifest))
|
353
|
+
const command = [ROLLUP_BIN, '--silent', '-c', configFile]
|
354
|
+
if (tsRegisterName != null) {
|
355
|
+
command.unshift(`node -r ${tsRegisterName}`)
|
356
|
+
}
|
357
|
+
if (watch) {
|
358
|
+
command.push('--watch')
|
359
|
+
}
|
360
|
+
command.push(...passThroughOptions)
|
361
|
+
const child = execaCommand(command.join(' '), {
|
362
|
+
ipc: true,
|
363
|
+
cwd: pkgCWD,
|
364
|
+
windowsHide: true,
|
365
|
+
env: {
|
366
|
+
...env,
|
367
|
+
JIEK_NAME: manifest.name,
|
368
|
+
JIEK_ROOT: wd
|
369
|
+
}
|
370
|
+
})
|
371
|
+
const bars: Record<string, ReturnType<typeof multiBars.create>> = {}
|
372
|
+
const times: Record<string, number> = {}
|
373
|
+
const locks: Record<string, boolean> = {}
|
374
|
+
let inputMaxLen = 10
|
375
|
+
child.on('message', (e: RollupBuildEvent) => {
|
376
|
+
if (
|
377
|
+
silent && [
|
378
|
+
'init',
|
379
|
+
'progress',
|
380
|
+
'watchChange'
|
381
|
+
].includes(e.type)
|
382
|
+
) return
|
383
|
+
switch (e.type) {
|
384
|
+
case 'init': {
|
385
|
+
const { leafMap, targetsLength } = e.data
|
386
|
+
const leafs = Array
|
387
|
+
.from(leafMap.entries())
|
388
|
+
.flatMap(([input, pathAndConditions]) =>
|
389
|
+
pathAndConditions.map(([path, ...conditions]) => ({
|
392
390
|
input,
|
393
|
-
event,
|
394
|
-
message
|
395
|
-
} = e.data
|
396
|
-
const bar = bars[`${input}:${path}`]
|
397
|
-
// eslint-disable-next-line ts/strict-boolean-expressions
|
398
|
-
if (!bar) return
|
399
|
-
const time = times[`${input}:${path}`]
|
400
|
-
bar.update(
|
401
|
-
{
|
402
|
-
start: 0,
|
403
|
-
resolve: 20,
|
404
|
-
end: 50
|
405
|
-
}[event ?? 'start'] ?? 0,
|
406
|
-
{
|
407
|
-
input: (
|
408
|
-
time
|
409
|
-
? `${input}(x${time.toString().padStart(2, '0')})`
|
410
|
-
: input
|
411
|
-
).padEnd(inputMaxLen + 5),
|
412
|
-
status: event?.padEnd(10),
|
413
|
-
message: `${tags?.join(', ')}: ${message}`
|
414
|
-
}
|
415
|
-
)
|
416
|
-
break
|
417
|
-
}
|
418
|
-
case 'watchChange': {
|
419
|
-
const {
|
420
391
|
path,
|
421
|
-
|
422
|
-
}
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
let time = times[key] ?? 1
|
428
|
-
if (!locks[key]) {
|
429
|
-
time += 1
|
430
|
-
times[key] = time
|
431
|
-
setTimeout(() => {
|
432
|
-
locks[key] = false
|
433
|
-
}, 100)
|
434
|
-
bar.update(0, {
|
435
|
-
input: `${input}(x${time.toString().padStart(2, '0')})`.padEnd(inputMaxLen + 5),
|
436
|
-
status: 'watching'.padEnd(10),
|
437
|
-
message: 'watching...'
|
438
|
-
})
|
439
|
-
}
|
440
|
-
locks[key] = true
|
441
|
-
break
|
442
|
-
}
|
443
|
-
case 'modulesAnalyze': {
|
444
|
-
const {
|
445
|
-
data: {
|
446
|
-
type,
|
447
|
-
modules: pkgModules
|
448
|
-
}
|
449
|
-
} = e
|
450
|
-
void refreshAnalyzer(
|
451
|
-
pkgCWD,
|
452
|
-
pkgModules.map(m => ({
|
453
|
-
...m,
|
454
|
-
type,
|
455
|
-
filename: `${manifest.name}/${m.filename}`,
|
456
|
-
label: `${manifest.name}/${m.label}`
|
457
|
-
}))
|
458
|
-
)
|
459
|
-
break
|
460
|
-
}
|
461
|
-
case 'debug': {
|
462
|
-
// eslint-disable-next-line no-console,ts/no-unsafe-argument
|
463
|
-
console.log(...(Array.isArray(e.data) ? e.data : [e.data]))
|
464
|
-
break
|
465
|
-
}
|
466
|
-
default:
|
392
|
+
conditions
|
393
|
+
}))
|
394
|
+
)
|
395
|
+
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`
|
396
|
+
if (watch) {
|
397
|
+
initMessage += ' and watching...'
|
467
398
|
}
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
399
|
+
// eslint-disable-next-line no-console
|
400
|
+
console.log(initMessage)
|
401
|
+
leafs.forEach(({ input }) => {
|
402
|
+
inputMaxLen = Math.max(inputMaxLen, input.length)
|
403
|
+
})
|
404
|
+
leafs.forEach(({ input, path }) => {
|
405
|
+
const key = `${input}:${path}`
|
406
|
+
// eslint-disable-next-line ts/strict-boolean-expressions
|
407
|
+
if (bars[key]) return
|
408
|
+
bars[key] = multiBars.create(50, 0, {
|
409
|
+
pkgName: manifest.name,
|
410
|
+
input: input.padEnd(inputMaxLen + 5),
|
411
|
+
status: 'waiting'.padEnd(10)
|
412
|
+
}, {
|
413
|
+
barsize: 20,
|
414
|
+
linewrap: true
|
415
|
+
})
|
475
416
|
})
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
417
|
+
break
|
418
|
+
}
|
419
|
+
case 'progress': {
|
420
|
+
const {
|
421
|
+
path,
|
422
|
+
tags,
|
423
|
+
input,
|
424
|
+
event,
|
425
|
+
message
|
426
|
+
} = e.data
|
427
|
+
const bar = bars[`${input}:${path}`]
|
428
|
+
// eslint-disable-next-line ts/strict-boolean-expressions
|
429
|
+
if (!bar) return
|
430
|
+
const time = times[`${input}:${path}`]
|
431
|
+
bar.update(
|
432
|
+
{
|
433
|
+
start: 0,
|
434
|
+
resolve: 20,
|
435
|
+
end: 50
|
436
|
+
}[event ?? 'start'] ?? 0,
|
437
|
+
{
|
438
|
+
input: (
|
439
|
+
time
|
440
|
+
? `${input}(x${time.toString().padStart(2, '0')})`
|
441
|
+
: input
|
442
|
+
).padEnd(inputMaxLen + 5),
|
443
|
+
status: event?.padEnd(10),
|
444
|
+
message: `${tags?.join(', ')}: ${message}`
|
445
|
+
}
|
446
|
+
)
|
447
|
+
break
|
448
|
+
}
|
449
|
+
case 'watchChange': {
|
450
|
+
const {
|
451
|
+
path,
|
452
|
+
input
|
453
|
+
} = e.data
|
454
|
+
const key = `${input}:${path}`
|
455
|
+
const bar = bars[key]
|
456
|
+
// eslint-disable-next-line ts/strict-boolean-expressions
|
457
|
+
if (!bar) return
|
458
|
+
let time = times[key] ?? 1
|
459
|
+
if (!locks[key]) {
|
460
|
+
time += 1
|
461
|
+
times[key] = time
|
462
|
+
setTimeout(() => {
|
463
|
+
locks[key] = false
|
464
|
+
}, 100)
|
465
|
+
bar.update(0, {
|
466
|
+
input: `${input}(x${time.toString().padStart(2, '0')})`.padEnd(inputMaxLen + 5),
|
467
|
+
status: 'watching'.padEnd(10),
|
468
|
+
message: 'watching...'
|
469
|
+
})
|
470
|
+
}
|
471
|
+
locks[key] = true
|
472
|
+
break
|
473
|
+
}
|
474
|
+
case 'modulesAnalyze': {
|
475
|
+
const {
|
476
|
+
data: {
|
477
|
+
type,
|
478
|
+
modules: pkgModules
|
479
|
+
}
|
480
|
+
} = e
|
481
|
+
void refreshAnalyzer(
|
482
|
+
pkgCWD,
|
483
|
+
pkgModules.map(m => ({
|
484
|
+
...m,
|
485
|
+
type,
|
486
|
+
filename: `${manifest.name}/${m.filename}`,
|
487
|
+
label: `${manifest.name}/${m.label}`
|
488
|
+
}))
|
489
|
+
)
|
490
|
+
break
|
491
|
+
}
|
492
|
+
case 'debug': {
|
493
|
+
// eslint-disable-next-line no-console,ts/no-unsafe-argument
|
494
|
+
console.log(...(Array.isArray(e.data) ? e.data : [e.data]))
|
495
|
+
break
|
496
|
+
}
|
497
|
+
default:
|
498
|
+
}
|
499
|
+
})
|
500
|
+
await new Promise<void>((resolve, reject) => {
|
501
|
+
let errorStr = `rollup build failed\n`
|
502
|
+
+ `package name: ${manifest.name}\n`
|
503
|
+
+ `cwd: ${pkgCWD}\n\n`
|
504
|
+
child.stderr?.on('data', (data) => {
|
505
|
+
errorStr += data
|
482
506
|
})
|
483
|
-
|
507
|
+
child.once('exit', (code) =>
|
508
|
+
code === 0
|
509
|
+
? resolve()
|
510
|
+
: reject(new Error(errorStr)))
|
511
|
+
verbose && child.stdout?.pipe(process.stdout)
|
512
|
+
})
|
484
513
|
}
|
485
514
|
|
486
515
|
const commandFilters = IS_WORKSPACE ? commandFiltersOrEntries : undefined
|
@@ -499,12 +528,14 @@ command
|
|
499
528
|
])
|
500
529
|
]
|
501
530
|
try {
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
531
|
+
const packages = (
|
532
|
+
filters.length > 0
|
533
|
+
? await filterPackagesGraph(filters)
|
534
|
+
: [await getSelectedProjectsGraph()]
|
535
|
+
).flatMap(({ value }) => Object.entries(value ?? {}))
|
536
|
+
await Promise.allSettled(
|
537
|
+
packages.map(async ([cwd, manifest]) => buildPackage([cwd, manifest], { resolveByJiekTemp }))
|
538
|
+
)
|
508
539
|
} finally {
|
509
540
|
multiBars.stop()
|
510
541
|
// eslint-disable-next-line no-console
|
package/src/commands/meta.ts
CHANGED