Skip to content

Commit

Permalink
Refactor build process
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 authored Sep 24, 2024
1 parent 6c7be8d commit 0687808
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 121 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on: [push, pull_request, workflow_dispatch, release]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v1

- name: Build package
working-directory: src/js
run: bun build pyodide.ts --outdir=dist --sourcemap=linked

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: src/js

preview:
runs-on: ubuntu-latest

needs: build

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: build
path: .

- name: Publish to pkg.pr.new
run: npx pkg-pr-new publish

publish:
runs-on: ubuntu-latest

needs: build

permissions:
contents: write
id-token: write

steps:
- uses: actions/setup-node@v4
with:
node-version: latest
registry-url: https://registry.npmjs.org

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: build
path: .

- name: List files
run: tree -s -h

- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
if [ "${{ github.event_name }}" == "release" ]; then
npm publish --provenance --access public
else
npm publish --provenance --access public --dry-run
fi
10 changes: 0 additions & 10 deletions src/js/emscripten-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,6 @@ function getFileSystemInitializationFuncs(config: ConfigType): PreRunFunc[] {
function getInstantiateWasmFunc(
indexURL: string,
): EmscriptenSettings["instantiateWasm"] {
if (SOURCEMAP) {
// According to the docs:
//
// "Sanitizers or source map is currently not supported if overriding
// WebAssembly instantiation with Module.instantiateWasm."
// https://emscripten.org/docs/api_reference/module.html?highlight=instantiatewasm#Module.instantiateWasm
//
// I haven't checked if this is actually a problem in practice.
return;
}
const { binary, response } = getBinaryResponse(indexURL + "pyodide.asm.wasm");
return function (
imports: { [key: string]: any },
Expand Down
124 changes: 14 additions & 110 deletions src/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"name": "pyodide",
"name": "@promplate/pyodide-bootstrap",
"publishConfig": {
"access": "public"
},
"version": "0.26.2",
"description": "The Pyodide JavaScript package",
"keywords": [
Expand All @@ -15,120 +18,21 @@
"url": "https://github.com/pyodide/pyodide/issues"
},
"license": "Apache-2.0",
"devDependencies": {
"@types/assert": "^1.5.6",
"@types/expect": "^24.3.0",
"@types/mocha": "^9.1.0",
"@types/node": "^20.8.4",
"@types/ws": "^8.5.3",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.3",
"dts-bundle-generator": "^8.1.1",
"esbuild": "^0.17.12",
"express": "^4.17.3",
"mocha": "^9.0.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"ts-mocha": "^9.0.2",
"tsd": "^0.24.1",
"typedoc": "^0.25.1",
"typescript": "^4.6.4",
"wabt": "^1.0.32"
},
"main": "pyodide.js",
"exports": {
".": {
"require": "./pyodide.js",
"import": "./pyodide.mjs",
"types": "./pyodide.d.ts"
},
"./ffi": {
"types": "./ffi.d.ts"
},
"./pyodide.asm.wasm": "./pyodide.asm.wasm",
"./pyodide.asm.js": "./pyodide.asm.js",
"./python_stdlib.zip": "./python_stdlib.zip",
"./pyodide.mjs": "./pyodide.mjs",
"./pyodide.js": "./pyodide.js",
"./package.json": "./package.json",
"./pyodide-lock.json": "./pyodide-lock.json"
"import": "./dist/pyodide.js",
"types": "./pyodide.ts"
}
},
"files": [
"pyodide.asm.js",
"pyodide.asm.wasm",
"python_stdlib.zip",
"pyodide.mjs",
"pyodide.js.map",
"pyodide.mjs.map",
"pyodide.d.ts",
"ffi.d.ts",
"pyodide-lock.json",
"console.html"
"dist",
"pyodide.ts",
"api.ts",
"types.ts",
"emscripten-settings.ts",
"snapshot.ts"
],
"browser": {
"child_process": false,
"crypto": false,
"fs": false,
"fs/promises": false,
"path": false,
"url": false,
"vm": false,
"ws": false
},
"scripts": {
"build": "tsc --noEmit && node esbuild.config.mjs",
"test": "npm-run-all test:*",
"test:unit": "cross-env TEST_NODE=1 ts-mocha --node-option=experimental-loader=./test/loader.mjs --node-option=experimental-wasm-stack-switching -p tsconfig.test.json test/unit/**/*.test.*",
"test:node": "cross-env TEST_NODE=1 mocha test/integration/**/*.test.js",
"test:browser": "mocha test/integration/**/*.test.js",
"tsc": "tsc --noEmit",
"coverage": "cross-env TEST_NODE=1 npm-run-all coverage:*",
"coverage:build": "nyc npm run test:node"
},
"mocha": {
"bail": false,
"timeout": 30000,
"full-trace": true,
"inline-diffs": true,
"check-leaks": false,
"global": [
"pyodide",
"page",
"chai"
]
},
"nyc": {
"reporter": [
"html",
"text-summary"
],
"include": [
"*.ts"
],
"all": true,
"clean": true,
"cache": false,
"instrument": false,
"checkCoverage": true,
"statements": 95,
"functions": 95,
"branches": 80,
"lines": 95
},
"tsd": {
"compilerOptions": {
"lib": [
"ES2017",
"DOM"
]
}
},
"dependencies": {
"ws": "^8.5.0"
},
"types": "./pyodide.d.ts",
"types": "./pyodide.ts",
"engines": {
"node": ">=18.0.0"
}
Expand Down
1 change: 0 additions & 1 deletion src/js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"tsBuildInfoFile": "tsconfig.tsbuildinfo",
"strict": true,
"noUnusedLocals": false,
"types": ["node"],
"experimentalDecorators": true,
"lib": ["ES2022", "DOM"],
"resolveJsonModule": true,
Expand Down

0 comments on commit 0687808

Please sign in to comment.