Skip to content

Commit ea23939

Browse files
guybedfordMylesBorins
authored andcommittedNov 16, 2020
module: cjs-module-lexer@0.4.1 big endian fix
PR-URL: #35634 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
1 parent 7a98961 commit ea23939

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed
 

‎deps/cjs-module-lexer/dist/lexer.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎deps/cjs-module-lexer/dist/lexer.mjs

+2-2
Large diffs are not rendered by default.

‎deps/cjs-module-lexer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cjs-module-lexer",
3-
"version": "0.4.0",
3+
"version": "0.4.2",
44
"description": "Lexes CommonJS modules, returning their named exports metadata",
55
"main": "lexer.js",
66
"exports": {

‎doc/api/esm.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1294,9 +1294,9 @@ success!
12941294
[`string`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
12951295
[`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
12961296
[`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
1297-
[`util.TextDecoder`]: util.html#util_class_util_textdecoder
1298-
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/0.4.0
12991297
[dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook
1298+
[`util.TextDecoder`]: util.md#util_class_util_textdecoder
1299+
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/0.4.2
13001300
[special scheme]: https://url.spec.whatwg.org/#special-scheme
13011301
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
13021302
[transpiler loader example]: #esm_transpiler_loader

‎lib/internal/modules/esm/translators.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,14 @@ const asyncESM = require('internal/process/esm_loader');
5959

6060
let cjsParse;
6161
async function initCJSParse() {
62-
if (typeof WebAssembly !== 'undefined') {
62+
if (typeof WebAssembly === 'undefined') {
63+
cjsParse = require('internal/deps/cjs-module-lexer/lexer');
64+
} else {
6365
const { parse, init } =
6466
require('internal/deps/cjs-module-lexer/dist/lexer');
6567
await init();
66-
let exports;
67-
try {
68-
({ exports } = parse('exports.a=1'));
69-
if (exports.length === 1) {
70-
cjsParse = parse;
71-
return;
72-
}
73-
} catch {}
68+
cjsParse = parse;
7469
}
75-
cjsParse = require('internal/deps/cjs-module-lexer/lexer');
7670
}
7771

7872
const translators = new SafeMap();

0 commit comments

Comments
 (0)
Please sign in to comment.