Skip to content

Commit

Permalink
module: cjs-module-lexer@0.4.1 big endian fix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
guybedford authored and MylesBorins committed Nov 16, 2020
1 parent 7a98961 commit ea23939
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion deps/cjs-module-lexer/dist/lexer.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions deps/cjs-module-lexer/dist/lexer.mjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/cjs-module-lexer/package.json
@@ -1,6 +1,6 @@
{
"name": "cjs-module-lexer",
"version": "0.4.0",
"version": "0.4.2",
"description": "Lexes CommonJS modules, returning their named exports metadata",
"main": "lexer.js",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions doc/api/esm.md
Expand Up @@ -1294,9 +1294,9 @@ success!
[`string`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
[`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
[`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
[`util.TextDecoder`]: util.html#util_class_util_textdecoder
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/0.4.0
[dynamic instantiate hook]: #esm_code_dynamicinstantiate_code_hook
[`util.TextDecoder`]: util.md#util_class_util_textdecoder
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/0.4.2
[special scheme]: https://url.spec.whatwg.org/#special-scheme
[the official standard format]: https://tc39.github.io/ecma262/#sec-modules
[transpiler loader example]: #esm_transpiler_loader
Expand Down
14 changes: 4 additions & 10 deletions lib/internal/modules/esm/translators.js
Expand Up @@ -59,20 +59,14 @@ const asyncESM = require('internal/process/esm_loader');

let cjsParse;
async function initCJSParse() {
if (typeof WebAssembly !== 'undefined') {
if (typeof WebAssembly === 'undefined') {
cjsParse = require('internal/deps/cjs-module-lexer/lexer');
} else {
const { parse, init } =
require('internal/deps/cjs-module-lexer/dist/lexer');
await init();
let exports;
try {
({ exports } = parse('exports.a=1'));
if (exports.length === 1) {
cjsParse = parse;
return;
}
} catch {}
cjsParse = parse;
}
cjsParse = require('internal/deps/cjs-module-lexer/lexer');
}

const translators = new SafeMap();
Expand Down

0 comments on commit ea23939

Please sign in to comment.