Skip to content

Commit

Permalink
feat: implement reflection and various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Oct 26, 2023
1 parent 66bfe74 commit 564eba7
Show file tree
Hide file tree
Showing 49 changed files with 3,391 additions and 792 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test Suite

on:
push:
branches:
- develop
pull_request_target:

jobs:
test_package:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [12, 18, 20]
fail-fast: false

steps:
- uses: actions/checkout@v4
name: Checkout source

- name: Run Rust tests
run: |
cargo install grcov
cargo clean
cargo test
grcov . --binary-path ./target/debug -s . -t lcov --branch -o ./coverage.lcov
env:
RUSTFLAGS: -Cinstrument-coverage
LLVM_PROFILE_FILE: "%p-%m.profraw"

- name: Publish coverage report
uses: codecov/codecov-action@v3
with:
file: ./coverage.lcov

- uses: actions/setup-node@v3
name: Setup Node.JS
with:
node-version: ${{ matrix.node_version }}

- name: Run WASM tests
run: |
cargo install wasm-pack
cargo clean
npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/simd-target
/Cargo.lock
/node_modules
4 changes: 3 additions & 1 deletion .mocha.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Inject jest's assertion (expect) into global scope for the Mocha
// to use same assertion between node-swc & rest.
global.expect = require("expect");
require('@jymfony/util');
global.expect = require('expect');
global.__jymfony.JObject = class {};
2 changes: 1 addition & 1 deletion .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
* This config is for the mocha test runner invoked by cargo to resolve its global setup file.
*/
module.exports = {
require: require.resolve("./.mocha.setup.js"),
require: require.resolve('./.mocha.setup.js'),
};
14 changes: 14 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/node_modules/
/pkg/.gitignore
/pkg/package.json
/simd/.gitignore
/simd/package.json
/src/
/simd-target/
/target/
/tests/
/.gitignore
/.mocha*
/.yarnrc.yml
/Cargo.*
/yarn.lock
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/*.rs
node_modules/
pkg/
simd/
simd-target/
target/
Cargo.lock
Cargo.toml
package.json
package-lock.json
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": true,
"tabWidth": 4,
"singleQuote": true
}
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
[package]
name = "jymfony-compiler"
description = "Jymfony compiler"
repository = "https://github.com/jymfony/compiler.git"
license = "MIT"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
simd = []

[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
base64 = "0.21.4"
getrandom = { version = "0.2.10", features = ["js"] }
js-sys = "0.3"
lazy_static = "1.4.0"
moka = { version = "0.12.1", features = ["js", "sync"] }
rand = "0.8.5"
rustc-hash = "1.1.0"
serde = { version = "1.0", features = ["derive"] }
serde-wasm-bindgen = "0.6"
sourcemap = "6.4.1"
swc_atoms = "0.6.0"
swc_common = { version = "0.33.0", features = ["anyhow", "sourcemap"] }
swc_ecma_ast = "0.110.0"
swc_ecma_ast = { version = "0.110.0", features = ["default", "serde"] }
swc_ecma_codegen = "0.146.1"
swc_ecma_parser = "0.141.1"
swc_ecma_transforms_base = "0.134.3"
swc_ecma_transforms_compat = "0.160.4"
swc_ecma_transforms_module = "0.177.4"
swc_ecma_transforms_proposal = "0.168.6"
swc_ecma_transforms_typescript = "0.184.6"
swc_ecma_transforms_typescript = "0.185.4"
swc_ecma_visit = "0.96.0"
swc_ecma_utils = "0.124.3"
url = "2.4"
uuid = { version = "1.5.0", features = ["v4"] }
uuid-simd = "0.8.0"
wasm-bindgen = { version = "0.2", features = ["serde-serialize"] }
wasm-bindgen-derive = "0.2"

Expand Down
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) 2023 Alessandro Chitolina

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './pkg/compiler';
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* From wasm-feature-detect (https://www.npmjs.com/package/wasm-feature-detect) */
const isSimdSupported = WebAssembly.validate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10,
1, 8, 0, 65, 0, 253, 15, 253, 98, 11,
]),
);
const { compile, prepareStackTrace, start } = isSimdSupported
? require('./simd/compiler')
: require('./pkg/compiler');

exports._isSimdSupported = isSimdSupported;
exports.compile = compile;
exports.prepareStackTrace = prepareStackTrace;
exports.start = start;
exports.getReflectionData = require('./lib/reflection').getReflectionData;

global._apply_decs_2203_r = require('./lib/_apply_decs_2203_r')._;
global.__jymfony_reflect = require('./lib/reflection')._;
Loading

0 comments on commit 564eba7

Please sign in to comment.