Skip to content

Commit a51a18f

Browse files
committed
feat: added bundle option
1 parent 1f5da2e commit a51a18f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

internal/cli/cli.go

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var (
2222
exportConditions []string
2323
sourcemap string
2424
cleanDist bool
25+
bundle bool
2526
)
2627

2728
var rootCmd = &cobra.Command{
@@ -45,6 +46,7 @@ func init() {
4546
rootCmd.Flags().StringSliceVar(&exportConditions, "export-condition", []string{}, "Export conditions for resolving dependency export and import maps")
4647
rootCmd.Flags().StringVar(&sourcemap, "sourcemap", "", "Sourcemap generation. Provide 'inline' for inline sourcemap")
4748
rootCmd.Flags().BoolVar(&cleanDist, "clean-dist", false, "Clean dist before bundling")
49+
rootCmd.Flags().BoolVar(&bundle, "bundle", true, "Bundle all dependencies")
4850
}
4951

5052
func run(cmd *cobra.Command, args []string) {
@@ -73,6 +75,7 @@ func run(cmd *cobra.Command, args []string) {
7375
ExportConditions: exportConditions,
7476
Sourcemap: sourcemap,
7577
CleanDist: cleanDist,
78+
Bundle: bundle,
7679
}
7780

7881
bundler := esbuild.NewBundler(bundlerConfig, pkg)

pkg/esbuild/esbuild.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type BundlerConfig struct {
2222
ExportConditions []string
2323
Sourcemap string
2424
CleanDist bool
25+
Bundle bool
2526
}
2627

2728
type Bundler struct {
@@ -191,12 +192,17 @@ func (b *Bundler) getDefine() map[string]string {
191192

192193
func (b *Bundler) getExternalDependencies() []string {
193194
externals := make([]string, 0)
194-
for dep := range b.pkg.Dependencies {
195-
externals = append(externals, dep)
195+
if !b.config.Bundle {
196+
for dep := range b.pkg.Dependencies {
197+
externals = append(externals, dep)
198+
}
196199
}
197200
for dep := range b.pkg.PeerDependencies {
198201
externals = append(externals, dep)
199202
}
203+
for dep := range b.pkg.DevDependencies {
204+
externals = append(externals, dep)
205+
}
200206
return externals
201207
}
202208

0 commit comments

Comments
 (0)