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 Oct 14, 2020
1 parent 6265951 commit ab0af50
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ success!
[`transformSource` hook]: #esm_transformsource_source_context_defaulttransformsource
[`string`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
[`util.TextDecoder`]: util.md#util_class_util_textdecoder
[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/0.4.0
[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
14 changes: 4 additions & 10 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,14 @@ const { emitWarningSync } = require('internal/process/warning');

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 ab0af50

Please sign in to comment.