Describe the bug
Components imported using nuxt/components with isAsync option set to false are imported asynchronously when building for production using nuxt build.
To Reproduce
Steps to reproduce the behavior:
- Clone repository https://github.com/gtnsimon/codesandbox-nuxt
- Go to the branch
bug/non-async-components - Run
yarn then yarn run build - Open generated file
.nuxt/components/index.js
First line is:
exportconstTutorial=()=>import('../../components/Tutorial.vue'/* webpackChunkName: "components/tutorial" */).then(c=>wrapFunctional(c.default||c))Expected behavior
Generated file .nuxt/components/index.js should import components synchronously.
In development when we run Nuxt using yarn run dev the first line is a synchronous import which is expected as directory options explicitly set isAsync: false:
export{defaultasTutorial}from'../../components/Tutorial.vue'Additional context
I'm running nuxt v2.15.8 which embeds @nuxt/components v2.1.8 and above (v2.2.1 when I check installed node_modules).
While trying to debug I found code which may cause the issue:
My nuxt.config.js
exportdefault{/* ... */// Auto import components: https://go.nuxtjs.dev/config-componentscomponents: [{path: '~/components',isAsync: false}],// custom options with `isAsync: false`/* ... */}Merci 😊
Describe the bug
Components imported using
nuxt/componentswithisAsyncoption set tofalseare imported asynchronously when building for production usingnuxt build.To Reproduce
Steps to reproduce the behavior:
bug/non-async-componentsyarnthenyarn run build.nuxt/components/index.jsFirst line is:
Expected behavior
Generated file
.nuxt/components/index.jsshould import components synchronously.In development when we run Nuxt using
yarn run devthe first line is a synchronous import which is expected as directory options explicitly setisAsync: false:Additional context
I'm running
nuxtv2.15.8 which embeds@nuxt/componentsv2.1.8 and above (v2.2.1 when I check installed node_modules).While trying to debug I found code which may cause the issue:
components/src/scan.ts
Line 42 in 86ab5e0
Ternary operator will always fallback to
nullwhen file doesn't contains .async anddirIsAsyncis nottrue. Settingsfalsewill be replaced tonull.components/templates/components/index.js
Line 7 in 86ab5e0
This condition is met because I'm running a production build and
isAsyncis nownullbecause replaced by the above code so it use theasyncImportsyntax defined.allow setting directory isAsync = false in options #239
seems to address the issue but I don't know about changing
nulltotrue.My nuxt.config.js
Merci 😊