-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
useNuxtApp is not defined after build #1268
Comments
It can be worked around by explicitly importing. import { useNuxtApp } from ‘#imports' |
@wattanx thanks!
That seems to fix it so the web app starts. However, tests have a problem with this: Anything special I need to do in tests that test the components that use this import workaround? |
If you are using vitest, you can set this in If alias is not used, the following writing style will also work. import { useNuxtApp } from '@nuxt/bridge/dist/runtime' |
@wattanx we are using jest and @vue/test-utils. I replaced all imports of
This is what thenuxt bridge folder looks like: |
@wattanx I also tried it with
Now the error is this:
Can this be fixed by doing some magic in |
I can't reproduce it. If you can provide me with a reproduction, I can investigate more.
I also think jest can resolve alias by using |
@wattanx adding the alias via moduleNameMapper helped! Unfortunately jest can't deal with ESM - I'm trying to figure this out using babel but no luck yet. This is the jest config
And this is the babel config
|
Environment
Darwin
v20.15.1
2.17.4
3.11.1
2.9.7
[email protected]
webpack
bridge
,ssr
,modern
,telemetry
,components
,head
,loading
,build
,publicRuntimeConfig
,serverHandlers
,devServerHandlers
,devServer
,typescript
,nitro
,buildModules
-
()
,@nuxt/[email protected]
Reproduction
https://github.com/tresorone/tresor-repro
Describe the bug
As part of our nuxt 2 to nuxt 3 migration we ran across an error where
useNuxtApp
is not defined in our build, while it works fine in dev.To reproduce:
npm i
npm run build
npm start
localhost:3000
in your browser and open the javascript consoleYou should see the error
useNuxtApp is not defined
.Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: