Skip to content

Commit

Permalink
chore: fix rolldown unsolve warning, due to be wrong order
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Jan 7, 2025
1 parent 2d5a6ba commit 71b36ca
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scripts/build-rolldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ async function main() {

async function buildAll(targets: string[]) {
const start = performance.now()
const all = []
let count = 0
for (const target of targets) {
const all = []
const configs = await createConfigsForTarget(target)
if (configs) {
all.push(
Expand All @@ -141,8 +141,8 @@ async function main() {
})
)
}
await Promise.all(all)
}
await Promise.all(all)
console.log(
`\n${count} files built in ${(performance.now() - start).toFixed(2)}ms.`
)
Expand Down
36 changes: 31 additions & 5 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,48 @@ export type BundleReport = {
brotli: number
}

const PKG_TARGET_ORDER = [
'shared',
'message-compiler',
'devtools-types',
'core-base',
'core',
'vue-i18n-core',
'petite-vue-i18n',
'vue-i18n'
]

function resolveTargets(targets: string[]) {
return targets.sort((a, b) => {
const ia = PKG_TARGET_ORDER.indexOf(a)
const ib = PKG_TARGET_ORDER.indexOf(b)
return ia > ib ? 1 : ia < ib ? -1 : 0
})
}

export const targets = async () => {
const packages = await fs.readdir('packages')
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const pkgCaches = new Map<string, any>()
const files = await Promise.all(
packages.map(async f => {
const stat = await fs.stat(`packages/${f}`)
if (!stat.isDirectory()) {
return ''
}
const pkg = await readJson(
resolve(dirname(''), `./packages/${f}/package.json`)
)
const pkgfile = resolve(dirname(''), `./packages/${f}/package.json`)
let pkg = pkgCaches.get(pkgfile)
if (pkg == null) {
pkg = await readJson(pkgfile)
pkgCaches.set(pkgfile, pkg)
}
if (pkg.private || !pkg.buildOptions) {
return ''
}
return f
})
)
return files.filter((_, f) => files[f])
return resolveTargets(files.filter((_, f) => files[f]))
}

export const fuzzyMatchTarget = async (
Expand Down Expand Up @@ -78,7 +102,9 @@ export async function sizeTargets() {
return f
})
)
return files.filter((_, f) => files[f]).filter(f => /size-check/.test(f))
return resolveTargets(
files.filter((_, f) => files[f]).filter(f => /size-check/.test(f))
)
}

export async function checkSizeDistFiles(target: string) {
Expand Down

0 comments on commit 71b36ca

Please sign in to comment.