Skip to content

Commit 7fd1983

Browse files
authored
Fix standalone mode (esm-dev#1367)
1 parent 6debc6e commit 7fd1983

6 files changed

Lines changed: 258 additions & 197 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
strategy:
1515
matrix:
16-
deno-version: [1.x, 2.x]
16+
deno-version: [1.x, 2.7.x]
1717

1818
steps:
1919
- name: Checkout

internal/npm/package_json.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"io"
9-
"path"
109
"strings"
1110

1211
"github.com/ije/gox/set"
@@ -72,7 +71,7 @@ type PackageJSON struct {
7271
// ToNpmPackage converts PackageJSONRaw to PackageJSON
7372
func (a *PackageJSONRaw) ToNpmPackage() *PackageJSON {
7473
browser := map[string]string{}
75-
if a.Browser.str != "" && hasModuleExt(a.Browser.str) {
74+
if a.Browser.str != "" {
7675
browser["."] = a.Browser.str
7776
}
7877
if a.Browser.object != nil {
@@ -119,7 +118,7 @@ func (a *PackageJSONRaw) ToNpmPackage() *PackageJSON {
119118
if s, ok := a.SideEffects.(string); ok {
120119
if s == "false" {
121120
sideEffectsFalse = true
122-
} else if hasModuleExt(s) {
121+
} else {
123122
sideEffects = set.New(s)
124123
}
125124
} else if b, ok := a.SideEffects.(bool); ok {
@@ -128,7 +127,7 @@ func (a *PackageJSONRaw) ToNpmPackage() *PackageJSON {
128127
if len(m) > 0 {
129128
sideEffects = set.New[string]()
130129
for _, v := range m {
131-
if name, ok := v.(string); ok && hasModuleExt(name) {
130+
if name, ok := v.(string); ok {
132131
sideEffects.Add(name)
133132
}
134133
}
@@ -419,16 +418,6 @@ func (a *JSONAny) String() string {
419418
return ""
420419
}
421420

422-
// hasModuleExt
423-
func hasModuleExt(s string) bool {
424-
switch path.Ext(s) {
425-
case ".js", ".mjs", ".cjs", ".jsx", ".ts", ".mts", ".cts", ".tsx":
426-
return true
427-
default:
428-
return false
429-
}
430-
}
431-
432421
// asMap converts any value to a map[string]any, if the value is not a map[string]any, return nil
433422
func asMap(v any) map[string]any {
434423
if m, ok := v.(map[string]any); ok {

0 commit comments

Comments
 (0)