Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from esm-dev:main #58

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
deploy:
name: Deploy esm.sh to production
runs-on: ubuntu-latest
environment: production
environment: esm.sh

steps:
- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy
name: Stage

on:
push:
Expand Down
59 changes: 59 additions & 0 deletions server/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,65 @@ var loaders = map[string]esbuild.Loader{
".woff2": esbuild.LoaderDataURL,
}

func (ctx *BuildContext) Path() string {
if ctx.path != "" {
return ctx.path
}

asteriskPrefix := ""
if ctx.externalAll {
asteriskPrefix = "*"
}

esm := ctx.esm
if ctx.target == "types" {
if strings.HasSuffix(esm.SubPath, ".d.ts") {
ctx.path = fmt.Sprintf(
"/%s%s/%s%s",
asteriskPrefix,
esm.Name(),
ctx.getBuildArgsPrefix(true),
esm.SubPath,
)
} else {
ctx.path = "/" + esm.Specifier()
}
return ctx.path
}

name := strings.TrimSuffix(path.Base(esm.PkgName), ".js")
if esm.SubModuleName != "" {
if esm.SubModuleName == name {
// if the sub-module name is same as the package name
name = "__" + esm.SubModuleName
} else {
name = esm.SubModuleName
}
// workaround for es5-ext "../#/.." path
if esm.PkgName == "es5-ext" {
name = strings.ReplaceAll(name, "/#/", "/%23/")
}
}

if ctx.dev {
name += ".development"
}
if ctx.bundleMode == BundleAll {
name += ".bundle"
} else if ctx.bundleMode == BundleFalse {
name += ".nobundle"
}
ctx.path = fmt.Sprintf(
"/%s%s/%s%s/%s.mjs",
asteriskPrefix,
esm.Name(),
ctx.getBuildArgsPrefix(ctx.target == "types"),
ctx.target,
name,
)
return ctx.path
}

func (ctx *BuildContext) Exists() (meta *BuildMeta, ok bool, err error) {
key := ctx.getSavepath() + ".meta"
meta, err = withLRUCache(key, func() (*BuildMeta, error) {
Expand Down
Loading
Loading