Skip to content
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

v12.20.0 proposal #35950

Merged
merged 117 commits into from
Nov 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
2471197
http2: wait for session to finish writing before destroy
lundibundi Dec 7, 2019
e85ca7a
http2: wait for session socket writable end on close/destroy
lundibundi Dec 8, 2019
82af8ac
http2,doc: minor fixes
mildsunrise Apr 27, 2020
bfce0eb
Revert "http2: streamline OnStreamRead streamline memory accounting"
Trott Jul 11, 2020
b732c92
http2: use and support non-empty DATA frame with END_STREAM flag
clshortfuse Jun 14, 2020
f10d721
http: reset headers timeout on headers complete
ronag Jul 31, 2020
fb9b66b
doc: fix typos in n-api, tls and worker_threads
jucke Jul 18, 2020
b644ab6
doc: fix line length in worker_threads.md
jucke Jul 18, 2020
c8a7789
http2: avoid unnecessary buffer resize
lundibundi Jul 22, 2020
70768ce
repl: give repl entries unique names
bmeck Jul 14, 2020
12d76b8
tls: reset secureConnecting on client socket
davedoesdev May 2, 2020
02787ce
test: add ALPNProtocols option to clientOptions
lpinca Oct 3, 2020
decfc2a
fs: add .ref() and .unref() methods to watcher classes
rickyes Apr 28, 2020
8a10916
stream: destroy wrapped streams on error
ronag Jun 28, 2020
d477e2e
http: only set keep-alive when not exists
atian25 Oct 13, 2020
cce4645
http: added scheduling option to http agent
delvedor May 7, 2020
9eb1fa1
module: named exports for CJS via static analysis
guybedford May 15, 2020
6ca8fb5
module: refine module type mismatch error cases
guybedford Sep 30, 2020
a18d0df
module: update to cjs-module-lexer@0.4.0
guybedford Oct 4, 2020
7510667
doc: rename module pages
aduh95 Aug 7, 2020
7c1700e
doc: move package config docs to separate page
aduh95 Aug 7, 2020
d6a13a9
doc: document support for package.json fields
aduh95 Aug 7, 2020
41af927
module: exports pattern support
guybedford Aug 12, 2020
5f0b157
doc: edit subpath export patterns introduction
Trott Sep 18, 2020
5330930
doc: refine require/import conditions constraints
guybedford Sep 23, 2020
f507ca9
doc: packages docs feedback
guybedford Sep 27, 2020
9197a66
doc: copyedit packages.md
Trott Sep 30, 2020
a7e66b6
doc: fix conditional exports flag removal version
aduh95 Sep 30, 2020
66f8730
doc: add history entry for exports patterns
aduh95 Sep 29, 2020
985b96a
doc,esm: add history support info
aduh95 Sep 28, 2020
1ff956f
module: remove experimental modules warning
guybedford Feb 26, 2020
1f34230
doc,esm: document experimental warning removal
aduh95 Oct 22, 2020
0f757bc
esm: use "node:" namespace for builtins
guybedford Sep 28, 2020
68c5ee4
doc: update fs promise-based examples
richardlau Oct 22, 2020
a9a606f
lib: use full URL to GitHub issues in comments
Trott Aug 8, 2020
f22672d
errors: improve ERR_INVALID_OPT_VALUE error
lundibundi Aug 7, 2020
44c739c
deps: V8: cherry-pick 6be2f6e26e8d
bcoe Sep 4, 2020
607f3c5
test: fix comment about DNS lookup test
tniessen Sep 6, 2020
85c47d7
doc: avoid double-while sentence in perf_hooks.md
Trott Sep 6, 2020
992af4e
module: fix specifier resolution option value
himself65 Sep 8, 2020
5405e62
deps: update to uvwasi 0.0.11
cjihrig Sep 8, 2020
548137f
errors: simplify ERR_REQUIRE_ESM message generation
Trott Sep 9, 2020
884755f
doc: simplify circular dependencies text in modules.md
Trott Sep 9, 2020
c3e1bf7
test: add wasi readdir() test
cjihrig Sep 1, 2020
d938e85
n-api: add more property defaults
Flarna Sep 15, 2020
11b10d7
tools,doc: upgrade dependencies
aduh95 Sep 17, 2020
f297174
tools,doc: enforce alphabetical order for md refs
aduh95 Sep 17, 2020
bc7da0c
tools: ignore build folder when checking links
Sep 23, 2020
cc11464
deps: upgrade to c-ares v1.16.1
codebytere Sep 24, 2020
b0e43c7
doc: add gpg key export directions to releases doc
danielleadams Sep 22, 2020
cf07a86
deps: upgrade to libuv 1.40.0
cjihrig Sep 25, 2020
fdc67eb
test: replace annonymous functions with arrow
PoojaDurgad Aug 25, 2020
a9ce9b2
tools: update ESLint to 7.10.0
cjihrig Sep 26, 2020
ae14923
tools: exclude gyp from markdown link checker
targos Sep 30, 2020
2e766a6
console: add Symbol.toStringTag property
Leko Sep 28, 2020
c192af6
doc: unhide resolver spec
guybedford Sep 26, 2020
42c0dfc
doc: importable node protocol URLs
bmeck Sep 30, 2020
8be289e
doc: update contact information for richardlau
richardlau Oct 1, 2020
edf3fbb
doc: update contact information for @BethGriggs
BethGriggs Oct 1, 2020
cd80195
src: make MakeCallback() check can_call_into_js before getting method
addaleax Sep 30, 2020
a6f58c0
crypto: set env values in KeyObject Deserialize method
ThakurKarthik Sep 28, 2020
e70b052
src: remove invalid ToLocalChecked in EmitBeforeExit
addaleax Oct 3, 2020
0a1474d
deps: update llhttp to 2.1.3
indutny Sep 30, 2020
19d7113
fs: simplify realpathSync
himself65 Sep 29, 2020
370f8e3
doc: update sxa's email address to Red Hat from IBM
Oct 1, 2020
76f7601
module: fix builtin reexport tracing
guybedford Oct 4, 2020
b5f7525
doc: update AUTHORS list
addaleax Sep 21, 2020
0955267
tools: add missing uv_setup_argv() calls
addaleax Oct 4, 2020
ade27b7
src: use env->ThrowUVException in pipe_wrap
jasnell Oct 4, 2020
7f8834f
src: more idiomatic error pattern in node_wasi
jasnell Oct 4, 2020
ad7281b
lib: use remaining typed arrays from primordials
targos Sep 28, 2020
6952c45
doc: add aduh95 to collaborators
aduh95 Oct 7, 2020
5faaa60
n-api: support for object freeze/seal
codebytere Sep 26, 2020
dec004f
src: expose v8::Isolate setup callbacks
codebytere Oct 5, 2020
2d5393b
src: fix freeing unintialized pointer bug in ParseSoaReply
AasthaGupta Oct 4, 2020
48bc3fc
build: improved release lint error message
codebytere Oct 6, 2020
6efa140
lib: change http client path assignment
dekinderfiets Oct 5, 2020
fb9bb05
doc: fix util.inspect change history
aduh95 Oct 6, 2020
42c4795
doc: use sentence case for class property
Trott Oct 7, 2020
f3a0457
build: fuzzer that targets node::LoadEnvironment()
DavidKorczynski Aug 19, 2020
05db4b8
doc: improve SIGINT error text
Trott Oct 8, 2020
992355c
doc: simplify wording in tracing APIs doc
PoojaDurgad Oct 8, 2020
b741f2f
src: move node_process to modern THROW_ERR*
jasnell Oct 2, 2020
e9bee39
src: move node_contextify to modern THROW_ERR_*
jasnell Oct 2, 2020
1173efc
tools: bump cpplint.py to 1.4.6
Trott Oct 9, 2020
adf4f90
tools: refloat 7 Node.js patches to cpplint.py
Trott Oct 9, 2020
a0b541c
doc: use kbd element in process doc
Trott Oct 10, 2020
5fea51b
doc: add PoojaDurgad as a triager
PoojaDurgad Sep 11, 2020
a3e8829
inspector: do not hardcode Debugger.CallFrameId in tests
dgozman Oct 9, 2020
42f64eb
crypto: update certdata to NSS 3.56
codebytere Oct 7, 2020
a9ac754
doc: add symlink information for process.execpath
PoojaDurgad Oct 10, 2020
bfff4fc
doc: revise description of process.ppid
PoojaDurgad Oct 10, 2020
42a587f
doc: use test username instead of real
PoojaDurgad Oct 12, 2020
df52814
doc: document Buffer.concat may use internal pool
puzpuzpuz Oct 7, 2020
a93ca2d
n-api: revert change to finalization
mhdawson Oct 23, 2020
354f358
module: use Wasm CJS lexer when available
guybedford Oct 10, 2020
7a98961
esm: fix hook mistypes and links to types
DerekNonGeneric Jul 7, 2020
ea23939
module: cjs-module-lexer@0.4.1 big endian fix
guybedford Oct 13, 2020
d7f0e3e
deps: update to cjs-module-lexer@0.4.3
guybedford Oct 21, 2020
5b8d3c7
deps: upgrade to cjs-module-lexer@0.5.0
guybedford Oct 29, 2020
bdcc77b
deps: update to cjs-module-lexer@0.5.2
guybedford Oct 31, 2020
6539cf2
deps: upgrade to cjs-module-lexer@1.0.0
guybedford Nov 2, 2020
d991200
doc: error code fix in resolver spec
guybedford Aug 31, 2020
1a8f3a8
doc: copyedit esm.md
Trott Sep 29, 2020
b50b34b
doc: put release script specifics in details
MylesBorins Sep 18, 2020
77555d8
doc: put landing specifics in details tag
Trott Sep 25, 2020
18f01dd
repl: improve static import error message in repl
MylesBorins May 27, 2020
f0b06b6
doc: move module core module doc to separate page
aduh95 Aug 7, 2020
7dc3b74
doc: add ESM examples in `module` API doc page
aduh95 Aug 22, 2020
b4941cf
doc: make minor improvements to module.md
Trott Sep 6, 2020
79f3c32
doc: fix broken links in modules.md
Trott Sep 14, 2020
1cd1d01
doc: move package.import content higher
MylesBorins Oct 7, 2020
9024436
crypto: fix KeyObject garbage collection
addaleax Oct 3, 2020
b78a1a1
doc: update releaser in v12.18.4 changelog
BethGriggs Sep 15, 2020
c6eb0b6
benchmark: ignore build artifacts for napi addons
richardlau Nov 4, 2020
b484732
events: assume an EventEmitter if emitter.on is a function
lpinca Oct 26, 2020
d84392f
2020-11-24, Version 12.20.0 'Erbium' (LTS)
MylesBorins Nov 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
module: named exports for CJS via static analysis
Backport-PR-URL: #35757
PR-URL: #35249
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
guybedford authored and MylesBorins committed Nov 16, 2020
commit 9eb1fa19248949dfc716807b1dc97dedf36da14e
14 changes: 14 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -137,6 +137,20 @@ The externally maintained libraries used by Node.js are:
IN THE SOFTWARE.
"""

- cjs-module-lexer, located at deps/cjs-module-lexer, is licensed as follows:
"""
MIT License
-----------

