Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface Component {
filePath: string
shortPath: string
isAsync?: boolean
resolvePath?: boolean
chunkName: string
/** @deprecated */
global: boolean
Expand Down
7 changes: 5 additions & 2 deletions templates/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
c.prefetch === true || typeof c.prefetch === 'number' ? `webpackPrefetch: ${c.prefetch}` : false,
c.preload === true || typeof c.preload === 'number' ? `webpackPreload: ${c.preload}` : false,
].filter(Boolean).join(', ')
const filePath = (c.resolvePath === false || ['~', '@'].includes(c.filePath[0]))
? c.filePath
: `../${relativeToBuild(c.filePath)}`
if (c.isAsync === true || (!isDev /* prod fallback */ && c.isAsync === null)) {
const exp = c.export === 'default' ? `c.default || c` : `c['${c.export}']`
const asyncImport = `() => import('../${relativeToBuild(c.filePath)}' /* ${magicComments} */).then(c => wrapFunctional(${exp}))`
const asyncImport = `() => import('${filePath}' /* ${magicComments} */).then(c => wrapFunctional(${exp}))`
return `export const ${c.pascalName} = ${asyncImport}`
} else {
const exp = c.export === 'default' ? `default as ${c.pascalName}` : c.pascalName
return `export { ${exp} } from '../${relativeToBuild(c.filePath)}'`
return `export { ${exp} } from '${filePath}'`
}
}).join('\n') %>

Expand Down