-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Description
Vue version
3.2.41
Link to minimal reproduction
https://github.com/bauer00/vue3-module-provide-test
Steps to reproduce
- Checkout https://github.com/bauer00/vue3-module-provide-test (It's a clean install with
npm init vue@latest
and only added Typescript) npm install
(this should also install the module@test/module
which is provided by a local packagetest-mdoule-0.0.1.tgz
npm run dev
- Open browser
General description of what I try to do:
I have a plugin which on install()
adds a value via provide
to the app. Then I have a component which injects this value again and displays them. Both, the plugin and the component are in an imported module which is installed via npm
. I also added both the plugin and the component directly into the app, to show that it only happens when I use the imported plugin and component.
What is expected?
Under Module Test Component
it should output
Module inject: MODULE TEST
like it does under Local Test Component
.
There should be no warning in the browser console.
What is actually happening?
The injection symbol can't be found and nothing is displayed in the imported component.
In the browser console this warning is visible:
[Vue warn]: injection "Symbol(module provide test)" not found.
at <ModuleTestComponent>
at <App>
Using the exact same injection symbol in a local component correctly injects the value.
System Info
No response
Any additional comments?
- The imported module is not pre-built in any way, it just contains the source code. The project which imports the module should be in charge of building and bundling everything.
- It works correct when building the project and running it.
- It also works when I exclude the imported module in
optimizeDeps
, but I'm not sure if that's the expected behavior. (I've commented this in the providedvite.config.ts
, so you can test it by just uncommenting this) - I've also done a quick test without typescript and without an injection key, just a normal string and it also seems to work.