(wd, loaderJs, outfile string)
| 63 | } |
| 64 | |
| 65 | func buildLoader(wd, loaderJs, outfile string) (err error) { |
| 66 | ret := esbuild.Build(esbuild.BuildOptions{ |
| 67 | Outfile: outfile, |
| 68 | Stdin: &esbuild.StdinOptions{Contents: loaderJs, ResolveDir: wd}, |
| 69 | Platform: esbuild.PlatformBrowser, |
| 70 | Format: esbuild.FormatESModule, |
| 71 | Target: esbuild.ESNext, |
| 72 | Bundle: true, |
| 73 | MinifySyntax: true, |
| 74 | MinifyWhitespace: true, |
| 75 | MinifyIdentifiers: true, |
| 76 | Write: true, |
| 77 | PreserveSymlinks: true, |
| 78 | Plugins: []esbuild.Plugin{{ |
| 79 | Name: "resolver", |
| 80 | Setup: func(build esbuild.PluginBuild) { |
| 81 | build.OnResolve(esbuild.OnResolveOptions{Filter: ".*"}, func(args esbuild.OnResolveArgs) (esbuild.OnResolveResult, error) { |
| 82 | if strings.HasPrefix(args.Path, "node:") || nodeBuiltinModules[args.Path] { |
| 83 | return esbuild.OnResolveResult{Path: "node:" + strings.TrimPrefix(args.Path, "node:"), External: true}, nil |
| 84 | } |
| 85 | if strings.HasPrefix(args.Path, "jsr:") { |
| 86 | return esbuild.OnResolveResult{Path: args.Path, External: true}, nil |
| 87 | } |
| 88 | return esbuild.OnResolveResult{}, nil |
| 89 | }) |
| 90 | }, |
| 91 | }}, |
| 92 | }) |
| 93 | if len(ret.Errors) > 0 { |
| 94 | err = errors.New(ret.Errors[0].Text) |
| 95 | } |
| 96 | return |
| 97 | } |
no test coverage detected