Skip to content

Commit

Permalink
Don't replace typeof window for deno target (close #681)
Browse files Browse the repository at this point in the history
  • Loading branch information
ije committed Jul 15, 2023
1 parent fe0404b commit 7d63a99
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions server/build_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ import (

// ensure the length of the returned `js` is not changed to avoid source map mapping issue
func rewriteJS(task *BuildTask, js []byte) []byte {
// most of npm packages check for the `window` object to detect browser environment, but Deno also has the `window` object
// so we need to replace `window` with `Deno`
if task.isDenoTarget() {
for _, r := range [][2]string{
{
"typeof window !== \"undefined\"",
"typeof Deno !== \"undefined\"",
},
{
`typeof window<"u"`,
`typeof Deno <"u"`,
},
} {
js = bytes.Replace(js, []byte(r[0]), []byte(r[1]), -1)
}
}
switch task.Pkg.Name {
case "axios", "cross-fetch", "whatwg-fetch":
if task.isDenoTarget() {
Expand Down

0 comments on commit 7d63a99

Please sign in to comment.