Skip to content

Commit c36fd14

Browse files
committed
fix: set default for isAsync in template
1 parent 0fec884 commit c36fd14

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const componentsModule: Module<Options> = function () {
7474
path: dirPath,
7575
extensions,
7676
pattern: dirOptions.pattern || `**/*.{${extensions.join(',')},}`,
77-
isAsync: dirOptions.isAsync ?? !nuxt.options.dev /* async only for prod by default */,
77+
isAsync: dirOptions.isAsync,
7878
// TODO: keep test/unit/utils.ts updated
7979
ignore: [
8080
'**/*.stories.{js,ts,jsx,tsx}', // ignore storybook files

src/scan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function scanComponents (dirs: ScanDir[], srcDir: string): Promise<
3939
if (fileName.toLowerCase() === 'index') {
4040
fileName = pathPrefix === false ? basename(dirname(filePath)) : '' /* inherits from path */
4141
}
42-
const isAsync = fileName.endsWith('.async') ? true : dirIsAsync
42+
const isAsync = (fileName.endsWith('.async') ? true : dirIsAsync) || null
4343
fileName = fileName.replace(/\.async$/, '')
4444
const fileNameParts = splitByCase(fileName)
4545

templates/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { wrapFunctional } from './utils'
66
c.prefetch === true || typeof c.prefetch === 'number' ? `webpackPrefetch: ${c.prefetch}` : false,
77
c.preload === true || typeof c.preload === 'number' ? `webpackPreload: ${c.preload}` : false,
88
].filter(Boolean).join(', ')
9-
if (c.isAsync) {
9+
if (c.isAsync === true || (!isDev /* prod fallback */ && c.isAsync === null)) {
1010
const exp = c.export === 'default' ? `c.default || c` : `c['${c.export}']`
1111
const asyncImport = `() => import('../${relativeToBuild(c.filePath)}' /* ${magicComments} */).then(c => wrapFunctional(${exp}))`
1212
return `export const ${c.pascalName} = ${asyncImport}`

0 commit comments

Comments
 (0)