@@ -170,7 +170,7 @@ func (ctx *BuildContext) Build(buildCtx context.Context) (meta *BuildMeta, err e
170170 }
171171
172172 // analyze splitting modules if bundling
173- if ctx .pkgJson .Exports .Len () > 1 && ! ctx .isNoBundle () {
173+ if ctx .pkgJson .Exports .Len () > 1 && ctx .shouldBundle () {
174174 ctx .status = "analyze"
175175 err = ctx .analyzeSplitting ()
176176 if err != nil {
@@ -400,7 +400,7 @@ func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, include
400400
401401 browserExclude := map [string ]* set.Set [string ]{}
402402 implicitExternal := set .New [string ]()
403- noBundle := ctx .isNoBundle ()
403+ noBundle := ! ctx .shouldBundle ()
404404 esmifyPlugin := esbuild.Plugin {
405405 Name : "esmify" ,
406406 Setup : func (build esbuild.PluginBuild ) {
@@ -1083,6 +1083,20 @@ func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, include
10831083 // disable minification for development build
10841084 minify = false
10851085 }
1086+ keepNames := ctx .args .KeepNames
1087+ ignoreAnnotations := ctx .args .IgnoreAnnotations
1088+ if esmsh := ctx .pkgJson .Esmsh ; esmsh != nil {
1089+ if v , ok := esmsh ["keepNames" ]; ok {
1090+ if b , ok := v .(bool ); ok {
1091+ keepNames = b
1092+ }
1093+ }
1094+ if v , ok := esmsh ["ignoreAnnotations" ]; ok {
1095+ if b , ok := v .(bool ); ok {
1096+ ignoreAnnotations = b
1097+ }
1098+ }
1099+ }
10861100 options := esbuild.BuildOptions {
10871101 AbsWorkingDir : ctx .wd ,
10881102 PreserveSymlinks : true ,
@@ -1097,8 +1111,8 @@ func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, include
10971111 MinifyWhitespace : minify ,
10981112 MinifyIdentifiers : minify ,
10991113 MinifySyntax : minify ,
1100- KeepNames : ctx . args . KeepNames , // prevent class/function names erasing
1101- IgnoreAnnotations : ctx . args . IgnoreAnnotations , // some libs maybe use wrong side-effect annotations
1114+ KeepNames : keepNames ,
1115+ IgnoreAnnotations : ignoreAnnotations ,
11021116 Conditions : conditions ,
11031117 Loader : loaders ,
11041118 Plugins : []esbuild.Plugin {esmifyPlugin },
@@ -1598,14 +1612,16 @@ func (ctx *BuildContext) install() (err error) {
15981612 return
15991613}
16001614
1601- func (ctx * BuildContext ) isNoBundle () bool {
1602- noBundle := ctx .bundleMode == BundleFalse || ctx .pkgJson .SideEffects .Len () > 0
1615+ func (ctx * BuildContext ) shouldBundle () bool {
1616+ if ctx .bundleMode == BundleFalse || ctx .pkgJson .SideEffects .Len () > 0 {
1617+ return false
1618+ }
16031619 if ctx .pkgJson .Esmsh != nil {
16041620 if v , ok := ctx .pkgJson .Esmsh ["bundle" ]; ok {
16051621 if b , ok := v .(bool ); ok && ! b {
1606- noBundle = true
1622+ return false
16071623 }
16081624 }
16091625 }
1610- return noBundle
1626+ return true
16111627}
0 commit comments