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

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Sep 20, 2022

Motivation

PR: #1407

I want to collect the used theme in postprocess and return it in preflights. But preflights will be executed faster.

Purpose

Add theme variables collected by postprocess to preflight

@Dunqing Dunqing requested a review from antfu as a code owner September 20, 2022 04:03
@netlify
Copy link

netlify bot commented Sep 20, 2022

Deploy Preview for unocss canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 16676ab
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/63315c96ddb87300091311bc

@@ -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

@antfu antfu changed the title feat(core): adjusting the order of execution feat(core)!: generate preflights after utilties Sep 26, 2022
resolve('/* rule */')
}, 20))],
}, 1000))],
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the timeout to be this long?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just wanted to make it look like it was at the end.

@chu121su12
Copy link
Collaborator

As @chris-zhu said in #1695, there are another way to wait until either tokens or preflights are all processed before doing the other. Try to get access to the UnoGenerator then you can do:

  • token only: UnoGenerator.generate($tokenVar, { preflights: false })
  • preflights only: UnoGenerator.generate('', { preflights: true }) (generate on an empty string)

You can combine both calls. Token generation uses cache until you update the config with UnoGenerator.setConfig() and preflight generation is without caching.

@antfu
Copy link
Member

antfu commented Oct 9, 2022

I am actually fine with this PR since it doesn't add extra complexity. @chu121su12 What's your opinion on that? Do you mean you prefer a more general solution?

@chu121su12
Copy link
Collaborator

@antfu Just with the async behavior as I commented above.

With this changes the whole test file could be removed since it was added to ensure the racing behavior.

@antfu antfu merged commit 3bca691 into unocss:main Oct 25, 2022
Dunqing added a commit to unpreset/unocss-preset-theme that referenced this pull request Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants