From 673bb52fb6425f1b8a8abf9c47518e872f892dba Mon Sep 17 00:00:00 2001
From: lilnasy <69170106+lilnasy@users.noreply.github.com>
Date: Fri, 12 Apr 2024 00:06:17 +0000
Subject: [PATCH 1/3] `make wasm` -> `pnpm build`
---
.github/workflows/ci.yml | 2 +-
.github/workflows/release.yml | 2 +-
.npmrc | 1 +
Makefile | 16 ----------------
package.json | 2 +-
5 files changed, 4 insertions(+), 19 deletions(-)
create mode 100644 .npmrc
delete mode 100644 Makefile
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 207be043d..009e459df 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -51,7 +51,7 @@ jobs:
cache: 'pnpm'
- name: Build WASM
- run: make wasm
+ run: pnpm build
- name: Install NPM Dependencies
run: pnpm install
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8ecce8932..100fd8561 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -29,7 +29,7 @@ jobs:
cache: 'pnpm'
- name: Build WASM
- run: make wasm
+ run: pnpm build
- name: Install NPM Dependencies
run: pnpm install
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 000000000..f3b569056
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+shell-emulator=true
\ No newline at end of file
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 94ec38338..000000000
--- a/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-GO_FLAGS += "-ldflags=-s -w"
-
-# Avoid embedding the build path in the executable for more reproducible builds
-GO_FLAGS += -trimpath
-
-
-wasm: internal/*/*.go go.mod
- CGO_ENABLED=0 GOOS=js GOARCH=wasm go build $(GO_FLAGS) -o ./packages/compiler/wasm/astro.wasm ./cmd/astro-wasm/astro-wasm.go
-
-
-publish-node:
- make wasm
- cd packages/compiler && pnpm run build
-
-clean:
- git clean -dxf
diff --git a/package.json b/package.json
index 4c3d07287..9340a8c96 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"url": "https://github.com/withastro/compiler.git"
},
"scripts": {
- "build": "make wasm",
+ "build": "CGO_ENABLED=0 GOOS=js GOARCH=wasm go build \"-ldflags=-s -w\" -trimpath -o ./packages/compiler/wasm/astro.wasm ./cmd/astro-wasm/astro-wasm.go",
"build:compiler": "pnpm --filter @astrojs/compiler run build",
"build:all": "pnpm run build && pnpm run build:compiler",
"lint": "eslint \"packages/**/src/**/*.{cjs,js,jsx,mjs,ts,tsx}\"",
From 4011bbe9c956f0c178132d26fea8fb08bb270152 Mon Sep 17 00:00:00 2001
From: lilnasy <69170106+lilnasy@users.noreply.github.com>
Date: Fri, 12 Apr 2024 00:06:53 +0000
Subject: [PATCH 2/3] fix: prevent printing `defineVars()` into an inline
script
---
internal/printer/printer.go | 3 +++
1 file changed, 3 insertions(+)
diff --git a/internal/printer/printer.go b/internal/printer/printer.go
index 0a6274018..67f5d0f63 100644
--- a/internal/printer/printer.go
+++ b/internal/printer/printer.go
@@ -218,6 +218,9 @@ func (p *printer) printDefineVarsOpen(n *astro.Node) {
if !(n.DataAtom == atom.Script || n.DataAtom == atom.Style) {
return
}
+ if n.DataAtom == atom.Style && transform.HasAttr(n, "is:inline") {
+ return
+ }
if !transform.HasAttr(n, "define:vars") {
return
}
From c966a1c32e21296bede37590d52097ed67029ae1 Mon Sep 17 00:00:00 2001
From: lilnasy <69170106+lilnasy@users.noreply.github.com>
Date: Fri, 12 Apr 2024 00:06:59 +0000
Subject: [PATCH 3/3] add test
---
internal/printer/printer_test.go | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go
index bbcfb40cb..728dcc3b5 100644
--- a/internal/printer/printer_test.go
+++ b/internal/printer/printer_test.go
@@ -3285,6 +3285,13 @@ const items = ["Dog", "Cat", "Platipus"];
definedVars: []string{"{color:'green'}"},
},
},
+ {
+ name: "style is:inline define:vars",
+ source: "",
+ want: want{
+ code: ``,
+ },
+ },
{
name: "define:vars on script with StaticExpression turned on",
// 1. An inline script with is:inline - right