diff --git a/Cargo.lock b/Cargo.lock index a5306cfe37d..26caaa16187 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,7 +12,6 @@ dependencies = [ "regex", "serde", "serde_json", - "wasm-bindgen", ] [[package]] @@ -65,6 +64,14 @@ dependencies = [ "structopt", ] +[[package]] +name = "boa_wasm" +version = "0.1.0" +dependencies = [ + "Boa", + "wasm-bindgen", +] + [[package]] name = "bstr" version = "0.2.12" diff --git a/Cargo.toml b/Cargo.toml index 347477474ee..c250459bb88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "boa", "boa_cli", + "boa_wasm", ] # The release profile, used for `cargo build`. diff --git a/boa/Cargo.toml b/boa/Cargo.toml index 1e2fb59aad5..cab2701742c 100644 --- a/boa/Cargo.toml +++ b/boa/Cargo.toml @@ -12,7 +12,6 @@ edition = "2018" [features] serde-ast = ["serde"] -default = ["wasm-bindgen"] [dependencies] gc = "0.3.3" @@ -22,7 +21,6 @@ rand = "0.7.3" regex = "1.3.6" # Optional Dependencies -wasm-bindgen = { version = "0.2.60", optional = true } serde = { version = "1.0.106", features = ["derive"], optional = true } [dev-dependencies] diff --git a/boa/src/lib.rs b/boa/src/lib.rs index ccd89d4254c..3c0c9e3dbdc 100644 --- a/boa/src/lib.rs +++ b/boa/src/lib.rs @@ -38,11 +38,6 @@ pub mod environment; pub mod exec; pub mod realm; pub mod syntax; -#[cfg(feature = "wasm-bindgen")] -mod wasm; - -#[cfg(feature = "wasm-bindgen")] -pub use crate::wasm::*; use crate::{ builtins::value::ResultValue, exec::{Executor, Interpreter}, diff --git a/boa_cli/Cargo.toml b/boa_cli/Cargo.toml index 18262687d34..07dcb68d3d1 100644 --- a/boa_cli/Cargo.toml +++ b/boa_cli/Cargo.toml @@ -11,7 +11,7 @@ exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] edition = "2018" [dependencies] -Boa = { path = "../boa", features = ["serde-ast"], default-features = false } +Boa = { path = "../boa", features = ["serde-ast"] } structopt = "0.3.13" [target.x86_64-unknown-linux-gnu.dependencies] diff --git a/boa_wasm/Cargo.toml b/boa_wasm/Cargo.toml new file mode 100644 index 00000000000..96292ec5145 --- /dev/null +++ b/boa_wasm/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "boa_wasm" +version = "0.1.0" +authors = ["Jason Williams "] +description = "Boa is a Javascript lexer, parser and Just-in-Time compiler written in Rust. Currently, it has support for some of the language." +repository = "https://github.com/jasonwilliams/boa" +keywords = ["javascript", "compiler", "lexer", "parser", "js"] +categories = ["wasm"] +license = "Unlicense/MIT" +exclude = ["../.vscode/*", "../Dockerfile", "../Makefile", "../.editorConfig"] +edition = "2018" + +[dependencies] +Boa = { path = "../boa" } +wasm-bindgen = { version = "0.2.60" } + +[lib] +crate-type = ["cdylib", "lib"] +name = "boa_wasm" +bench = false diff --git a/boa/src/wasm.rs b/boa_wasm/src/lib.rs similarity index 98% rename from boa/src/wasm.rs rename to boa_wasm/src/lib.rs index 2bb8f7391e6..c8e88726193 100644 --- a/boa/src/wasm.rs +++ b/boa_wasm/src/lib.rs @@ -1,4 +1,4 @@ -use crate::{ +use boa::{ exec::{Executor, Interpreter}, realm::Realm, syntax::{ast::node::Node, lexer::Lexer, parser::Parser}, diff --git a/index.js b/index.js index b7d41bc3b6e..c5b4e26133c 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ // Note that a dynamic `import` statement here is required due to // webpack/webpack#6615, but in theory `import { greet } from './pkg/hello_world';` // will work here one day as well! -const rust = import("./boa/pkg"); +const rust = import("./boa_wasm/pkg"); import * as monaco from "monaco-editor"; self.MonacoEnvironment = { diff --git a/webpack.config.js b/webpack.config.js index 156c4abc712..d49fbdfacd0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -18,8 +18,8 @@ module.exports = { template: "index.html", }), new WasmPackPlugin({ - crateDirectory: path.resolve(__dirname, "./boa/"), - outDir: path.resolve(__dirname, "./boa/pkg/"), + crateDirectory: path.resolve(__dirname, "./boa_wasm/"), + outDir: path.resolve(__dirname, "./boa_wasm/pkg/"), }), new CopyWebpackPlugin([ {