Browse Source

create boa-wasm package (#352)

pull/353/head
Victor Tuekam 5 years ago committed by GitHub
parent
commit
55c85768c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      Cargo.lock
  2. 1
      Cargo.toml
  3. 2
      boa/Cargo.toml
  4. 5
      boa/src/lib.rs
  5. 2
      boa_cli/Cargo.toml
  6. 20
      boa_wasm/Cargo.toml
  7. 2
      boa_wasm/src/lib.rs
  8. 2
      index.js
  9. 4
      webpack.config.js

9
Cargo.lock generated

@ -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"

1
Cargo.toml

@ -2,6 +2,7 @@
members = [
"boa",
"boa_cli",
"boa_wasm",
]
# The release profile, used for `cargo build`.

2
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]

5
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},

2
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]

20
boa_wasm/Cargo.toml

@ -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
boa/src/wasm.rs → 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},

2
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 = {

4
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([
{

Loading…
Cancel
Save