Skip to content

feat(experimental): Load entrypoint options with Vite Runtime API - #648

Merged
aklinker1 merged 9 commits into
mainfrom
vite-runtime
May 4, 2024
Merged

aklinker1 merged 9 commits into
mainfrom
vite-runtime

Conversation

@aklinker1

@aklinker1 aklinker1 commented May 4, 2024 •

Copy link
Copy Markdown
Member

Entrypoint options can now be extracted during the build using the Vite Runtime API. Previously, these files were loaded using jiti.

// wxt.config.ts
export default defineConfig({
  experimental: {
    viteRuntime: true,
  },
});

With the experimental flag enabled, you can now:

  • Use imported variables outside the main function of your entrypoints
  • Use vite-only features like import.meta.glob to generate options like content script matches
  • Leverage any Vite plugins you've listed in wxt.config.ts to transform your code, allowing use of non-standard syntax

Since all code is now loaded using Vite, it should also be more consistent and lead to less differences in runtime, which has caused errors.

The main downside to this approach is that it will take longer to load entrypoint options at the start of a build. WXT tries to tree-shake out as much runtime code as possible, but will not remove any explicitly listed imports.

For the demo app, the entire build goes from 1.5s to 1.9s.


Apart of #506. Not closing until I've released and tested all the reports again. Based on experimentation done in #585.

@netlify

netlify Bot commented May 4, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 77bdb92
🔍 Latest deploy log https://app.netlify.com/sites/creative-fairy-df92c4/deploys/6636574a04b5650008b871ff
😎 Deploy Preview https://deploy-preview-648--creative-fairy-df92c4.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 configuration.

@codecov

codecov Bot commented May 4, 2024 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 99.00990% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 86.83%. Comparing base (6ca3767) to head (ef91a6d).

❗ Current head ef91a6d differs from pull request most recent head 77bdb92. Consider uploading reports for the commit 77bdb92 to get more accurate results

Files Patch % Lines
...es/wxt/src/core/utils/building/find-entrypoints.ts 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #648      +/-   ##
==========================================
+ Coverage   86.48%   86.83%   +0.34%     
==========================================
  Files         112      114       +2     
  Lines        9111     9207      +96     
  Branches      911      922      +11     
==========================================
+ Hits         7880     7995     +115     
+ Misses       1217     1198      -19     
  Partials       14       14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aklinker1 aklinker1 changed the title feat: Load entrypoint options with Vite Runtime API feat!: Load entrypoint options with Vite Runtime API May 4, 2024
@aklinker1 aklinker1 changed the title feat!: Load entrypoint options with Vite Runtime API feat: Experimental option to load entrypoints with Vite Runtime API May 4, 2024
@aklinker1
aklinker1 marked this pull request as ready for review May 4, 2024 15:15
@aklinker1 aklinker1 changed the title feat: Experimental option to load entrypoints with Vite Runtime API feat(experimental): Load entrypoint options with Vite Runtime API May 4, 2024
@aklinker1
aklinker1 merged commit a917f32 into main May 4, 2024
@aklinker1
aklinker1 deleted the vite-runtime branch May 4, 2024 15:46
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.

1 participant