@@ -52,7 +52,6 @@ export class Appliaction {
52
52
plugins : [ ] ,
53
53
postcss : {
54
54
plugins : [
55
- 'postcss-nested' ,
56
55
'autoprefixer'
57
56
]
58
57
}
@@ -581,20 +580,22 @@ export class Appliaction {
581
580
await this . createMainModule ( )
582
581
583
582
// pre-compile framework modules
584
- const rendererUrl = `${ alephPkgUrl } /framework/${ this . config . framework } /renderer.ts`
585
- await this . compile ( rendererUrl )
586
583
if ( this . isDev ) {
587
584
const mods = [ 'hmr.ts' , 'nomodule.ts' ]
588
585
for ( const mod of mods ) {
589
586
await this . compile ( `${ alephPkgUrl } /framework/core/${ mod } ` )
590
587
}
591
588
}
592
589
593
- // import framework renderer
594
- const { render } = await import ( 'file://' + this . #modules. get ( rendererUrl ) ! . jsFile )
595
- this . #renderer = { render }
590
+ // compile and import framework renderer when ssr is enable
591
+ if ( this . config . ssr ) {
592
+ const rendererUrl = `${ alephPkgUrl } /framework/${ this . config . framework } /renderer.ts`
593
+ await this . compile ( rendererUrl )
594
+ const { render } = await import ( 'file://' + this . #modules. get ( rendererUrl ) ! . jsFile )
595
+ this . #renderer = { render }
596
+ }
596
597
597
- // apply plugins
598
+ // apply server plugins
598
599
for ( const plugin of this . config . plugins ) {
599
600
if ( plugin . type === 'server' ) {
600
601
await plugin . onInit ( this )
@@ -764,39 +765,34 @@ export class Appliaction {
764
765
/** fix import url */
765
766
private fixImportUrl ( importUrl : string ) : string {
766
767
const isRemote = util . isLikelyHttpURL ( importUrl )
767
- const url = new URL ( isRemote ? importUrl : 'file://' + importUrl )
768
- let ext = path . extname ( url . pathname ) || '.js'
769
- let pathname = util . trimSuffix ( url . pathname , ext )
770
768
if ( isRemote ) {
771
- let ok = [ ...pageModuleExts , 'css' , 'pcss' ] . includes ( ext )
772
- if ( ! ok ) {
769
+ const url = new URL ( importUrl )
770
+ let pathname = url . pathname
771
+ let ok = [ ...pageModuleExts , 'css' , 'pcss' ] . includes ( path . extname ( pathname ) . slice ( 1 ) )
772
+ if ( ok ) {
773
773
for ( const plugin of this . config . plugins ) {
774
- if ( plugin . type === 'loader' && plugin . test . test ( url . pathname ) ) {
774
+ if ( plugin . type === 'loader' && plugin . test . test ( pathname ) ) {
775
775
ok = true
776
776
break
777
777
}
778
778
}
779
779
}
780
780
if ( ! ok ) {
781
- ext = '.js'
781
+ pathname += '.js'
782
+ }
783
+ let search = Array . from ( url . searchParams . entries ( ) ) . map ( ( [ key , value ] ) => value ? `${ key } =${ value } ` : key )
784
+ if ( search . length > 0 ) {
785
+ pathname += '_' + search . join ( ',' )
782
786
}
783
- }
784
- let search = Array . from ( url . searchParams . entries ( ) ) . map ( ( [ key , value ] ) => value ? `${ key } =${ value } ` : key )
785
- if ( search . length > 0 ) {
786
- pathname += '_' + search . join ( ',' )
787
- }
788
- if ( isRemote ) {
789
787
return [
790
788
'/-/' ,
791
789
( url . protocol === 'http:' ? 'http_' : '' ) ,
792
790
url . hostname ,
793
791
( url . port ? '_' + url . port : '' ) ,
794
- pathname ,
795
- ext
792
+ pathname
796
793
] . join ( '' )
797
794
}
798
- const result = pathname + ext
799
- return ! isRemote && importUrl . startsWith ( '/api/' ) ? decodeURI ( result ) : result
795
+ return importUrl
800
796
}
801
797
802
798
/** preprocess css with postcss plugins */
@@ -822,7 +818,7 @@ export class Appliaction {
822
818
this . #postcssReady = true
823
819
}
824
820
if ( t !== null ) {
825
- log . debug ( `load ${ this . config . postcss . plugins . length } plugins of postcss in ${ Math . round ( performance . now ( ) - t ) } ms` )
821
+ log . debug ( `${ this . config . postcss . plugins . length } postcss plugins loaded in ${ Math . round ( performance . now ( ) - t ) } ms` )
826
822
}
827
823
const pcss = ( await postcss ( this . config . postcss . plugins . map ( p => {
828
824
if ( typeof p === 'string' ) {
0 commit comments