jiek 2.2.7 → 2.3.0
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} +225 -444
- package/dist/.internal/bin/common.d.cts +18 -0
- package/dist/.internal/bin/common.d.ts +18 -0
- package/dist/{cli-only-build.js → .internal/bin/common.js} +220 -438
- 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 +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/bin/build.cjs +10 -0
- package/dist/bin/index.cjs +501 -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 +15 -23
- 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 +226 -211
- package/src/commands/meta.ts +1 -1
- package/src/commands/publish.ts +113 -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/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
@@ -6,23 +6,24 @@ import { MultiBar, Presets } from 'cli-progress'
|
|
6
6
|
import { program } from 'commander'
|
7
7
|
import { execaCommand } from 'execa'
|
8
8
|
|
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 {
|
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 { Manifest } from '#~/utils/filterSupport'
|
20
|
+
import { filterPackagesGraph, getSelectedProjectsGraph } from '#~/utils/filterSupport'
|
21
|
+
import { getWD } from '#~/utils/getWD'
|
22
|
+
import { loadConfig } from '#~/utils/loadConfig'
|
23
|
+
import { tsRegisterName } from '#~/utils/tsRegister'
|
23
24
|
|
24
25
|
declare module 'jiek' {
|
25
|
-
|
26
|
+
interface Config {
|
26
27
|
build?: TemplateOptions & {
|
27
28
|
/**
|
28
29
|
* Whether to run in silent mode, only active when configured in the workspace root or cwd.
|
@@ -38,7 +39,11 @@ const FILE_TEMPLATE = (manifest: unknown) => (`
|
|
38
39
|
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
39
40
|
`.trimStart())
|
40
41
|
|
41
|
-
const
|
42
|
+
const ROLLUP_BIN = require
|
43
|
+
.resolve('rollup')
|
44
|
+
.replace(/dist\/rollup.js$/, 'dist/bin/rollup')
|
45
|
+
|
46
|
+
const isDefault = process.env.JIEK_BIN__FILENAME === 'build.cjs'
|
42
47
|
|
43
48
|
const description = `
|
44
49
|
Build the package according to the 'exports' field from the package.json.
|
@@ -102,6 +107,8 @@ interface BuildOptions extends AnalyzerBuildOptions {
|
|
102
107
|
* - ./tsconfig.dts.json
|
103
108
|
*/
|
104
109
|
dtsconfig?: string
|
110
|
+
|
111
|
+
'features.keepImportAttributes'?: boolean | 'assert'
|
105
112
|
}
|
106
113
|
|
107
114
|
let DEFAULT_BUILDER_TYPE: typeof BUILDER_TYPES[number]
|
@@ -143,8 +150,7 @@ let command = isDefault
|
|
143
150
|
command = command
|
144
151
|
.description(description)
|
145
152
|
.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)) {
|
153
|
+
if (!BUILDER_TYPES.includes(v as typeof BUILDER_TYPES[number])) {
|
148
154
|
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}`)
|
149
155
|
}
|
150
156
|
return String(v)
|
@@ -173,6 +179,9 @@ command = command
|
|
173
179
|
parseBoolean
|
174
180
|
)
|
175
181
|
|
182
|
+
command = command
|
183
|
+
.option('--features.keepImportAttributes', 'Keep the import attributes in the output.')
|
184
|
+
|
176
185
|
command = command
|
177
186
|
.option('--tsconfig <TSCONFIG>', 'The path of the tsconfig file which is used to generate js and dts files.', String)
|
178
187
|
.option('--dtsconfig <DTSCONFIG>', 'The path of the tsconfig file which is used to generate dts files.', String)
|
@@ -277,6 +286,9 @@ command
|
|
277
286
|
JIEK_MINIFY_TYPE: minifyType,
|
278
287
|
JIEK_TSCONFIG: tsconfig,
|
279
288
|
JIEK_DTSCONFIG: dtsconfig,
|
289
|
+
JIEK_FEATURES: JSON.stringify({
|
290
|
+
keepImportAttributes: options['features.keepImportAttributes']
|
291
|
+
}),
|
280
292
|
...process.env
|
281
293
|
}
|
282
294
|
|
@@ -286,201 +298,202 @@ command
|
|
286
298
|
format: '- {bar} | {status} | {pkgName} | {input} | {message}'
|
287
299
|
}, Presets.shades_classic)
|
288
300
|
|
289
|
-
const
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
mkdirSync(
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
try {
|
304
|
-
mkdirSync(jiekTemp)
|
305
|
-
} catch {}
|
301
|
+
const { wd } = getWD()
|
302
|
+
const wdNodeModules = path.resolve(wd, 'node_modules')
|
303
|
+
if (!existsSync(wdNodeModules)) {
|
304
|
+
mkdirSync(wdNodeModules)
|
305
|
+
}
|
306
|
+
const resolveByJiekTemp = (...paths: string[]) => path.resolve(wdNodeModules, '.jiek', ...paths)
|
307
|
+
const jiekTemp = resolveByJiekTemp()
|
308
|
+
if (!existsSync(jiekTemp)) {
|
309
|
+
try {
|
310
|
+
mkdirSync(jiekTemp)
|
311
|
+
} catch (e) {
|
312
|
+
if ((e as { code: string }).code !== 'EEXIST') {
|
313
|
+
throw e
|
314
|
+
}
|
306
315
|
}
|
316
|
+
}
|
307
317
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
318
|
+
let i = 0
|
319
|
+
const buildPackage = async ([pkgCWD, manifest]: [
|
320
|
+
string,
|
321
|
+
Manifest
|
322
|
+
], {
|
323
|
+
resolveByJiekTemp
|
324
|
+
}: {
|
325
|
+
resolveByJiekTemp: (...paths: string[]) => string
|
326
|
+
}) => {
|
327
|
+
if (manifest.name == null) {
|
328
|
+
throw new Error('package.json must have a name field')
|
329
|
+
}
|
316
330
|
|
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,
|
331
|
+
// TODO support auto build child packages in workspaces
|
332
|
+
const escapeManifestName = manifest.name.replace(/^@/g, '').replace(/\//g, '+')
|
333
|
+
const configFile = resolveByJiekTemp(
|
334
|
+
`${escapeManifestName ?? `anonymous-${i++}`}.rollup.config.js`
|
335
|
+
)
|
336
|
+
writeFileSync(configFile, FILE_TEMPLATE(manifest))
|
337
|
+
const command = [ROLLUP_BIN, '--silent', '-c', configFile]
|
338
|
+
if (tsRegisterName != null) {
|
339
|
+
command.unshift(`node -r ${tsRegisterName}`)
|
340
|
+
}
|
341
|
+
if (watch) {
|
342
|
+
command.push('--watch')
|
343
|
+
}
|
344
|
+
command.push(...passThroughOptions)
|
345
|
+
const child = execaCommand(command.join(' '), {
|
346
|
+
ipc: true,
|
347
|
+
cwd: pkgCWD,
|
348
|
+
windowsHide: true,
|
349
|
+
env: {
|
350
|
+
...env,
|
351
|
+
JIEK_NAME: manifest.name,
|
352
|
+
JIEK_ROOT: wd
|
353
|
+
}
|
354
|
+
})
|
355
|
+
const bars: Record<string, ReturnType<typeof multiBars.create>> = {}
|
356
|
+
const times: Record<string, number> = {}
|
357
|
+
const locks: Record<string, boolean> = {}
|
358
|
+
let inputMaxLen = 10
|
359
|
+
child.on('message', (e: RollupBuildEvent) => {
|
360
|
+
if (
|
361
|
+
silent && [
|
362
|
+
'init',
|
363
|
+
'progress',
|
364
|
+
'watchChange'
|
365
|
+
].includes(e.type)
|
366
|
+
) return
|
367
|
+
switch (e.type) {
|
368
|
+
case 'init': {
|
369
|
+
const { leafMap, targetsLength } = e.data
|
370
|
+
const leafs = Array
|
371
|
+
.from(leafMap.entries())
|
372
|
+
.flatMap(([input, pathAndConditions]) =>
|
373
|
+
pathAndConditions.map(([path, ...conditions]) => ({
|
392
374
|
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
375
|
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:
|
376
|
+
conditions
|
377
|
+
}))
|
378
|
+
)
|
379
|
+
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`
|
380
|
+
if (watch) {
|
381
|
+
initMessage += ' and watching...'
|
467
382
|
}
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
+ `cwd: ${pkgCWD}\n\n`
|
473
|
-
child.stderr?.on('data', (data) => {
|
474
|
-
errorStr += data
|
383
|
+
// eslint-disable-next-line no-console
|
384
|
+
console.log(initMessage)
|
385
|
+
leafs.forEach(({ input }) => {
|
386
|
+
inputMaxLen = Math.max(inputMaxLen, input.length)
|
475
387
|
})
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
388
|
+
leafs.forEach(({ input, path }) => {
|
389
|
+
const key = `${input}:${path}`
|
390
|
+
// eslint-disable-next-line ts/strict-boolean-expressions
|
391
|
+
if (bars[key]) return
|
392
|
+
bars[key] = multiBars.create(50, 0, {
|
393
|
+
pkgName: manifest.name,
|
394
|
+
input: input.padEnd(inputMaxLen + 5),
|
395
|
+
status: 'waiting'.padEnd(10)
|
396
|
+
}, {
|
397
|
+
barsize: 20,
|
398
|
+
linewrap: true
|
399
|
+
})
|
400
|
+
})
|
401
|
+
break
|
402
|
+
}
|
403
|
+
case 'progress': {
|
404
|
+
const {
|
405
|
+
path,
|
406
|
+
tags,
|
407
|
+
input,
|
408
|
+
event,
|
409
|
+
message
|
410
|
+
} = e.data
|
411
|
+
const bar = bars[`${input}:${path}`]
|
412
|
+
// eslint-disable-next-line ts/strict-boolean-expressions
|
413
|
+
if (!bar) return
|
414
|
+
const time = times[`${input}:${path}`]
|
415
|
+
bar.update(
|
416
|
+
{
|
417
|
+
start: 0,
|
418
|
+
resolve: 20,
|
419
|
+
end: 50
|
420
|
+
}[event ?? 'start'] ?? 0,
|
421
|
+
{
|
422
|
+
input: (
|
423
|
+
time
|
424
|
+
? `${input}(x${time.toString().padStart(2, '0')})`
|
425
|
+
: input
|
426
|
+
).padEnd(inputMaxLen + 5),
|
427
|
+
status: event?.padEnd(10),
|
428
|
+
message: `${tags?.join(', ')}: ${message}`
|
429
|
+
}
|
430
|
+
)
|
431
|
+
break
|
432
|
+
}
|
433
|
+
case 'watchChange': {
|
434
|
+
const {
|
435
|
+
path,
|
436
|
+
input
|
437
|
+
} = e.data
|
438
|
+
const key = `${input}:${path}`
|
439
|
+
const bar = bars[key]
|
440
|
+
// eslint-disable-next-line ts/strict-boolean-expressions
|
441
|
+
if (!bar) return
|
442
|
+
let time = times[key] ?? 1
|
443
|
+
if (!locks[key]) {
|
444
|
+
time += 1
|
445
|
+
times[key] = time
|
446
|
+
setTimeout(() => {
|
447
|
+
locks[key] = false
|
448
|
+
}, 100)
|
449
|
+
bar.update(0, {
|
450
|
+
input: `${input}(x${time.toString().padStart(2, '0')})`.padEnd(inputMaxLen + 5),
|
451
|
+
status: 'watching'.padEnd(10),
|
452
|
+
message: 'watching...'
|
453
|
+
})
|
454
|
+
}
|
455
|
+
locks[key] = true
|
456
|
+
break
|
457
|
+
}
|
458
|
+
case 'modulesAnalyze': {
|
459
|
+
const {
|
460
|
+
data: {
|
461
|
+
type,
|
462
|
+
modules: pkgModules
|
463
|
+
}
|
464
|
+
} = e
|
465
|
+
void refreshAnalyzer(
|
466
|
+
pkgCWD,
|
467
|
+
pkgModules.map(m => ({
|
468
|
+
...m,
|
469
|
+
type,
|
470
|
+
filename: `${manifest.name}/${m.filename}`,
|
471
|
+
label: `${manifest.name}/${m.label}`
|
472
|
+
}))
|
473
|
+
)
|
474
|
+
break
|
475
|
+
}
|
476
|
+
case 'debug': {
|
477
|
+
// eslint-disable-next-line no-console,ts/no-unsafe-argument
|
478
|
+
console.log(...(Array.isArray(e.data) ? e.data : [e.data]))
|
479
|
+
break
|
480
|
+
}
|
481
|
+
default:
|
482
|
+
}
|
483
|
+
})
|
484
|
+
await new Promise<void>((resolve, reject) => {
|
485
|
+
let errorStr = `rollup build failed\n`
|
486
|
+
+ `package name: ${manifest.name}\n`
|
487
|
+
+ `cwd: ${pkgCWD}\n\n`
|
488
|
+
child.stderr?.on('data', (data) => {
|
489
|
+
errorStr += data
|
482
490
|
})
|
483
|
-
|
491
|
+
child.once('exit', (code) =>
|
492
|
+
code === 0
|
493
|
+
? resolve()
|
494
|
+
: reject(new Error(errorStr)))
|
495
|
+
verbose && child.stdout?.pipe(process.stdout)
|
496
|
+
})
|
484
497
|
}
|
485
498
|
|
486
499
|
const commandFilters = IS_WORKSPACE ? commandFiltersOrEntries : undefined
|
@@ -499,12 +512,14 @@ command
|
|
499
512
|
])
|
500
513
|
]
|
501
514
|
try {
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
515
|
+
const packages = (
|
516
|
+
filters.length > 0
|
517
|
+
? await filterPackagesGraph(filters)
|
518
|
+
: [await getSelectedProjectsGraph()]
|
519
|
+
).flatMap(({ value }) => Object.entries(value ?? {}))
|
520
|
+
await Promise.allSettled(
|
521
|
+
packages.map(async ([cwd, manifest]) => buildPackage([cwd, manifest], { resolveByJiekTemp }))
|
522
|
+
)
|
508
523
|
} finally {
|
509
524
|
multiBars.stop()
|
510
525
|
// eslint-disable-next-line no-console
|
package/src/commands/meta.ts
CHANGED