@@ -41,6 +41,9 @@ export function qwikRollup(opts: QwikPluginOptions): any {
4141 }
4242 return {
4343 esbuild : { include : / \. j s $ / } ,
44+ optimizeDeps : {
45+ include : [ '@builder.io/qwik' , '@builder.io/qwik/jsx-runtime' ] ,
46+ } ,
4447 build : {
4548 polyfillModulePreload : false ,
4649 dynamicImportVarsOptions : {
@@ -128,8 +131,7 @@ export function qwikRollup(opts: QwikPluginOptions): any {
128131
129132 const result = await optimizer . transformFs ( transformOpts ) ;
130133 for ( const output of result . modules ) {
131- let key = optimizer . path . join ( transformOpts . rootDir , output . path ) ! ;
132- key = key . split ( '.' ) . slice ( 0 , - 1 ) . join ( '.' ) ;
134+ const key = optimizer . path . join ( transformOpts . rootDir , output . path ) ! ;
133135 if ( debug ) {
134136 // eslint-disable-next-line no-console
135137 console . debug ( `[QWIK PLUGIN] Module: ${ key } ` ) ;
@@ -166,24 +168,23 @@ export function qwikRollup(opts: QwikPluginOptions): any {
166168 id = optimizer . path . resolve ( dir , id ) ;
167169 }
168170 }
169- if ( transformedOutputs . has ( id ) ) {
170- if ( debug ) {
171- // eslint-disable-next-line no-console
172- console . debug ( `[QWIK PLUGIN] Resolve: ${ id } ${ opts } ` ) ;
173- }
174- return {
175- id,
176- moduleSideEffects : false ,
177- } ;
171+ const tries = [ id , id + '.js' ] ;
172+ if ( [ '.jsx' , '.ts' , '.tsx' ] . includes ( optimizer . path . extname ( id ) ) ) {
173+ tries . push ( removeExtension ( id ) + '.js' ) ;
178174 }
179- if ( [ '.js' , '.jsx' , '.ts' , '.tsx' ] . includes ( optimizer . path . extname ( id ) ) ) {
180- id = id . split ( '.' ) . slice ( 0 , - 1 ) . join ( '.' ) ;
181- if ( transformedOutputs . has ( id ) ) {
175+ for ( const id of tries ) {
176+ const res = transformedOutputs . get ( id ) ;
177+ if ( res ) {
182178 if ( debug ) {
183179 // eslint-disable-next-line no-console
184- console . debug ( `[QWIK PLUGIN] Resolved : ${ id } ` ) ;
180+ console . debug ( `[QWIK PLUGIN] Resolve : ${ id } ${ opts } ` ) ;
185181 }
186- return id ;
182+ const mod = res [ 0 ] ;
183+ const sideEffects = ! mod . isEntry || ! mod . hook ;
184+ return {
185+ id,
186+ moduleSideEffects : sideEffects ,
187+ } ;
187188 }
188189 }
189190 return null ;
@@ -310,7 +311,7 @@ export function qwikRollup(opts: QwikPluginOptions): any {
310311
311312 hooks . forEach ( ( h ) => {
312313 const symbolName = h . name ;
313- let filename = h . canonicalFilename ;
314+ let filename = h . canonicalFilename + '.js' ;
314315 // eslint-disable-next-line
315316 const found = output . find ( ( [ _ , v ] ) => {
316317 return (
@@ -344,6 +345,10 @@ export function qwikRollup(opts: QwikPluginOptions): any {
344345 return plugin ;
345346}
346347
348+ function removeExtension ( id : string ) {
349+ return id . split ( '.' ) . slice ( 0 , - 1 ) . join ( '.' ) ;
350+ }
351+
347352/**
348353 * @alpha
349354 */
0 commit comments