Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core)!: generate preflights after utilties #1617

Merged
merged 5 commits into from Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/core/src/generator/index.ts
Expand Up @@ -174,7 +174,8 @@ export class UnoGenerator {
}
})

const preflightPromise = (async () => {
await Promise.all(tokenPromises)
await (async () => {
chu121su12 marked this conversation as resolved.
Show resolved Hide resolved
if (!preflights)
return

Expand Down Expand Up @@ -206,11 +207,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
22 changes: 0 additions & 22 deletions test/generate-async.test.ts
Expand Up @@ -23,26 +23,4 @@ describe('generate-async', () => {
await uno.generate('rule')
expect(order).eql([1, 2])
})

test('preflight-first', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now parseToken first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a breaking change - Can we still keep the test but instead update the order?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a breaking change - Can we still keep the test but instead update the order?

Yes, updated

const order: number[] = []
const uno = createGenerator({
rules: [
[/^rule$/, () => new Promise(resolve => setTimeout(() => {
order.push(2)
resolve('/* rule */')
}, 20))],
],
preflights: [
{
getCSS: () => new Promise(resolve => setTimeout(() => {
order.push(1)
resolve('/* preflight */')
}, 10)),
},
],
})
await uno.generate('rule')
expect(order).eql([1, 2])
})
})