Skip to content

Commit

Permalink
feat(core)!: generate preflights after utilties (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Oct 25, 2022
1 parent dd0d6cb commit 3bca691
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions packages/core/src/generator/index.ts
Expand Up @@ -165,7 +165,8 @@ export class UnoGenerator {
}
})

const preflightPromise = (async () => {
await Promise.all(tokenPromises)
await (async () => {
if (!preflights)
return

Expand Down Expand Up @@ -197,11 +198,6 @@ export class UnoGenerator {
)
})()

await Promise.all([
...tokenPromises,
preflightPromise,
])

const layers = this.config.sortLayers(Array
.from(layerSet)
.sort((a, b) => ((this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0)) || a.localeCompare(b)),
Expand Down
10 changes: 5 additions & 5 deletions test/generate-async.test.ts
Expand Up @@ -24,21 +24,21 @@ describe('generate-async', () => {
expect(order).eql([1, 2])
})

test('preflight-first', async () => {
test('preflight at the end', async () => {
const order: number[] = []
const uno = createGenerator({
rules: [
[/^rule$/, () => new Promise(resolve => setTimeout(() => {
order.push(2)
order.push(1)
resolve('/* rule */')
}, 20))],
],
preflights: [
{
getCSS: () => new Promise(resolve => setTimeout(() => {
order.push(1)
getCSS: () => new Promise((resolve) => {
order.push(2)
resolve('/* preflight */')
}, 10)),
}),
},
],
})
Expand Down

0 comments on commit 3bca691

Please sign in to comment.