diff --git a/src/types.ts b/src/types.ts index bf2197a..b8dc6b6 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,6 +7,7 @@ export interface Component { filePath: string shortPath: string isAsync?: boolean + isAbsolute?: boolean chunkName: string /** @deprecated */ global: boolean diff --git a/templates/components/index.js b/templates/components/index.js index fe252b2..e19b49d 100644 --- a/templates/components/index.js +++ b/templates/components/index.js @@ -4,13 +4,14 @@ 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.isAbsolute ? 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') %>