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
package/src/commands/build.ts
DELETED
@@ -1,544 +0,0 @@
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
|
2
|
-
import path from 'node:path'
|
3
|
-
import process from 'node:process'
|
4
|
-
|
5
|
-
import { MultiBar, Presets } from 'cli-progress'
|
6
|
-
import { program } from 'commander'
|
7
|
-
import { execaCommand } from 'execa'
|
8
|
-
import type { Config } from 'jiek'
|
9
|
-
|
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'
|
25
|
-
|
26
|
-
declare module 'jiek' {
|
27
|
-
interface Config {
|
28
|
-
/**
|
29
|
-
* Skip entries which end with '.js'.
|
30
|
-
*/
|
31
|
-
skipJS?: boolean
|
32
|
-
build?: TemplateOptions & {
|
33
|
-
/**
|
34
|
-
* Whether to run in silent mode, only active when configured in the workspace root or cwd.
|
35
|
-
*
|
36
|
-
* @default false
|
37
|
-
*/
|
38
|
-
silent?: boolean
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
|
43
|
-
const FILE_TEMPLATE = (manifest: unknown) => (`
|
44
|
-
module.exports = require('jiek/rollup').template(${JSON.stringify(manifest, null, 2)})
|
45
|
-
`.trimStart())
|
46
|
-
|
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'
|
52
|
-
|
53
|
-
const description = `
|
54
|
-
Build the package according to the 'exports' field from the package.json.
|
55
|
-
If you want to through the options to the \`rollup\` command, you can pass the options after '--'.
|
56
|
-
${isDefault ? 'This command is the default command.' : ''}
|
57
|
-
`.trim()
|
58
|
-
|
59
|
-
interface BuildOptions extends
|
60
|
-
AnalyzerBuildOptions,
|
61
|
-
Pick<
|
62
|
-
Config,
|
63
|
-
'skipJS'
|
64
|
-
>
|
65
|
-
{
|
66
|
-
/**
|
67
|
-
* Auto-detect the builder from the installed dependencies.
|
68
|
-
* If the builder is not installed, it will prompt the user to install it.
|
69
|
-
* If exists multiple builders, it will fall back to the 'esbuild'.
|
70
|
-
*/
|
71
|
-
type?: typeof BUILDER_TYPES[number]
|
72
|
-
/**
|
73
|
-
* The output directory of the build, which relative to the target subpackage root directory.
|
74
|
-
* Support with variables: 'PKG_NAME',
|
75
|
-
* .e.g. 'dist/{{PKG_NAME}}'.
|
76
|
-
*
|
77
|
-
* @default 'dist'
|
78
|
-
*/
|
79
|
-
outdir: string
|
80
|
-
watch: boolean
|
81
|
-
/**
|
82
|
-
* The port of the server.
|
83
|
-
*
|
84
|
-
* @default 8888
|
85
|
-
*/
|
86
|
-
port: number
|
87
|
-
silent: boolean
|
88
|
-
verbose: boolean
|
89
|
-
entries?: string
|
90
|
-
external?: string
|
91
|
-
noConvert: boolean
|
92
|
-
noJs: boolean
|
93
|
-
noDts: boolean
|
94
|
-
noMin: boolean
|
95
|
-
/**
|
96
|
-
* Do not clean the output directory before building.
|
97
|
-
*/
|
98
|
-
noClean: boolean
|
99
|
-
onlyMin: boolean
|
100
|
-
/**
|
101
|
-
* The type of minify, support 'terser' and 'builder'.
|
102
|
-
*
|
103
|
-
* @default 'builder'
|
104
|
-
*/
|
105
|
-
minType?: string
|
106
|
-
/**
|
107
|
-
* The path of the tsconfig file which is used to generate js and dts files.
|
108
|
-
* If not specified, it will be loaded from:
|
109
|
-
* - ./tsconfig.json
|
110
|
-
* - ./tsconfig.dts.json
|
111
|
-
* - ./tsconfig.build.json
|
112
|
-
*/
|
113
|
-
tsconfig?: string
|
114
|
-
/**
|
115
|
-
* The path of the tsconfig file which is used to generate dts files.
|
116
|
-
* If not specified, it will be loaded from:
|
117
|
-
* - ./tsconfig.json
|
118
|
-
* - ./tsconfig.dts.json
|
119
|
-
*/
|
120
|
-
dtsconfig?: string
|
121
|
-
|
122
|
-
'features.keepImportAttributes'?: boolean | 'assert'
|
123
|
-
}
|
124
|
-
|
125
|
-
let DEFAULT_BUILDER_TYPE: typeof BUILDER_TYPES[number]
|
126
|
-
Object.entries(BUILDER_TYPE_PACKAGE_NAME_MAP).forEach(([type, packageName]) => {
|
127
|
-
try {
|
128
|
-
require.resolve(packageName)
|
129
|
-
DEFAULT_BUILDER_TYPE = type as typeof BUILDER_TYPES[number]
|
130
|
-
} catch { /* empty */ }
|
131
|
-
})
|
132
|
-
if (!DEFAULT_BUILDER_TYPE!) {
|
133
|
-
DEFAULT_BUILDER_TYPE = 'esbuild'
|
134
|
-
}
|
135
|
-
|
136
|
-
const buildFilterDescription = `
|
137
|
-
${filterDescription}
|
138
|
-
If you pass the --filter option, it will merge into the filters of the command.
|
139
|
-
`.trim()
|
140
|
-
|
141
|
-
const buildEntriesDescription = `
|
142
|
-
${entriesDescription}
|
143
|
-
If you pass the --entries option, it will merge into the entries of the command.
|
144
|
-
`.trim()
|
145
|
-
|
146
|
-
let command = isDefault
|
147
|
-
? (() => {
|
148
|
-
const c = program
|
149
|
-
.name('jb/jiek-build')
|
150
|
-
.helpCommand(false)
|
151
|
-
if (IS_WORKSPACE) {
|
152
|
-
c.argument('[filters]', buildFilterDescription)
|
153
|
-
} else {
|
154
|
-
c.argument('[entries]', buildEntriesDescription)
|
155
|
-
}
|
156
|
-
return c
|
157
|
-
})()
|
158
|
-
: program
|
159
|
-
.command(`build [${IS_WORKSPACE ? 'filters' : 'entries'}]`)
|
160
|
-
|
161
|
-
command = command
|
162
|
-
.description(description)
|
163
|
-
.option('-t, --type <TYPE>', `The type of build, support ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}.`, v => {
|
164
|
-
if (!BUILDER_TYPES.includes(v as typeof BUILDER_TYPES[number])) {
|
165
|
-
throw new Error(`The value of 'type' must be ${BUILDER_TYPES.map(s => `"${s}"`).join(', ')}`)
|
166
|
-
}
|
167
|
-
return String(v)
|
168
|
-
}, 'esbuild')
|
169
|
-
.option('-o, --outdir <OUTDIR>', outdirDescription, String, 'dist')
|
170
|
-
.option('-e, --entries <ENTRIES>', entriesDescription)
|
171
|
-
.option('--external <EXTERNAL>', 'Specify the external dependencies of the package.', String)
|
172
|
-
.option('--noConvert', 'Specify the `crossModuleConvertor` option to false.', parseBoolean)
|
173
|
-
.option('-nj, --noJs', 'Do not output js files.', parseBoolean)
|
174
|
-
.option('-nd, --noDts', 'Do not output dts files.', parseBoolean)
|
175
|
-
.option('-nm, --noMin', 'Do not output minify files.', parseBoolean)
|
176
|
-
.option(
|
177
|
-
'--minType <MINTYPE>',
|
178
|
-
'The type of minify, support "builder" and "terser".',
|
179
|
-
v => {
|
180
|
-
if (!['builder', 'terser'].includes(v)) {
|
181
|
-
throw new Error('The value of `minType` must be "builder" or "terser"')
|
182
|
-
}
|
183
|
-
return String(v)
|
184
|
-
}
|
185
|
-
)
|
186
|
-
.option('-nc, --noClean', 'Do not clean the output directory before building.', parseBoolean)
|
187
|
-
.option(
|
188
|
-
'-om, --onlyMin',
|
189
|
-
'Only output minify files, but dts files will still be output, it only replaces the js files.',
|
190
|
-
parseBoolean
|
191
|
-
)
|
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
|
-
|
199
|
-
command = command
|
200
|
-
.option('--tsconfig <TSCONFIG>', 'The path of the tsconfig file which is used to generate js and dts files.', String)
|
201
|
-
.option('--dtsconfig <DTSCONFIG>', 'The path of the tsconfig file which is used to generate dts files.', String)
|
202
|
-
|
203
|
-
command = command
|
204
|
-
.option('-w, --watch', 'Watch the file changes.', parseBoolean)
|
205
|
-
.option('-p, --port <PORT>', 'The port of the server.', Number.parseInt, 8888)
|
206
|
-
|
207
|
-
command = registerAnalyzerCommandOptions(command)
|
208
|
-
|
209
|
-
command = command
|
210
|
-
.option('-s, --silent', "Don't display logs.", parseBoolean)
|
211
|
-
.option('-v, --verbose', 'Display debug logs.', parseBoolean)
|
212
|
-
|
213
|
-
command
|
214
|
-
.action(async (commandFiltersOrEntries: string | undefined, options: BuildOptions) => {
|
215
|
-
let {
|
216
|
-
type,
|
217
|
-
outdir,
|
218
|
-
watch,
|
219
|
-
silent,
|
220
|
-
verbose,
|
221
|
-
entries: optionEntries,
|
222
|
-
external,
|
223
|
-
noConvert,
|
224
|
-
noJs: withoutJs,
|
225
|
-
noDts: withoutDts,
|
226
|
-
noMin: withoutMin,
|
227
|
-
minType: minifyType,
|
228
|
-
noClean,
|
229
|
-
onlyMin,
|
230
|
-
tsconfig,
|
231
|
-
dtsconfig,
|
232
|
-
skipJS
|
233
|
-
} = options
|
234
|
-
const resolvedType = type ?? DEFAULT_BUILDER_TYPE
|
235
|
-
if (!withoutJs) {
|
236
|
-
await checkDependency(BUILDER_TYPE_PACKAGE_NAME_MAP[resolvedType])
|
237
|
-
if (minifyType === 'builder') {
|
238
|
-
minifyType = resolvedType
|
239
|
-
}
|
240
|
-
}
|
241
|
-
if (!withoutMin && minifyType === 'terser') {
|
242
|
-
await checkDependency('@rollup/plugin-terser')
|
243
|
-
}
|
244
|
-
let shouldPassThrough = false
|
245
|
-
|
246
|
-
const passThroughOptions = process.argv
|
247
|
-
.reduce(
|
248
|
-
(acc, value) => {
|
249
|
-
if (shouldPassThrough) {
|
250
|
-
acc.push(value)
|
251
|
-
}
|
252
|
-
if (value === '--') {
|
253
|
-
shouldPassThrough = true
|
254
|
-
}
|
255
|
-
return acc
|
256
|
-
},
|
257
|
-
[] as string[]
|
258
|
-
)
|
259
|
-
|
260
|
-
const shouldCreateServer = [
|
261
|
-
options.ana === true && options['ana.mode'] === 'server'
|
262
|
-
].some(Boolean)
|
263
|
-
const server = shouldCreateServer
|
264
|
-
? createServer(options.port, 'localhost')
|
265
|
-
: undefined
|
266
|
-
|
267
|
-
const {
|
268
|
-
ANALYZER_ENV,
|
269
|
-
refreshAnalyzer
|
270
|
-
} = await useAnalyzer(options, server)
|
271
|
-
|
272
|
-
const { build } = loadConfig()
|
273
|
-
silent = silent ?? build?.silent ?? false
|
274
|
-
|
275
|
-
if (withoutMin && onlyMin) {
|
276
|
-
throw new Error('Cannot use both --without-minify and --only-minify')
|
277
|
-
}
|
278
|
-
if (onlyMin && withoutJs) {
|
279
|
-
throw new Error('Cannot use --without-js and --only-minify at the same time')
|
280
|
-
}
|
281
|
-
|
282
|
-
let entries: string | undefined = [
|
283
|
-
optionEntries,
|
284
|
-
IS_WORKSPACE ? undefined : commandFiltersOrEntries
|
285
|
-
].filter(Boolean).join(',')
|
286
|
-
if (entries.length === 0) {
|
287
|
-
entries = undefined
|
288
|
-
}
|
289
|
-
const env = {
|
290
|
-
...ANALYZER_ENV,
|
291
|
-
JIEK_BUILDER: type,
|
292
|
-
JIEK_OUT_DIR: outdir,
|
293
|
-
JIEK_CLEAN: String(!noClean),
|
294
|
-
JIEK_ENTRIES: entries,
|
295
|
-
JIEK_EXTERNAL: external,
|
296
|
-
JIEK_CROSS_MODULE_CONVERTOR: String(!noConvert),
|
297
|
-
JIEK_WITHOUT_JS: String(withoutJs),
|
298
|
-
JIEK_WITHOUT_DTS: String(withoutDts),
|
299
|
-
JIEK_WITHOUT_MINIFY: String(withoutMin),
|
300
|
-
JIEK_ONLY_MINIFY: String(onlyMin),
|
301
|
-
JIEK_MINIFY_TYPE: minifyType,
|
302
|
-
JIEK_TSCONFIG: tsconfig,
|
303
|
-
JIEK_DTSCONFIG: dtsconfig,
|
304
|
-
JIEK_SKIP_JS: String(skipJS),
|
305
|
-
JIEK_FEATURES: JSON.stringify({
|
306
|
-
keepImportAttributes: options['features.keepImportAttributes']
|
307
|
-
}),
|
308
|
-
...process.env
|
309
|
-
}
|
310
|
-
|
311
|
-
const multiBars = new MultiBar({
|
312
|
-
clearOnComplete: false,
|
313
|
-
hideCursor: true,
|
314
|
-
format: '- {bar} | {status} | {pkgName} | {input} | {message}'
|
315
|
-
}, Presets.shades_classic)
|
316
|
-
|
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
|
-
}
|
331
|
-
}
|
332
|
-
}
|
333
|
-
|
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
|
-
}
|
346
|
-
|
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]) => ({
|
390
|
-
input,
|
391
|
-
path,
|
392
|
-
conditions
|
393
|
-
}))
|
394
|
-
)
|
395
|
-
let initMessage = `Package '${manifest.name}' has ${targetsLength} targets to build`
|
396
|
-
if (watch) {
|
397
|
-
initMessage += ' and watching...'
|
398
|
-
}
|
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
|
-
})
|
416
|
-
})
|
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
|
506
|
-
})
|
507
|
-
child.once('exit', (code) =>
|
508
|
-
code === 0
|
509
|
-
? resolve()
|
510
|
-
: reject(new Error(errorStr)))
|
511
|
-
verbose && child.stdout?.pipe(process.stdout)
|
512
|
-
})
|
513
|
-
}
|
514
|
-
|
515
|
-
const commandFilters = IS_WORKSPACE ? commandFiltersOrEntries : undefined
|
516
|
-
const filters = [
|
517
|
-
...new Set([
|
518
|
-
...(program.getOptionValue('filter') as string | undefined)
|
519
|
-
?.split(',')
|
520
|
-
.map(s => s.trim())
|
521
|
-
.filter(s => s.length > 0)
|
522
|
-
?? [],
|
523
|
-
...commandFilters
|
524
|
-
?.split(',')
|
525
|
-
.map(s => s.trim())
|
526
|
-
.filter(s => s.length > 0)
|
527
|
-
?? []
|
528
|
-
])
|
529
|
-
]
|
530
|
-
try {
|
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
|
-
)
|
539
|
-
} finally {
|
540
|
-
multiBars.stop()
|
541
|
-
// eslint-disable-next-line no-console
|
542
|
-
!silent && console.log('Build complete')
|
543
|
-
}
|
544
|
-
})
|
@@ -1,17 +0,0 @@
|
|
1
|
-
export const entriesDescription = `
|
2
|
-
Specify the build entry-points of the package.json's 'exports' field.
|
3
|
-
Support glob pattern and array.
|
4
|
-
.e.g. '.', './*', './sub/*', './a,./b'.
|
5
|
-
`.trim()
|
6
|
-
|
7
|
-
export const filterDescription = `
|
8
|
-
Filter the packages from the workspace.
|
9
|
-
Support fuzzy match and array.
|
10
|
-
.e.g. 'core,utils'.
|
11
|
-
`.trim()
|
12
|
-
|
13
|
-
export const outdirDescription = `
|
14
|
-
The output directory of the build, which relative to the target subpackage root directory.
|
15
|
-
Support with variables: 'PKG_NAME',
|
16
|
-
.e.g. 'dist/{{PKG_NAME}}'.
|
17
|
-
`.trim()
|