diff --git a/js/bundle.go b/js/bundle.go index 39368aa40b3..a6c28290b70 100644 --- a/js/bundle.go +++ b/js/bundle.go @@ -197,7 +197,7 @@ func (b *Bundle) populateExports(updateOptions bool, bi *BundleInstance) error { } switch k { case consts.Options: - if !updateOptions { + if !updateOptions || v == nil { continue } var data []byte diff --git a/js/bundle_test.go b/js/bundle_test.go index ee7853a1f5d..a0f48a8af7a 100644 --- a/js/bundle_test.go +++ b/js/bundle_test.go @@ -214,6 +214,16 @@ func TestNewBundle(t *testing.T) { `) require.NoError(t, err) }) + t.Run("Null", func(t *testing.T) { + t.Parallel() + fs := fsext.NewMemMapFs() + require.NoError(t, fsext.WriteFile(fs, "/options.js", []byte("module.exports={}"), 0o644)) + _, err := getSimpleBundle(t, "/script.js", ` + export {options} from "./options.js"; + export default function() {}; + `, fs) + require.NoError(t, err) + }) t.Run("Invalid", func(t *testing.T) { t.Parallel() invalidOptions := map[string]struct {