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 #45

Merged
merged 1 commit into from
Dec 25, 2024
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
9 changes: 6 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
deploy:
name: Deploy main branch to next.esm.sh
runs-on: ubuntu-latest
environment: next

steps:
- name: Checkout
Expand All @@ -23,6 +24,8 @@ jobs:
env:
GOOS: linux
GOARCH: ${{ secrets.DEPLOY_HOST_ARCH }}
SSH_HOST_NAME: ${{ secrets.DEPLOY_HOST_NAME }}
SSH_USER: ${{ secrets.DEPLOY_SSH_USER }}
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
DEPLOY_HOST_NAME: ${{ secrets.DEPLOY_HOST_NAME }}
DEPLOY_HOST_PORT: ${{ secrets.DEPLOY_HOST_PORT }}
DEPLOY_SSH_USER: ${{ secrets.DEPLOY_SSH_USER }}
DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
VERSION: ${{ github.sha }}
11 changes: 6 additions & 5 deletions scripts/deploy-ci.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/bin/bash

mkdir -p ~/.ssh
ssh-keyscan $SSH_HOST_NAME >> ~/.ssh/known_hosts
echo "${SSH_PRIVATE_KEY}" >> ~/.ssh/id_ed25519
ssh-keyscan $DEPLOY_HOST_NAME >> ~/.ssh/known_hosts
echo "${DEPLOY_SSH_PRIVATE_KEY}" >> ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "Host next.esm.sh" >> ~/.ssh/config
echo " HostName ${SSH_HOST_NAME}" >> ~/.ssh/config
echo " User ${SSH_USER}" >> ~/.ssh/config
echo " HostName ${DEPLOY_HOST_NAME}" >> ~/.ssh/config
echo " Port ${DEPLOY_HOST_PORT}" >> ~/.ssh/config
echo " User ${DEPLOY_SSH_USER}" >> ~/.ssh/config
echo " IdentityFile ~/.ssh/id_ed25519" >> ~/.ssh/config
echo " IdentitiesOnly yes" >> ~/.ssh/config

echo "--- building..."
go build -ldflags="-s -w" -o esmd $(dirname $0)/../main.go
go build -ldflags="-s -w -X 'github.com/esm-dev/esm.sh/server.Version=${VERSION}'" -o esmd $(dirname $0)/../main.go
if [ "$?" != "0" ]; then
exit 1
fi
Expand Down
12 changes: 6 additions & 6 deletions server/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func (ctx *BuildContext) Build() (meta *BuildMeta, err error) {
// }
// }
// if !exportAll {

// for _, exportName := range exportNames {
// esm := ctx.esm
// esm.SubPath = exportName
Expand Down Expand Up @@ -225,8 +224,7 @@ func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, depTree
if analyzeMode {
return
}
nmDir := path.Join(ctx.wd, "node_modules")
jsonPath := path.Join(nmDir, ctx.esm.PkgName, ctx.esm.SubModuleName)
jsonPath := path.Join(ctx.wd, "node_modules", ctx.esm.PkgName, ctx.esm.SubModuleName)
if existsFile(jsonPath) {
var jsonData []byte
jsonData, err = os.ReadFile(jsonPath)
Expand Down Expand Up @@ -735,13 +733,15 @@ func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, depTree
// - it's not a dynamic import and `?bundle=false` query is not present
if moduleSpecifier == entry.main || (exportSpecifier != "" && exportSpecifier == entrySpecifier) || (args.Kind != esbuild.ResolveJSDynamicImport && !noBundle) {
if existsFile(moduleFilename) {
pkgDir := path.Join(ctx.wd, "node_modules", ctx.esm.PkgName)
moduleName := strings.TrimPrefix(moduleSpecifier, pkgDir)[1:]
if analyzeMode && moduleFilename != entryModuleFilename {
depTree.lock.Lock()
depTree.refs[moduleFilename] = append(depTree.refs[moduleFilename], args.Importer)
depTree.refs[moduleName] = append(depTree.refs[moduleName], strings.TrimPrefix(args.Importer, pkgDir)[1:])
depTree.lock.Unlock()
}
if !analyzeMode && ctx.splitting != nil && ctx.splitting.Has(moduleFilename) && !ctx.splitting.Has(entryModuleFilename) {
fmt.Println("splitting", moduleFilename)
if !analyzeMode && ctx.splitting != nil && ctx.splitting.Has(moduleName) {
fmt.Println("splitting", moduleName)
}
// embed wasm as WebAssembly.Module
if strings.HasSuffix(moduleFilename, ".wasm") {
Expand Down
2 changes: 1 addition & 1 deletion server/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
package server

const DEBUG = true
const VERSION = "dev"
const Version = "DEV"
1 change: 1 addition & 0 deletions server/loader_implements.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func compileUnocssLoader(npmrc *NpmRC, loaderVersion string, loaderExecPath stri
"deno", "compile",
"--no-config",
"--no-lock",
"--no-check",
"--include=jsr:@std/tar/untar-stream",
"--no-prompt",
"--allow-read="+config.WorkDir+"/cache",
Expand Down
4 changes: 3 additions & 1 deletion server/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
package server

const DEBUG = false
const VERSION = "v136"

// may be changed by `-ldflags`
var Version = "v136"
4 changes: 2 additions & 2 deletions server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (
func esmRouter() rex.Handle {
var (
startTime = time.Now()
globalETag = fmt.Sprintf(`W/"%s"`, VERSION)
globalETag = fmt.Sprintf(`W/"%s"`, Version)
)

return func(ctx *rex.Context) any {
Expand Down Expand Up @@ -272,7 +272,7 @@ func esmRouter() rex.Handle {
ctx.Header.Set("Cache-Control", ccMustRevalidate)
return map[string]any{
"buildQueue": q[:i],
"version": VERSION,
"version": Version,
"uptime": time.Since(startTime).String(),
"disk": disk,
}
Expand Down
2 changes: 1 addition & 1 deletion server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

var (
bufferPool = sync.Pool{New: func() interface{} { return new(bytes.Buffer) }}
defaultUserAgent = "esmd/" + VERSION
defaultUserAgent = "esmd/" + Version
)

var (
Expand Down
Loading