Skip to content

Commit 2e60935

Browse files
committed
feat: allow components to provide absolute import path
1 parent f8667b6 commit 2e60935

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface Component {
77
filePath: string
88
shortPath: string
99
isAsync?: boolean
10+
isAbsolute?: boolean
1011
chunkName: string
1112
/** @deprecated */
1213
global: boolean

templates/components/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
c.prefetch === true || typeof c.prefetch === 'number' ? `webpackPrefetch: ${c.prefetch}` : false,
55
c.preload === true || typeof c.preload === 'number' ? `webpackPreload: ${c.preload}` : false,
66
].filter(Boolean).join(', ')
7+
const filePath = c.isAbsolute ? c.filePath : `../${relativeToBuild(c.filePath)}`
78
if (c.isAsync === true || (!isDev /* prod fallback */ && c.isAsync === null)) {
89
const exp = c.export === 'default' ? `c.default || c` : `c['${c.export}']`
9-
const asyncImport = `() => import('../${relativeToBuild(c.filePath)}' /* ${magicComments} */).then(c => wrapFunctional(${exp}))`
10+
const asyncImport = `() => import('${filePath}' /* ${magicComments} */).then(c => wrapFunctional(${exp}))`
1011
return `export const ${c.pascalName} = ${asyncImport}`
1112
} else {
1213
const exp = c.export === 'default' ? `default as ${c.pascalName}` : c.pascalName
13-
return `export { ${exp} } from '../${relativeToBuild(c.filePath)}'`
14+
return `export { ${exp} } from '${filePath}'`
1415
}
1516
}).join('\n') %>
1617

0 commit comments

Comments
 (0)