Skip to content

Commit 71b36ca

Browse files
committed
chore: fix rolldown unsolve warning, due to be wrong order
1 parent 2d5a6ba commit 71b36ca

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

scripts/build-rolldown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ async function main() {
113113

114114
async function buildAll(targets: string[]) {
115115
const start = performance.now()
116-
const all = []
117116
let count = 0
118117
for (const target of targets) {
118+
const all = []
119119
const configs = await createConfigsForTarget(target)
120120
if (configs) {
121121
all.push(
@@ -141,8 +141,8 @@ async function main() {
141141
})
142142
)
143143
}
144+
await Promise.all(all)
144145
}
145-
await Promise.all(all)
146146
console.log(
147147
`\n${count} files built in ${(performance.now() - start).toFixed(2)}ms.`
148148
)

scripts/utils.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,48 @@ export type BundleReport = {
99
brotli: number
1010
}
1111

12+
const PKG_TARGET_ORDER = [
13+
'shared',
14+
'message-compiler',
15+
'devtools-types',
16+
'core-base',
17+
'core',
18+
'vue-i18n-core',
19+
'petite-vue-i18n',
20+
'vue-i18n'
21+
]
22+
23+
function resolveTargets(targets: string[]) {
24+
return targets.sort((a, b) => {
25+
const ia = PKG_TARGET_ORDER.indexOf(a)
26+
const ib = PKG_TARGET_ORDER.indexOf(b)
27+
return ia > ib ? 1 : ia < ib ? -1 : 0
28+
})
29+
}
30+
1231
export const targets = async () => {
1332
const packages = await fs.readdir('packages')
33+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34+
const pkgCaches = new Map<string, any>()
1435
const files = await Promise.all(
1536
packages.map(async f => {
1637
const stat = await fs.stat(`packages/${f}`)
1738
if (!stat.isDirectory()) {
1839
return ''
1940
}
20-
const pkg = await readJson(
21-
resolve(dirname(''), `./packages/${f}/package.json`)
22-
)
41+
const pkgfile = resolve(dirname(''), `./packages/${f}/package.json`)
42+
let pkg = pkgCaches.get(pkgfile)
43+
if (pkg == null) {
44+
pkg = await readJson(pkgfile)
45+
pkgCaches.set(pkgfile, pkg)
46+
}
2347
if (pkg.private || !pkg.buildOptions) {
2448
return ''
2549
}
2650
return f
2751
})
2852
)
29-
return files.filter((_, f) => files[f])
53+
return resolveTargets(files.filter((_, f) => files[f]))
3054
}
3155

3256
export const fuzzyMatchTarget = async (
@@ -78,7 +102,9 @@ export async function sizeTargets() {
78102
return f
79103
})
80104
)
81-
return files.filter((_, f) => files[f]).filter(f => /size-check/.test(f))
105+
return resolveTargets(
106+
files.filter((_, f) => files[f]).filter(f => /size-check/.test(f))
107+
)
82108
}
83109

84110
export async function checkSizeDistFiles(target: string) {

0 commit comments

Comments
 (0)