-
Notifications
You must be signed in to change notification settings - Fork 6
can be used as a library, options for export mode #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
📋 also, copy helper function for writing tests from binaryen-loader 😂 tslint doesn't like json
X can be: 🐣 'buffer' will export wasm code as Buffer class 🐥 'module' or 'async-module' will export wasm code as WebAssembly.Module 🐤 'instance' or 'async-instance' will export wasm code as WebAssembly.Instance 🐔 'async' will "instantiate" wasm code asynchronously waiting for v17.1 to resolve d.ts issue when bundling 👉 ezolenko/rollup-plugin-typescript2/issues/101 👈
😲 the new ts-jest now make jest configuration really simple
💡 found a shortcut to register all wasm functions into vue methods ⛔️ rust must be compiled in release profile when wasm exported as instance since default profile produce 2MB wasm 😂
🥚 add and modify on.js from binaryen-loader
🐣 since it's javascript, allowJs in tsconfig.json
🐥 however rollup will complain, so need to disable allowJs when bundling
---
🥚 use @webpack-contrib/test-utils to test it as a webpack-loader
🐣 but that dependency not compatible with es6 import
🐥 so tsconfig.json need to transform code as commonjs module {"module": "commonjs"}
🐤 but it cannot produce type declaration so need to disable it {"declaration": true}
🐔 luckily tsconfig.json can be override when bundling, so transform code as esnext module (see rollup.config.js)
🦃 summary, testing will transform code into commonjs module while bundling will generate commonjs module that support esnext import
🦖 so test the bundle result (dist/) rather than the source code (src/)
🦕 and collectCoverageFrom dist/ instead of src/ (see package.json)
🐉 which need to run `npm run build` before testing (see jest.config.js)
---
⌛️ minor change in testing as a library (lib.test.ts)
🚯 bundle the project before running linter in CI (npm run ci:lint)
🆗 ezolenko/rollup-plugin-typescript2/issues/101 now respect declarationDir and produces *.d.ts
incorrect source could be: 🔸 invalid/not-compilable wasm binary 🔸 wasm code over 4KB when using export mode: instance or module⚠️ Rust v1.29 and nightly produce ~57KB wasm code, smoke-test need to lock on v1.28 👉 https://developers.google.com/web/updates/2018/04/loading-wasm 👈
Owner
Author
|
I attach the coverage test here because https://codecov.io can't pick up coverage report which source code are not in github repo. (since I test the bundle result instead of the source code) $ npm run test:coverage
> webassembly-loader@0.0.0 test:coverage /home/wildan/Projects/OSS/webassembly-loader
> jest --collectCoverageFrom='dist/*.js' --coverage
Determining test suites to run...
src/index.ts → dist/index.js...
created dist/index.js in 3.3s
PASS test/lib.test.ts (15.242s)
PASS test/loader.test.ts (28.831s)
PASS test/negative.test.ts (28.996s)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 97.3 | 81.82 | 100 | 96.97 | |
index.js | 97.3 | 81.82 | 100 | 96.97 | 105 |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 3 passed, 3 total
Tests: 39 passed, 39 total
Snapshots: 0 total
Time: 35.705s
Ran all test suites. |
This was referenced Oct 17, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains a:
Motivation / Use-Case
Additional Info
TODO: