Skip to content

Commit d9ce2b6

Browse files
authored
Use napi-rs 2 in compat-mode (parcel-bundler#161)
1 parent 4e36e07 commit d9ce2b6

File tree

5 files changed

+116
-469
lines changed

5 files changed

+116
-469
lines changed

Cargo.lock

Lines changed: 90 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ parcel_sourcemap = "2.0.2"
2020
jemallocator = { version = "0.3.2", features = ["disable_initial_exec_tls"] }
2121

2222
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
23-
napi = { version = "1.7.10", features = ["serde-json"] }
24-
napi-derive = "1"
23+
napi = {version = "2.2.0", default-features = false, features = ["napi4", "compat-mode", "serde-json"]}
24+
napi-derive = "2"
2525

2626
[target.'cfg(target_arch = "wasm32")'.dependencies]
2727
js-sys = "0.3"

node/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'i> CompileError<'i> {
428428
// Generate an error with location information.
429429
let syntax_error = ctx.env.get_global()?.get_named_property::<napi::JsFunction>("SyntaxError")?;
430430
let reason = ctx.env.create_string_from_std(reason)?;
431-
let mut obj = syntax_error.new(&[reason])?;
431+
let mut obj = syntax_error.new_instance(&[reason])?;
432432
if let Some(loc) = loc {
433433
let line = ctx.env.create_int32((loc.line + 1) as i32)?;
434434
let col = ctx.env.create_int32(loc.column as i32)?;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
},
3737
"devDependencies": {
3838
"@mdn/browser-compat-data": "^4.1.12",
39-
"@napi-rs/cli": "1.0.4",
39+
"@napi-rs/cli": "^2.6.2",
4040
"autoprefixer": "^10.4.4",
4141
"caniuse-lite": "^1.0.30001319",
4242
"cssnano": "^5.0.8",
@@ -58,4 +58,4 @@
5858
"playground:start": "parcel playground/index.html",
5959
"playground:build": "yarn wasm-browser:build-release && parcel build playground/index.html"
6060
}
61-
}
61+
}

0 commit comments

Comments
 (0)