Copyright (C) 2018-2020 Guy Bedford

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

- ICU, located at deps/icu-small, is licensed as follows:
"""
COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later)
11 changes: 11 additions & 0 deletions deps/cjs-module-lexer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
*.lock
test
.*
Makefile
bench
build.js
include-wasm
include
lib
src
10 changes: 10 additions & 0 deletions deps/cjs-module-lexer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MIT License
-----------

Copyright (C) 2018-2020 Guy Bedford

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.
331 changes: 331 additions & 0 deletions deps/cjs-module-lexer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,331 @@
# CJS Module Lexer

[![Build Status][travis-image]][travis-url]

A [very fast](#benchmarks) JS CommonJS module syntax lexer used to detect the most likely list of named exports of a CommonJS module.

Outputs the list of named exports (`exports.name = ...`) and possible module reexports (`module.exports = require('...')`), including the common transpiler variations of these cases.

Forked from https://github.com/guybedford/es-module-lexer.

_Comprehensively handles the JS language grammar while remaining small and fast. - ~90ms per MB of JS cold and ~15ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._

### Usage

```
npm install cjs-module-lexer
```

For use in CommonJS:

```js
const parse = require('cjs-module-lexer');

const { exports, reexports } = parse(`
// named exports detection
module.exports.a = 'a';
(function () {
exports.b = 'b';
})();
Object.defineProperty(exports, 'c', { value: 'c' });
/* exports.d = 'not detected'; */

// reexports detection
if (maybe) module.exports = require('./dep1.js');
if (another) module.exports = require('./dep2.js');

// literal exports assignments
module.exports = { a, b: c, d, 'e': f }

// __esModule detection
Object.defineProperty(module.exports, '__esModule', { value: true })
`);

// exports === ['a', 'b', 'c', '__esModule']
// reexports === ['./dep1.js', './dep2.js']
```

When using the ESM version, Wasm is supported instead:

```js
import { parse, init } from 'cjs-module-lexer';
// init needs to be called and waited upon
await init();
const { exports, reexports } = parse(source);
```

The Wasm build is around 1.5x faster and without a cold start.

### Grammar

CommonJS exports matches are run against the source token stream.

The token grammar is:

```
IDENTIFIER: As defined by ECMA-262, without support for identifier `\` escapes, filtered to remove strict reserved words:
"implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "enum"

STRING_LITERAL: A `"` or `'` bounded ECMA-262 string literal.

IDENTIFIER_STRING: ( `"` IDENTIFIER `"` | `'` IDENTIFIER `'` )

COMMENT_SPACE: Any ECMA-262 whitespace, ECMA-262 block comment or ECMA-262 line comment

MODULE_EXPORTS: `module` COMMENT_SPACE `.` COMMENT_SPACE `exports`

EXPORTS_IDENTIFIER: MODULE_EXPORTS_IDENTIFIER | `exports`

EXPORTS_DOT_ASSIGN: EXPORTS_IDENTIFIER COMMENT_SPACE `.` COMMENT_SPACE IDENTIFIER COMMENT_SPACE `=`

EXPORTS_LITERAL_COMPUTED_ASSIGN: EXPORTS_IDENTIFIER COMMENT_SPACE `[` COMMENT_SPACE IDENTIFIER_STRING COMMENT_SPACE `]` COMMENT_SPACE `=`

EXPORTS_LITERAL_PROP: (IDENTIFIER (COMMENT_SPACE `:` COMMENT_SPACE IDENTIFIER)?) | (IDENTIFIER_STRING COMMENT_SPACE `:` COMMENT_SPACE IDENTIFIER)

EXPORTS_MEMBER: EXPORTS_DOT_ASSIGN | EXPORTS_LITERAL_COMPUTED_ASSIGN

EXPORTS_DEFINE: `Object` COMMENT_SPACE `.` COMMENT_SPACE `defineProperty COMMENT_SPACE `(` EXPORTS_IDENTIFIER COMMENT_SPACE `,` COMMENT_SPACE IDENTIFIER_STRING

EXPORTS_LITERAL: MODULE_EXPORTS COMMENT_SPACE `=` COMMENT_SPACE `{` COMMENT_SPACE (EXPORTS_LITERAL_PROP COMMENT_SPACE `,` COMMENT_SPACE)+ `}`

REQUIRE: `require` COMMENT_SPACE `(` COMMENT_SPACE STRING_LITERAL COMMENT_SPACE `)`

EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` REQUIRE

MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS COMMENT_SPACE `=` COMMENT_SPACE REQUIRE

EXPORT_STAR: (`__export` | `__exportStar`) `(` REQUIRE

EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2 `) {`
(
`if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? |
`if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) `)`
)
(
EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? |
`Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get: function () { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? } })` `;`?
)
`})`
```

* The returned export names are the matched `IDENTIFIER` and `IDENTIFIER_STRING` slots for all `EXPORTS_MEMBER`, `EXPORTS_DEFINE` and `EXPORTS_LITERAL` matches.
* The reexport specifiers are taken to be the `STRING_LITERAL` slots of all `MODULE_EXPORTS_ASSIGN` as well as all _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`.

### Parsing Examples

#### Named Exports Parsing

The basic matching rules for named exports are `exports.name`, `exports['name']` or `Object.defineProperty(exports, 'name', ...)`. This matching is done without scope analysis and regardless of the expression position:

```js
// DETECTS EXPORTS: a, b, c
(function (exports) {
exports.a = 'a';
exports['b'] = 'b';
Object.defineProperty(exports, 'c', { value: 'c' });
})(exports);
```

Because there is no scope analysis, the above detection may overclassify:

```js
// DETECTS EXPORTS: a, b, c
(function (exports, Object) {
exports.a = 'a';
exports['b'] = 'b';
if (false)
Object.defineProperty(exports, 'c', { value: 'c' });
})(NOT_EXPORTS, NOT_OBJECT);
```

It will in turn underclassify in cases where the identifiers are renamed:

```js
// DETECTS: NO EXPORTS
(function (e, defineProperty) {
e.a = 'a';
e['b'] = 'b';
defineProperty(e, 'c', { value: 'c' });
})(exports, defineProperty);
```

#### Exports Object Assignment

A best-effort is made to detect `module.exports` object assignments, but because this is not a full parser, arbitrary expressions are not handled in the
object parsing process.

Simple object definitions are supported:

```js
// DETECTS EXPORTS: a, b, c
module.exports = {
a,
b: 'c',
c: c
};
```

Object properties that are not identifiers or string expressions will bail out of the object detection:

```js
// DETECTS EXPORTS: a, b
module.exports = {
a,
b: require('c'),
c: "not detected since require('c') above bails the object detection"
}
```

`Object.defineProperties` is not currently supported either.

#### module.exports reexport assignment

Any `module.exports = require('mod')` assignment is detected as a reexport:

```js
// DETECTS REEXPORTS: a, b, c
module.exports = require('a');
(module => module.exports = require('b'))(NOT_MODULE);
if (false) module.exports = require('c');
```

As a result, the total list of exports would be inferred as the union of all of these reexported modules, which can lead to possible over-classification.

#### Transpiler Re-exports

For named exports, transpiler output works well with the rules described above.

But for star re-exports, special care is taken to support common patterns of transpiler outputs from Babel and TypeScript as well as bundlers like RollupJS.
These reexport and star reexport patterns are restricted to only be detected at the top-level as provided by the direct output of these tools.

For example, `export * from 'external'` is output by Babel as:

```js
"use strict";

exports.__esModule = true;

var _external = require("external");

Object.keys(_external).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
exports[key] = _external[key];
});
```

Where the `var _external = require("external")` is specifically detected as well as the `Object.keys(_external)` statement, down to the exact
for of that entire expression including minor variations of the output. The `_external` and `key` identifiers are carefully matched in this
detection.

Similarly for TypeScript, `export * from 'external'` is output as:

```js
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("external"));
```

Where the `__export(require("external"))` statement is explicitly detected as a reexport, including variations `tslib.__export` and `__exportStar`.

### Environment Support

Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm).

### JS Grammar Support

* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators.
* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking.
* Always correctly parses valid JS source, but may parse invalid JS source without errors.

### Benchmarks

Benchmarks can be run with `npm run bench`.

Current results:

JS Build:

```
Module load time
> 2ms
Cold Run, All Samples
test/samples/*.js (3635 KiB)
> 333ms

Warm Runs (average of 25 runs)
test/samples/angular.js (1410 KiB)
> 16.48ms
test/samples/angular.min.js (303 KiB)
> 5.36ms
test/samples/d3.js (553 KiB)
> 8.32ms
test/samples/d3.min.js (250 KiB)
> 4.28ms
test/samples/magic-string.js (34 KiB)
> 1ms
test/samples/magic-string.min.js (20 KiB)
> 0.36ms
test/samples/rollup.js (698 KiB)
> 10.48ms
test/samples/rollup.min.js (367 KiB)
> 6.64ms

Warm Runs, All Samples (average of 25 runs)
test/samples/*.js (3635 KiB)
> 49.28ms
```

Wasm Build:
```
Module load time
> 11ms
Cold Run, All Samples
test/samples/*.js (3635 KiB)
> 48ms

Warm Runs (average of 25 runs)
test/samples/angular.js (1410 KiB)
> 12.32ms
test/samples/angular.min.js (303 KiB)
> 3.76ms
test/samples/d3.js (553 KiB)
> 6.08ms
test/samples/d3.min.js (250 KiB)
> 3ms
test/samples/magic-string.js (34 KiB)
> 0.24ms
test/samples/magic-string.min.js (20 KiB)
> 0ms
test/samples/rollup.js (698 KiB)
> 7.2ms
test/samples/rollup.min.js (367 KiB)
> 4.2ms

Warm Runs, All Samples (average of 25 runs)
test/samples/*.js (3635 KiB)
> 33.6ms
```

### Wasm Build Steps

To build download the WASI SDK from https://github.com/CraneStation/wasi-sdk/releases.

The Makefile assumes the existence of "wasi-sdk-10.0", "binaryen" and "wabt" (both optional) as sibling folders to this project.

The build through the Makefile is then run via `make lib/lexer.wasm`, which can also be triggered via `npm run build-wasm` to create `dist/lexer.js`.

On Windows it may be preferable to use the Linux subsystem.

After the Web Assembly build, the CJS build can be triggered via `npm run build`.

Optimization passes are run with [Binaryen](https://github.com/WebAssembly/binaryen) prior to publish to reduce the Web Assembly footprint.

### License

MIT

[travis-url]: https://travis-ci.org/guybedford/es-module-lexer
[travis-image]: https://travis-ci.org/guybedford/es-module-lexer.svg?branch=master
Loading