This repository was archived by the owner on Jul 13, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
NodeJS ES Module Loader
2
2
===
3
3
4
- Loads ES modules with CJS interop in Node according to https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md .
4
+ Loads ES modules and WebAssembly with CJS interop in Node, roughly according to https://github.com/nodejs/node-eps/blob/master/002-es6-modules.md .
5
5
6
6
Follows the NodeJS resolution algorithm, loading modules first as CJS and then falling back to ES on import or export syntax failures.
7
7
This effectively provides the "export {}" assumption to load an ES module.
8
8
9
+ This does mean a double-parse, over the mjs approach currently being taken by Node.
10
+
9
11
Built with the ES Module Loader polyfill 1.0 branch at https://github.com/ModuleLoader/es-module-loader .
10
12
11
13
### Installation
@@ -27,6 +29,7 @@ For example, where `module.js` contains:
27
29
``` javascript
28
30
import fs from ' fs' ;
29
31
import {fn } from ' ./local-es-module.js' ;
32
+ import {wasmFn } from ' ./local-wasm-binary.wasm' ;
30
33
```
31
34
32
35
Note that only the default import form for CommonJS modules is supported.
@@ -41,6 +44,12 @@ export function lazyLoad(path) {
41
44
42
45
Source maps for errors are fully supported through the [ source-map-support project] ( https://github.com/evanw/node-source-map-support ) .
43
46
47
+ Wasm requires running with the ` --expose-wasm ` flag in Node currently (currently supporting Node 8 nightly only):
48
+
49
+ ```
50
+ node --expose-wasm node_modules/.bin/node-esml module.js
51
+ ```
52
+
44
53
Source maps also work in Node 6 with the ` node --inspect ` flag via:
45
54
46
55
```
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " node-es-module-loader" ,
3
- "version" : " 0.3.2 " ,
3
+ "version" : " 0.3.3 " ,
4
4
"description" : " Loads ES modules with CJS interop in Node" ,
5
5
"main" : " dist/node-es-module-loader.js" ,
6
6
"bin" : {
You can’t perform that action at this time.
0 commit comments