Skip to content

Commit

Permalink
create boa-wasm package (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
muskuloes authored Apr 28, 2020
1 parent 41cda68 commit 55c8576
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 13 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"boa",
"boa_cli",
"boa_wasm",
]

# The release profile, used for `cargo build`.
Expand Down
2 changes: 0 additions & 2 deletions boa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ edition = "2018"

[features]
serde-ast = ["serde"]
default = ["wasm-bindgen"]

[dependencies]
gc = "0.3.3"
Expand All @@ -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]
Expand Down
5 changes: 0 additions & 5 deletions boa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion boa_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
20 changes: 20 additions & 0 deletions boa_wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "boa_wasm"
version = "0.1.0"
authors = ["Jason Williams <jase.williams@gmail.com>"]
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
2 changes: 1 addition & 1 deletion boa/src/wasm.rs → boa_wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{
use boa::{
exec::{Executor, Interpreter},
realm::Realm,
syntax::{ast::node::Node, lexer::Lexer, parser::Parser},
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down

0 comments on commit 55c8576

Please sign in to comment.