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 480bba4 commit 6c878e1
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 124 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
126 changes: 14 additions & 112 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.27.0-dev.0",
"description": "The Pyodide JavaScript package",
"keywords": [
Expand All @@ -15,122 +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",
"sinon": "^18.0.0",
"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-inner": "node esbuild.config.inner.mjs",
"build": "tsc --noEmit && node esbuild.config.outer.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: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
3 changes: 2 additions & 1 deletion src/js/pyodide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ declare function _createPyodideModule(
// It is used to check that memory snapshots were generated by the same build of
// the runtime that is trying to use them. Attempting to use a snapshot from a
// different build will fail badly. See logic in snapshot.ts.
declare const BUILD_ID: string;
// Here we set BUILD_ID to an empty string so that the check is disabled.
const BUILD_ID = "";

/**
* See documentation for loadPyodide.
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 6c878e1

Please sign in to comment.