File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -1119,12 +1119,30 @@ function vitePluginUseClient(
11191119 const exports = meta . renderedExports
11201120 . map ( ( name ) => ( name === 'default' ? 'default: _default' : name ) )
11211121 . sort ( )
1122- code += `
1123- ${ key } : async () => {
1124- const {${ exports } } = await import(${ id } );
1125- return {${ exports } };
1126- },
1127- `
1122+ if ( this . environment . name === 'client' ) {
1123+ // TODO:
1124+ // - re-export through virtual to fiter renderedExports
1125+ // - replace `import.meta.ROLLUP_FILE_URL_` on our own
1126+ // - handle "vite preload" on our own
1127+ const chunkId = this . emitFile ( {
1128+ type : 'chunk' ,
1129+ id : meta . importId ,
1130+ preserveSignature : 'allow-extension' ,
1131+ } )
1132+ code += `
1133+ ${ key } : async () => {
1134+ const {${ exports } } = await import(import.meta.ROLLUP_FILE_URL_${ chunkId } );
1135+ return {${ exports } };
1136+ },
1137+ `
1138+ } else {
1139+ code += `
1140+ ${ key } : async () => {
1141+ const {${ exports } } = await import(${ id } );
1142+ return {${ exports } };
1143+ },
1144+ `
1145+ }
11281146 }
11291147 code = `export default {${ code } };\n`
11301148 return { code, map : null }
You can’t perform that action at this time.
0 commit comments