deno.land / x / esm@v135_2 / server / build_rewriter.go

build_rewriter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package server
import ( "bytes" "encoding/json" "os" "path" "regexp")
var regReadTailwindPreflightCSS = regexp.MustCompile(`[a-zA-Z.]+\.readFileSync\(.+?/preflight\.css"\),\s*"utf-?8"\)`)
func (task *BuildTask) rewriteJS(js []byte) (ret []byte, dropSourceMap bool) { switch task.Pkg.Name { case "axios", "cross-fetch", "whatwg-fetch": if task.isDenoTarget() { xhr := []byte("\nimport \"https://deno.land/x/xhr@0.3.0/mod.ts\";") return concatBytes(js, xhr), false }
case "tailwindcss": preflightCSSFile := path.Join(task.wd, "node_modules", "tailwindcss/src/css/preflight.css") if fileExists(preflightCSSFile) { data, err := os.ReadFile(preflightCSSFile) if err == nil { str, _ := json.Marshal(string(data)) return regReadTailwindPreflightCSS.ReplaceAll(js, str), true // drop breaking source map } }
case "iconv-lite": if task.isDenoTarget() && semverLessThan(task.Pkg.Version, "0.5.0") { old := "__Process$.versions.node" new := "__Process$.versions.nope" return bytes.Replace(js, []byte(old), []byte(new), 1), false } } return nil, false}
esm

Version Info

Tagged at
2 months ago