Repository navigation
feat!: Individual exports and introduce the #imports module - #1258
Conversation
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
#imports virtual module
@wxt-dev/auto-icons
@wxt-dev/i18n
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/storage
@wxt-dev/unocss
wxt
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 0.20.0-breaking-changes #1258 +/- ##
===========================================================
+ Coverage 80.24% 80.29% +0.04%
===========================================================
Files 127 126 -1
Lines 6070 5958 -112
Branches 1020 999 -21
===========================================================
- Hits 4871 4784 -87
+ Misses 1184 1157 -27
- Partials 15 17 +2 ☔ View full report in Codecov by Sentry. |
| }, | ||
| "module": "./dist/index.mjs", | ||
| "types": "./dist/index.d.ts", | ||
| "exports": { |
There was a problem hiding this comment.
Moved all this stuff down since I look at scripts and dependencies more often. Now that there are way more exports, I had to scroll way further.
| const options = wxt.config.imports; | ||
| if (options === false) return; |
There was a problem hiding this comment.
Now, instead of disabling the entire module, we only set a flag to false in the vite plugin to prevent adding auto-imports, but still replace #imports.
| const injected = await unimport.injectImports(code, id); | ||
| const injected = await unimport.injectImports(code, id, { | ||
| // Only auto-import modules if enabled | ||
| autoImport: autoImportsEnabled, |
There was a problem hiding this comment.
Here is where auto-imports are disabled from now.
#imports virtual module#imports virtual module
#imports virtual module#imports virtual module
#imports virtual module#imports module
f6dff26 to
55eaa89
Compare
BREAKING CHANGE: APIs exported by
wxt/clientandwxt/sandboxsubmodules have been moved towxt/utils/*. Each API now resides in it's own submodule.To ease the process of importing these APIs, WXT is introducing the new
#importsmodule. To upgrade, replace any manual imports fromwxt/clientorwxt/sandboxwith the new#importsmodule:Read more about the
#importsmodule in the blog post.If you use auto-imports, you may have manually imported things. Update them to import from
#importsas well.It's rare, but if you are mocking any API from
wxt/clientorwxt/sandboxin your unit tests, you'll need to update the mock paths to the newwxt/utils/*paths (not#imports):To learn more about mocking APIs from the
#importsmodule, read the Unit Testing docs.BREAKING CHANGE: To override types in
<srcDir>/app.config.ts, update your module-augmentation:BREAKING CHANGE:
wxt.config.importstype was changed fromfalse | WxtResolvedUnimportOptionsto justWxtResolvedUnimportOptions. You no longer need to check if auto-imports are enabled before modifying the config.This addresses the issue discovered in #1210 (comment). Instead of importing the entire
wxt/clientmodule, it will now auto-import the individual API,useAppConfig, fromwxt/utils/app-configinstead ofwxt/client. This PR also adds individual exports for every other runtime API.Additional, a new virtual modules has been added:
#imports. Used the same way as with Nuxt. You can import all APIs from it and WXT will automatically convert each import to their auto-imported module:Would become:
TODO
#importsmodule, making sure editors give it priority when manually importing an API.wxt/utils/*