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

Replace patch with hoist script #12

Merged
merged 1 commit into from
Jun 27, 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
3 changes: 1 addition & 2 deletions buildtools/wasm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ RUN corepack enable

COPY buildtools/wasm/package.json buildtools/wasm/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY buildtools/wasm/*.mjs ./
COPY buildtools/wasm/*.ts ./
COPY buildtools/wasm/tsconfig.json ./
RUN pnpm run build
COPY buildtools/wasm/patch.txt ./
RUN patch -p0 < patch.txt

FROM ghcr.io/webassembly/wasi-sdk:wasi-sdk-21

Expand Down
31 changes: 31 additions & 0 deletions buildtools/wasm/hoist-imports.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import readline from "node:readline";

async function run() {
const lines = readline.createInterface({
input: process.stdin,
terminal: false,
});

const imports = [];
const others = [];

for await (const line of lines) {
if (
line.startsWith("import ") &&
(line.endsWith(' "std";') || line.endsWith(' "os";'))
) {
imports.push(line);
} else {
others.push(line);
}
}

for (const line of imports) {
console.log(line);
}
for (const line of others) {
console.log(line);
}
}

await run();
2 changes: 1 addition & 1 deletion buildtools/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"type": "module",
"scripts": {
"build": "esbuild --external:std --bundle protoc-gen-connect-es.ts --format=esm --outfile=dist/protoc-gen-connect-es.js"
"build": "esbuild --external:std --bundle protoc-gen-connect-es.ts --format=esm | node hoist-imports.mjs > dist/protoc-gen-connect-es.js"
},
"keywords": [],
"author": "",
Expand Down
19 changes: 0 additions & 19 deletions buildtools/wasm/patch.txt

This file was deleted.