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(vite): introduce hmrTopLevelAwait option #2066

Merged
merged 8 commits into from Jan 12, 2023

Conversation

LittleSound
Copy link
Contributor

@LittleSound LittleSound commented Jan 10, 2023

Summary

Sometimes I need to develop in restricted environments to debug the compatibility of certain code on a particular platform, but recently unocss has been using top-level await's in development mode, causing my code to not work properly in these restricted environments, which makes it very inconvenient to have to build and release the project for testing.

fix #2031, fix #2025, close #1981

@netlify
Copy link

netlify bot commented Jan 10, 2023

Deploy Preview for unocss ready!

Name Link
🔨 Latest commit a48f743
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/63c0020fa6206f0009af0ab0
😎 Deploy Preview https://deploy-preview-2066--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@zyyv
Copy link
Member

zyyv commented Jan 10, 2023

Similar to #1981

@antfu
Copy link
Member

antfu commented Jan 10, 2023

I think we should better make an option, so ppl can opt-out if needed, while the majority could still benefit from it.

@LittleSound
Copy link
Contributor Author

I think we should better make an option, so ppl can opt-out if needed, while the majority could still benefit from it.

I added a switch to the top-level await feature in the configuration. I'm not familiar with the unocss code yet, so feel free to point out if there is something wrong with the changes

@@ -13,7 +13,9 @@ export default defineConfig({
},
plugins: [
Vue(),
Unocss(),
UnoCSS({
topLevelAwait: false,
Copy link
Member

@zyyv zyyv Jan 12, 2023

Choose a reason for hiding this comment

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

You can test it on playground.

image

packages/core/src/types.ts Outdated Show resolved Hide resolved
@@ -13,7 +13,9 @@ export default defineConfig({
},
plugins: [
Vue(),
Unocss(),
UnoCSS({
hmrTopLevelAwait: false,
Copy link
Member

Choose a reason for hiding this comment

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

Please allow me add this option to test uno's vite plugin, it doesn't affect anything. @antfu

@zyyv zyyv changed the title fix: top level await fix(vite): switch of top level await Jan 12, 2023
@LittleSound
Copy link
Contributor Author

Thank you very much for helping me to improve the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants