mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
chore(wasm/parser): remove parser wasm32-unknown-unknown build (#9865)
In favor of napi wasm32-wasip1-threads build
This commit is contained in:
1 parent
590a258776
commit
c8979d9bff
26 files changed
+3
-820
No files matched your search
@@ -212,7 +212,6 @@ jobs:
|
||||
- '!editors/**'
|
||||
- '!napi/**'
|
||||
- '!npm/**'
|
||||
- '!wasm/**'
|
||||
- '!crates/oxc_linter/**'
|
||||
- '!crates/oxc_language_server/**'
|
||||
- '!tasks/**'
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
name: Release WASM
|
||||
|
||||
permissions: {}
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- wasm/parser/package.json # Please only commit this file, so we don't need to wait for all the other CI jobs to finish.
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check version
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
version_changed: ${{ steps.version.outputs.changed }}
|
||||
steps:
|
||||
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
|
||||
|
||||
- name: Check version changes
|
||||
uses: EndBug/version-check@36ff30f37c7deabe56a30caa043d127be658c425 # v2.1.5
|
||||
id: version
|
||||
with:
|
||||
static-checking: localIsNew
|
||||
file-url: https://unpkg.com/@oxc-parser/wasm/package.json
|
||||
file-name: wasm/parser/package.json
|
||||
|
||||
- name: Set version name
|
||||
if: steps.version.outputs.changed == 'true'
|
||||
env:
|
||||
VERSION_NUMBER: ${{ steps.version.outputs.version }}
|
||||
VERSION_TYPE: ${{ steps.version.outputs.version_type }}
|
||||
run: |
|
||||
echo "Version change found! New version: ${VERSION_NUMBER} (${VERSION_TYPE})"
|
||||
|
||||
build:
|
||||
needs: check
|
||||
if: needs.check.outputs.version_changed == 'true'
|
||||
name: Release WASM
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write # for `pnpm publish --provenance`
|
||||
steps:
|
||||
- uses: taiki-e/checkout-action@b13d20b7cda4e2f325ef19895128f7ff735c0b3d # v1.3.1
|
||||
|
||||
- uses: ./.github/actions/pnpm
|
||||
|
||||
- uses: oxc-project/setup-rust@cd82e1efec7fef815e2c23d296756f31c7cdc03d # v1.0.0
|
||||
with:
|
||||
cache-key: "wasm"
|
||||
tools: wasm-pack
|
||||
|
||||
- name: Build
|
||||
working-directory: wasm/parser
|
||||
run: |
|
||||
rustup target add wasm32-unknown-unknown
|
||||
pnpm run build
|
||||
pnpm run test
|
||||
|
||||
- name: Check
|
||||
working-directory: npm/parser-wasm
|
||||
run: pnpm run check
|
||||
|
||||
- name: Publish
|
||||
working-directory: npm/parser-wasm
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: pnpm publish --provenance --access public --no-git-checks
|
||||
@@ -11,4 +11,3 @@ tasks/prettier_conformance/prettier/**
|
||||
**/*.snap
|
||||
|
||||
crates/oxc_transformer/src/options/es_features.rs
|
||||
npm/oxc-wasm/**
|
||||
Generated
+1
-155
@@ -855,19 +855,6 @@ dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gloo-utils"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.5.0"
|
||||
@@ -1190,16 +1177,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json-strip-comments"
|
||||
version = "1.0.4"
|
||||
@@ -1544,15 +1521,12 @@ version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5482acf27be53699af8214b9067b71117f34d74974db4b0feef1c09b556c274"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"nom",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde-wasm-bindgen",
|
||||
"serde_json",
|
||||
"thiserror 2.0.12",
|
||||
"time",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2021,17 +1995,6 @@ dependencies = [
|
||||
"rustc-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oxc_parser_wasm"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"oxc",
|
||||
"serde",
|
||||
"serde-wasm-bindgen",
|
||||
"tsify",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "oxc_playground_napi"
|
||||
version = "0.0.1"
|
||||
@@ -2187,7 +2150,6 @@ dependencies = [
|
||||
"ryu-js",
|
||||
"serde",
|
||||
"unicode-id-start",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2805,7 +2767,7 @@ checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_derive_internals 0.29.1",
|
||||
"serde_derive_internals",
|
||||
"syn",
|
||||
]
|
||||
|
||||
@@ -2852,17 +2814,6 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-wasm-bindgen"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"serde",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.219"
|
||||
@@ -2874,17 +2825,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive_internals"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e578a843d40b4189a4d66bba51d7684f57da5bd7c304c64e14bd63efbef49509"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive_internals"
|
||||
version = "0.29.1"
|
||||
@@ -3172,7 +3112,6 @@ checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"js-sys",
|
||||
"num-conv",
|
||||
"powerfmt",
|
||||
"serde",
|
||||
@@ -3365,31 +3304,6 @@ dependencies = [
|
||||
"tracing-log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tsify"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6b26cf145f2f3b9ff84e182c448eaf05468e247f148cf3d2a7d67d78ff023a0"
|
||||
dependencies = [
|
||||
"gloo-utils",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tsify-macros",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tsify-macros"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a94b0f0954b3e59bfc2c246b4c8574390d94a4ad4ad246aaf2fb07d7dfd3b47"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde_derive_internals 0.28.0",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.18.0"
|
||||
@@ -3558,74 +3472,6 @@ dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.26.8"
|
||||
|
||||
+1
-4
@@ -1,6 +1,6 @@
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
members = ["apps/*", "crates/*", "napi/*", "tasks/*", "wasm/*"]
|
||||
members = ["apps/*", "crates/*", "napi/*", "tasks/*"]
|
||||
exclude = ["tasks/lint_rules", "tasks/e2e"]
|
||||
|
||||
[workspace.package]
|
||||
@@ -214,7 +214,6 @@ saphyr = "0.0.3"
|
||||
schemars = "0.8.21"
|
||||
self_cell = "1.1.0"
|
||||
seq-macro = "0.3.5"
|
||||
serde-wasm-bindgen = "0.6.5"
|
||||
sha1 = "0.10.6"
|
||||
simdutf8 = { version = "0.1.5", features = ["aarch64_neon"] }
|
||||
similar = "2.7.0"
|
||||
@@ -224,10 +223,8 @@ tempfile = "3.16.0"
|
||||
tokio = "1.43.0"
|
||||
tower-lsp = "0.20.0"
|
||||
tracing-subscriber = "0.3.19"
|
||||
tsify = "0.4.5"
|
||||
ureq = { version = "3.0.5", default-features = false }
|
||||
walkdir = "2.5.0"
|
||||
wasm-bindgen = "0.2.100"
|
||||
|
||||
[workspace.metadata.cargo-shear]
|
||||
ignored = ["napi", "oxc_transform_napi", "oxc_parser_napi", "prettyplease"]
|
||||
|
||||
@@ -73,7 +73,5 @@ serialize = [
|
||||
"oxc_syntax/serialize",
|
||||
]
|
||||
|
||||
wasm = ["oxc_transformer/wasm"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
@@ -36,7 +36,6 @@ unicode-id-start = { workspace = true }
|
||||
|
||||
ryu-js = { workspace = true, optional = true }
|
||||
serde = { workspace = true, features = ["derive"], optional = true }
|
||||
wasm-bindgen = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
@@ -44,7 +43,6 @@ to_js_string = ["dep:ryu-js"]
|
||||
serialize = [
|
||||
"bitflags/serde",
|
||||
"dep:serde",
|
||||
"dep:wasm-bindgen",
|
||||
"oxc_index/serde",
|
||||
"oxc_estree/serialize",
|
||||
]
|
||||
|
||||
@@ -56,18 +56,6 @@ impl Serialize for NodeId {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = r#"
|
||||
export type NodeId = number;
|
||||
export type NodeFlags = {
|
||||
JSDoc: 1,
|
||||
Class: 2,
|
||||
HasYield: 4
|
||||
Parameter: 8
|
||||
};
|
||||
"#;
|
||||
|
||||
bitflags! {
|
||||
/// Contains additional information about an AST node.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
||||
@@ -39,19 +39,6 @@ impl Serialize for ReferenceId {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = r#"
|
||||
export type ReferenceId = number;
|
||||
export type ReferenceFlags = {
|
||||
None: 0,
|
||||
Read: 0b1,
|
||||
Write: 0b10,
|
||||
Type: 0b100,
|
||||
Value: 0b11
|
||||
}
|
||||
"#;
|
||||
|
||||
bitflags! {
|
||||
/// Describes how a symbol is being referenced in the AST.
|
||||
///
|
||||
|
||||
@@ -57,12 +57,6 @@ impl Serialize for ScopeId {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = r#"
|
||||
export type ScopeId = number;
|
||||
"#;
|
||||
|
||||
bitflags! {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ScopeFlags: u16 {
|
||||
|
||||
@@ -80,14 +80,6 @@ impl Serialize for RedeclarationId {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = r#"
|
||||
export type SymbolId = number;
|
||||
export type SymbolFlags = unknown;
|
||||
export type RedeclarationId = unknown;
|
||||
"#;
|
||||
|
||||
bitflags! {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
||||
|
||||
@@ -53,7 +53,3 @@ oxc_sourcemap = { workspace = true }
|
||||
oxc_tasks_common = { workspace = true }
|
||||
pico-args = { workspace = true }
|
||||
similar = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
wasm = ["oxc-browserslist/wasm_bindgen"]
|
||||
@@ -3,7 +3,7 @@ module.exports.wrap = function wrap(result) {
|
||||
return {
|
||||
get program() {
|
||||
if (!program) {
|
||||
// Note: This code is repeated in `wasm/parser/update-bindings.mjs` and `crates/oxc-wasm/update-bindings.mjs`.
|
||||
// Note: This code is repeated in `crates/oxc-wasm/update-bindings.mjs` and `napi/parser/wrap.cjs`.
|
||||
// Any changes should be applied in those 2 scripts too.
|
||||
program = JSON.parse(result.program, function(key, value) {
|
||||
// Set `value` field of `Literal`s for `BigInt`s and `RegExp`s.
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
node_modules/
|
||||
node/
|
||||
web/
|
||||
@@ -1,5 +0,0 @@
|
||||
# Deprecated
|
||||
|
||||
This package is deprecated.
|
||||
|
||||
Please use [`oxc-parser`](https://www.npmjs.com/package/oxc-parser), which includes a `@oxc-parser/binding-wasm32-wasi` build.
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"name": "@oxc-parser/wasm",
|
||||
"version": "0.53.0",
|
||||
"description": "Wasm target for the oxc parser.",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
"TypeScript",
|
||||
"parser"
|
||||
],
|
||||
"author": "Boshen and oxc contributors",
|
||||
"license": "MIT",
|
||||
"homepage": "https://oxc.rs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/oxc-project/oxc",
|
||||
"directory": "wasm/parser"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
},
|
||||
"main": "./node/oxc_parser_wasm.js",
|
||||
"browser": "./web/oxc_parser_wasm.js",
|
||||
"types": "./web/oxc_parser_wasm.d.ts",
|
||||
"files": [
|
||||
"node",
|
||||
"web"
|
||||
],
|
||||
"dependencies": {
|
||||
"@oxc-project/types": "workspace:^"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm run build-node && pnpm run build-web && pnpm run update-bindings && pnpm run copy-files && pnpm run clean-files",
|
||||
"build-node": "pnpm run build-base --target nodejs --out-dir ../../npm/parser-wasm/node .",
|
||||
"build-web": "pnpm run build-base --target web --out-dir ../../npm/parser-wasm/web .",
|
||||
"build-base": "wasm-pack build --release --no-pack",
|
||||
"update-bindings": "node ./update-bindings.mjs",
|
||||
"copy-files": "cp ./package.json ../../npm/parser-wasm/package.json && cp ./README.md ../../npm/parser-wasm/README.md",
|
||||
"clean-files": "rm ../../npm/parser-wasm/*/.gitignore",
|
||||
"test": "vitest ./test",
|
||||
"check": "tsc --lib es2020,dom ./node/oxc_parser_wasm.d.ts"
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ versioned_files = [
|
||||
"napi/minify/package.json",
|
||||
"npm/oxc-types/package.json",
|
||||
"npm/runtime/package.json",
|
||||
"wasm/parser/package.json",
|
||||
]
|
||||
|
||||
[[releases]]
|
||||
|
||||
Generated
-12
@@ -117,12 +117,6 @@ importers:
|
||||
|
||||
npm/oxlint: {}
|
||||
|
||||
npm/parser-wasm:
|
||||
dependencies:
|
||||
'@oxc-project/types':
|
||||
specifier: workspace:^
|
||||
version: link:../oxc-types
|
||||
|
||||
npm/runtime: {}
|
||||
|
||||
tasks/compat_data:
|
||||
@@ -213,12 +207,6 @@ importers:
|
||||
specifier: ^0.2.2
|
||||
version: 0.2.2
|
||||
|
||||
wasm/parser:
|
||||
dependencies:
|
||||
'@oxc-project/types':
|
||||
specifier: workspace:^
|
||||
version: link:../../npm/oxc-types
|
||||
|
||||
packages:
|
||||
|
||||
'@ampproject/remapping@2.3.0':
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
bin/
|
||||
pkg/
|
||||
node_modules/
|
||||
wasm-pack.log
|
||||
@@ -1,91 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0.
|
||||
|
||||
## [0.54.0] - 2025-03-04
|
||||
|
||||
- a5cde10 visit_ast: [**BREAKING**] Add `oxc_visit_ast` crate (#9428) (Boshen)
|
||||
|
||||
### Features
|
||||
|
||||
|
||||
## [0.53.0] - 2025-02-26
|
||||
|
||||
### Features
|
||||
|
||||
- 835ee95 wasm: Return estree with utf16 span offsets (#9376) (Boshen)
|
||||
|
||||
### Refactor
|
||||
|
||||
- b09249c ast/estree: Rename serializers and serialization methods (#9284) (overlookmotel)
|
||||
|
||||
## [0.52.0] - 2025-02-21
|
||||
|
||||
- 216b33f ast/estree: [**BREAKING**] Replace `serde` with custom `ESTree` serializer (#9256) (overlookmotel)
|
||||
|
||||
### Features
|
||||
|
||||
- ac1f622 wasm/parser: Expose comments (#9175) (Kevin Deng 三咲智子)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- b9c8a10 wasm: Transfer AST to JS as JSON string in `oxc-wasm` (#9269) (overlookmotel)
|
||||
- 5acc6ec wasm: Transfer AST to JS as JSON string (#9259) (overlookmotel)
|
||||
|
||||
### Documentation
|
||||
|
||||
- d04c4b0 wasm: Correct and update docs (#9260) (overlookmotel)
|
||||
|
||||
## [0.49.0] - 2025-02-10
|
||||
|
||||
### Styling
|
||||
|
||||
- a4a8e7d all: Replace `#[allow]` with `#[expect]` (#8930) (overlookmotel)
|
||||
|
||||
## [0.42.0] - 2024-12-18
|
||||
|
||||
### Refactor
|
||||
|
||||
- 8cf9766 semantic, syntax, wasm: Remove `#![expect(non_snake_case)]` (#7863) (overlookmotel)
|
||||
|
||||
## [0.35.0] - 2024-11-04
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- 7d12669 types: Move @oxc-project/types to dependencies (#6909) (ottomated)
|
||||
|
||||
## [0.34.0] - 2024-10-26
|
||||
|
||||
### Features
|
||||
|
||||
- 1145341 ast_tools: Output typescript to a separate package (#6755) (ottomated)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- b075982 types: Change @oxc/types package name (#6874) (ottomated)
|
||||
|
||||
## [0.26.0] - 2024-09-03
|
||||
|
||||
### Refactor
|
||||
|
||||
- b39c0d6 wasm: Add `source_type` for parser, replace class options with plain object (#5217) (Kevin Deng 三咲智子)
|
||||
|
||||
## [0.13.0] - 2024-05-14
|
||||
|
||||
### Refactor
|
||||
|
||||
- 2064ae9 parser,diagnostic: One diagnostic struct to eliminate monomorphization of generic types (#3214) (Boshen)
|
||||
|
||||
## [0.10.0] - 2024-03-14
|
||||
|
||||
### Features
|
||||
- 697b6b7 Merge features `serde` and `wasm` to `serialize` (#2716) (Boshen)
|
||||
|
||||
## [0.6.0] - 2024-02-03
|
||||
|
||||
### Features
|
||||
|
||||
- 9c6c17b wasm/parser: Improve FFI (#2232) (Boshen)- 5ac61f0 Setup wasm parser for npm (#2221) (Boshen)
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
[package]
|
||||
name = "oxc_parser_wasm"
|
||||
version = "0.0.1"
|
||||
authors.workspace = true
|
||||
categories.workspace = true
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
keywords.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
repository.workspace = true
|
||||
rust-version.workspace = true
|
||||
description.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
test = false
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
oxc = { workspace = true, features = ["ast_visit", "serialize"] }
|
||||
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde-wasm-bindgen = { workspace = true }
|
||||
tsify = { workspace = true }
|
||||
wasm-bindgen = { workspace = true }
|
||||
@@ -1,60 +0,0 @@
|
||||
## About
|
||||
|
||||
Experimental wasm package for the oxc parser, with full TypeScript typings support.
|
||||
|
||||
This package is built with different [wasm-pack's target](https://rustwasm.github.io/docs/wasm-bindgen/reference/deployment.html) builds:
|
||||
|
||||
- `wasm-pack build --target web` for bundler (webpack / vite) consumption.
|
||||
- `wasm-pack build --target nodejs` for node.js
|
||||
|
||||
And exports the files as
|
||||
|
||||
```json
|
||||
"main": "./node/oxc_parser_wasm.js",
|
||||
"browser": "./web/oxc_parser_wasm.js",
|
||||
"types": "./node/oxc_parser_wasm.d.ts",
|
||||
```
|
||||
|
||||
Check out [oxc-parser](https://www.npmjs.com/package/oxc-parser) for an alternative in Node.js
|
||||
which performs the same function, but using native code via NAPI bindings (slightly faster).
|
||||
|
||||
Source code: https://github.com/oxc-project/oxc/tree/main/wasm/parser
|
||||
|
||||
## Usage
|
||||
|
||||
### Node.js
|
||||
|
||||
```js
|
||||
import { parseSync } from '@oxc-parser/wasm';
|
||||
|
||||
const code = 'let foo';
|
||||
const result = parseSync(code, { sourceFilename: 'test.ts' });
|
||||
console.log(result.program);
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
```js
|
||||
import { initSync, parseSync } from '@oxc-parser/wasm';
|
||||
|
||||
initSync();
|
||||
|
||||
const code = 'let foo';
|
||||
const result = parseSync(code, { sourceFilename: 'test.ts' });
|
||||
console.log(result.program);
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
The AST returned conforms to the [ESTree](https://github.com/estree/estree) spec for JS syntax.
|
||||
|
||||
For TypeScript code, the AST is broadly aligned with
|
||||
[typescript-eslint](https://typescript-eslint.io/packages/parser/)'s format, though there may be some
|
||||
differences.
|
||||
|
||||
### Vite
|
||||
|
||||
`wasm-pack build --target web` is used for the wasm build.
|
||||
|
||||
You may need something like https://github.com/nshen/vite-plugin-wasm-pack to get it working with vite,
|
||||
otherwise vite will load the wasm file as a HTML file causing a `CompileError: WebAssembly.instantiate(): expected magic word` error.
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"name": "@oxc-parser/wasm",
|
||||
"version": "0.60.0",
|
||||
"description": "Wasm target for the oxc parser.",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
"TypeScript",
|
||||
"parser"
|
||||
],
|
||||
"author": "Boshen and oxc contributors",
|
||||
"license": "MIT",
|
||||
"homepage": "https://oxc.rs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/oxc-project/oxc",
|
||||
"directory": "wasm/parser"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
},
|
||||
"main": "./node/oxc_parser_wasm.js",
|
||||
"browser": "./web/oxc_parser_wasm.js",
|
||||
"types": "./node/oxc_parser_wasm.d.ts",
|
||||
"files": [
|
||||
"node",
|
||||
"web"
|
||||
],
|
||||
"dependencies": {
|
||||
"@oxc-project/types": "workspace:^"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm run build-node && pnpm run build-web && pnpm run update-bindings && pnpm run copy-files && pnpm run clean-files",
|
||||
"build-node": "pnpm run build-base --target nodejs --out-dir ../../npm/parser-wasm/node .",
|
||||
"build-web": "pnpm run build-base --target web --out-dir ../../npm/parser-wasm/web .",
|
||||
"build-base": "wasm-pack build --release --no-pack",
|
||||
"update-bindings": "node ./update-bindings.mjs",
|
||||
"copy-files": "cp ./package.json ../../npm/parser-wasm/package.json && cp ./README.md ../../npm/parser-wasm/README.md",
|
||||
"clean-files": "rm ../../npm/parser-wasm/*/.gitignore",
|
||||
"test": "vitest ./test",
|
||||
"check": "tsc --lib es2020,dom ./node/oxc_parser_wasm.d.ts"
|
||||
}
|
||||
}
|
||||
@@ -1,165 +0,0 @@
|
||||
#![expect(clippy::needless_pass_by_value)]
|
||||
|
||||
use oxc::{
|
||||
allocator::Allocator, ast::CommentKind, ast_visit::utf8_to_utf16::Utf8ToUtf16, parser::Parser,
|
||||
span::SourceType,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tsify::Tsify;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
|
||||
const TS_APPEND_CONTENT: &'static str = r#"
|
||||
import type { Program } from "@oxc-project/types";
|
||||
export * from "@oxc-project/types";
|
||||
"#;
|
||||
|
||||
#[derive(Debug, Default, Clone, Deserialize, Tsify)]
|
||||
#[tsify(from_wasm_abi)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ParserOptions {
|
||||
#[tsify(optional, type = "\"script\" | \"module\"")]
|
||||
pub source_type: Option<String>,
|
||||
|
||||
/// "module" and "jsx" will be inferred from `sourceFilename`.
|
||||
#[tsify(optional)]
|
||||
pub source_filename: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Tsify)]
|
||||
#[wasm_bindgen(getter_with_clone)]
|
||||
pub struct ParseResult {
|
||||
// Dummy field, only present to make `tsify` include it in the type definition for `ParseResult`.
|
||||
// The getter for this field in WASM bindings is generated by `update-bindings.mjs` script.
|
||||
#[wasm_bindgen(skip)]
|
||||
#[tsify(type = "Program")]
|
||||
pub program: (),
|
||||
|
||||
#[wasm_bindgen(readonly, skip_typescript, js_name = programJson)]
|
||||
#[serde(rename = "programJson")]
|
||||
pub program_json: String,
|
||||
|
||||
#[wasm_bindgen(readonly, skip_typescript)]
|
||||
#[tsify(type = "Comment[]")]
|
||||
pub comments: Vec<JsValue>,
|
||||
|
||||
#[wasm_bindgen(readonly, skip_typescript)]
|
||||
#[tsify(type = "Diagnostic[]")]
|
||||
pub errors: Vec<JsValue>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Serialize, Tsify)]
|
||||
pub struct Diagnostic {
|
||||
pub start: usize,
|
||||
pub end: usize,
|
||||
pub severity: String,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Tsify, Serialize)]
|
||||
pub struct Comment {
|
||||
pub r#type: CommentType,
|
||||
pub value: String,
|
||||
pub start: u32,
|
||||
pub end: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Tsify, Serialize)]
|
||||
#[tsify(into_wasm_abi)]
|
||||
pub enum CommentType {
|
||||
Line,
|
||||
Block,
|
||||
}
|
||||
|
||||
/// # Errors
|
||||
///
|
||||
/// * wasm bindgen serialization failed
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// * File extension is invalid
|
||||
/// * Serde JSON serialization
|
||||
#[wasm_bindgen(js_name = parseSync)]
|
||||
pub fn parse_sync(
|
||||
source_text: String,
|
||||
options: Option<ParserOptions>,
|
||||
) -> Result<ParseResult, serde_wasm_bindgen::Error> {
|
||||
let options = options.unwrap_or_default();
|
||||
|
||||
let allocator = Allocator::default();
|
||||
|
||||
let source_type = options
|
||||
.source_filename
|
||||
.as_ref()
|
||||
.map(|name| SourceType::from_path(name).unwrap())
|
||||
.unwrap_or_default();
|
||||
|
||||
let source_type = match options.source_type.as_deref() {
|
||||
Some("script") => source_type.with_script(true),
|
||||
Some("module") => source_type.with_module(true),
|
||||
_ => source_type,
|
||||
};
|
||||
|
||||
let ret = Parser::new(&allocator, &source_text, source_type).parse();
|
||||
|
||||
let serializer = serde_wasm_bindgen::Serializer::json_compatible();
|
||||
|
||||
let mut program = ret.program;
|
||||
let span_converter = Utf8ToUtf16::new(program.source_text);
|
||||
span_converter.convert_program(&mut program);
|
||||
let program_json = program.to_estree_ts_json();
|
||||
|
||||
let mut offset_converter = span_converter.converter();
|
||||
let comments: Vec<JsValue> = if program.comments.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
program
|
||||
.comments
|
||||
.iter()
|
||||
.map(|comment| {
|
||||
let value = comment.content_span().source_text(&source_text).to_string();
|
||||
let mut span = comment.span;
|
||||
if let Some(converter) = &mut offset_converter {
|
||||
converter.convert_span(&mut span);
|
||||
}
|
||||
Comment {
|
||||
r#type: match comment.kind {
|
||||
CommentKind::Line => CommentType::Line,
|
||||
CommentKind::Block => CommentType::Block,
|
||||
},
|
||||
value,
|
||||
start: span.start,
|
||||
end: span.end,
|
||||
}
|
||||
.serialize(&serializer)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<JsValue>>()
|
||||
};
|
||||
|
||||
let errors = if ret.errors.is_empty() {
|
||||
vec![]
|
||||
} else {
|
||||
ret.errors
|
||||
.iter()
|
||||
.flat_map(|error| {
|
||||
let Some(labels) = &error.labels else { return vec![] };
|
||||
labels
|
||||
.iter()
|
||||
.map(|label| {
|
||||
Diagnostic {
|
||||
start: label.offset(),
|
||||
end: label.offset() + label.len(),
|
||||
severity: "Error".to_string(),
|
||||
message: format!("{error}"),
|
||||
}
|
||||
.serialize(&serializer)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<JsValue>>()
|
||||
})
|
||||
.collect::<Vec<JsValue>>()
|
||||
};
|
||||
|
||||
Ok(ParseResult { program: (), program_json, comments, errors })
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { assert, describe, it } from 'vitest';
|
||||
import { parseSync } from '../../npm/parser-wasm/node/oxc_parser_wasm.js';
|
||||
|
||||
describe('simple', () => {
|
||||
it('should parse', () => {
|
||||
const code = '/abc/gu; 123n; 1e+350; // 🤨';
|
||||
const result = parseSync(code, { sourceFilename: 'test.ts' });
|
||||
|
||||
assert(result.errors.length === 0);
|
||||
|
||||
// Check `program` getter caches result
|
||||
const program = result.program;
|
||||
assert(result.program === program);
|
||||
|
||||
// Check output is correct
|
||||
assert(program.type === 'Program');
|
||||
assert(program.body.length === 3);
|
||||
|
||||
// Check `RegExp`s, `BigInt`s and `Infinity` are deserialized correctly
|
||||
assert(program.body[0].expression.value instanceof RegExp);
|
||||
assert(typeof program.body[1].expression.value === 'bigint');
|
||||
const inf = program.body[2].expression.value;
|
||||
assert(typeof inf === 'number');
|
||||
assert(inf === Infinity);
|
||||
});
|
||||
});
|
||||
@@ -1,56 +0,0 @@
|
||||
// Script to inject code for an extra `program` getter on `class ParseResult` in WASM binding files.
|
||||
|
||||
import assert from 'assert';
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { join as pathJoin } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const pkgDirPath = pathJoin(fileURLToPath(import.meta.url), '../../../npm/parser-wasm');
|
||||
|
||||
const bindingFilename = 'oxc_parser_wasm.js';
|
||||
|
||||
// Extra getter on `ParseResult` `get program() { ... }` that gets the program as JSON string,
|
||||
// and parses it to a `Program` object.
|
||||
//
|
||||
// JSON parsing uses a reviver function that sets `value` field of `Literal`s for `BigInt`s and `RegExp`s.
|
||||
// This is not possible to do on Rust side, as neither can be represented correctly in JSON.
|
||||
// Invalid regexp, or valid regexp using syntax not supported by the platform is ignored.
|
||||
//
|
||||
// The getter caches the result to avoid re-parsing JSON every time `result.program` is accessed.
|
||||
//
|
||||
// Note: This code is repeated in `napi/parser/index.js` and `crates/oxc-wasm/update-bindings.mjs`.
|
||||
// Any changes should be applied in those 2 places too.
|
||||
const getterCode = `
|
||||
__program;
|
||||
|
||||
get program() {
|
||||
if (this.__program) return this.__program;
|
||||
return this.__program = JSON.parse(this.programJson, function(key, value) {
|
||||
if (value === null && key === 'value' && Object.hasOwn(this, 'type') && this.type === 'Literal') {
|
||||
if (Object.hasOwn(this, 'bigint')) {
|
||||
return BigInt(this.bigint);
|
||||
}
|
||||
if (Object.hasOwn(this, 'regex')) {
|
||||
const { regex } = this;
|
||||
try {
|
||||
return RegExp(regex.pattern, regex.flags);
|
||||
} catch (_err) {}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
`.trimEnd().replace(/ /g, ' ');
|
||||
|
||||
const insertGetterAfter = 'class ParseResult {';
|
||||
|
||||
for (const dirName of ['node', 'web']) {
|
||||
const path = pathJoin(pkgDirPath, dirName, bindingFilename);
|
||||
const code = readFileSync(path, 'utf8');
|
||||
|
||||
const parts = code.split(insertGetterAfter);
|
||||
assert(parts.length === 2);
|
||||
const [before, after] = parts;
|
||||
const updatedCode = [before, insertGetterAfter, getterCode, after].join('');
|
||||
writeFileSync(path, updatedCode);
|
||||
}
|
||||
Reference in new issue
Block a user