Skip to content

Commit 58ad868

Browse files
authored
fix: reuse flags for native bundler (#3485)
1 parent fc12a40 commit 58ad868

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

internal/functions/deploy/bundle.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (b *dockerBundler) Bundle(ctx context.Context, slug, entrypoint, importMap
5050
}
5151
hostOutputPath := filepath.Join(hostOutputDir, "output.eszip")
5252
// Create exec command
53-
cmd := []string{"bundle", "--entrypoint", utils.ToDockerPath(entrypoint), "--output", utils.ToDockerPath(hostOutputPath), "--decorator", "tc39"}
53+
cmd := []string{"bundle", "--entrypoint", utils.ToDockerPath(entrypoint), "--output", utils.ToDockerPath(hostOutputPath)}
5454
if len(importMap) > 0 {
5555
cmd = append(cmd, "--import-map", utils.ToDockerPath(importMap))
5656
}
@@ -60,6 +60,7 @@ func (b *dockerBundler) Bundle(ctx context.Context, slug, entrypoint, importMap
6060
if viper.GetBool("DEBUG") {
6161
cmd = append(cmd, "--verbose")
6262
}
63+
cmd = append(cmd, function.BundleFlags...)
6364

6465
env := []string{}
6566
if custom_registry := os.Getenv("NPM_CONFIG_REGISTRY"); custom_registry != "" {

pkg/function/bundle.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ func NewNativeBundler(tempDir string, fsys fs.FS) EszipBundler {
2929
}
3030
}
3131

32-
// Use a package private variable to allow testing without gosec complaining about G204
33-
var edgeRuntimeBin = "edge-runtime"
32+
var (
33+
// Use a package private variable to allow testing without gosec complaining about G204
34+
edgeRuntimeBin = "edge-runtime"
35+
BundleFlags = []string{
36+
"--decorator", "tc39",
37+
}
38+
)
3439

3540
func (b *nativeBundler) Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, output io.Writer) (api.FunctionDeployMetadata, error) {
3641
meta := NewMetadata(slug, entrypoint, importMap, staticFiles)
@@ -43,6 +48,7 @@ func (b *nativeBundler) Bundle(ctx context.Context, slug, entrypoint, importMap
4348
for _, staticFile := range staticFiles {
4449
args = append(args, "--static", staticFile)
4550
}
51+
args = append(args, BundleFlags...)
4652
cmd := exec.CommandContext(ctx, edgeRuntimeBin, args...)
4753
cmd.Stderr = os.Stderr
4854
cmd.Stdout = os.Stdout

0 commit comments

Comments
 (0)