()
| 199 | } |
| 200 | |
| 201 | func (ctx *BuildContext) buildPath() { |
| 202 | asteriskPrefix := "" |
| 203 | if ctx.externalAll { |
| 204 | asteriskPrefix = "*" |
| 205 | } |
| 206 | |
| 207 | esm := ctx.esmPath |
| 208 | if ctx.target == "types" { |
| 209 | if strings.HasSuffix(esm.SubPath, ".d.ts") { |
| 210 | ctx.path = fmt.Sprintf( |
| 211 | "/%s%s/%s%s", |
| 212 | asteriskPrefix, |
| 213 | esm.PackageId(), |
| 214 | ctx.getBuildArgsPrefix(true), |
| 215 | esm.SubPath, |
| 216 | ) |
| 217 | } else { |
| 218 | ctx.path = "/" + esm.String() |
| 219 | } |
| 220 | return |
| 221 | } |
| 222 | |
| 223 | name := strings.TrimSuffix(path.Base(esm.PkgName), ".js") |
| 224 | if esm.SubPath != "" { |
| 225 | if esm.SubPath == name { |
| 226 | // if the sub-module name is same as the package name |
| 227 | name = "__" + esm.SubPath |
| 228 | } else { |
| 229 | name = esm.SubPath |
| 230 | } |
| 231 | // workaround for es5-ext "../#/.." path |
| 232 | if esm.PkgName == "es5-ext" { |
| 233 | name = strings.ReplaceAll(name, "/#/", "/%23/") |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | if ctx.dev { |
| 238 | name += ".development" |
| 239 | } |
| 240 | switch ctx.bundleMode { |
| 241 | case BundleDeps: |
| 242 | name += ".bundle" |
| 243 | case BundleFalse: |
| 244 | name += ".nobundle" |
| 245 | } |
| 246 | ctx.path = fmt.Sprintf( |
| 247 | "/%s%s/%s%s/%s.mjs", |
| 248 | asteriskPrefix, |
| 249 | esm.PackageId(), |
| 250 | ctx.getBuildArgsPrefix(ctx.target == "types"), |
| 251 | ctx.target, |
| 252 | name, |
| 253 | ) |
| 254 | } |
| 255 | |
| 256 | func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, includes [][2]string, err error) { |
| 257 | if err = ctx.checkCanceled(); err != nil { |
no test coverage detected