From a522525f13570c55c9217165176d0b2803446d3e Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Jun 2022 15:58:39 -0700 Subject: [PATCH 1/2] module: cjs-module-lexer WebAssembly fallback --- lib/internal/modules/esm/translators.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index bcd1775bac898e..505beda061ef08 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -61,8 +61,13 @@ async function initCJSParse() { } else { const { parse, init } = require('internal/deps/cjs-module-lexer/dist/lexer'); - await init(); - cjsParse = parse; + try { + await init(); + cjsParse = parse; + } + catch { + cjsParse = require('internal/deps/cjs-module-lexer/lexer').parse; + } } } From e82b07e4267e88a06518fc93c3e7786fcecc8fb0 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 28 Jun 2022 19:00:04 -0700 Subject: [PATCH 2/2] lint fix --- lib/internal/modules/esm/translators.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index 505beda061ef08..8fb3c96f8dc4c5 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -64,8 +64,7 @@ async function initCJSParse() { try { await init(); cjsParse = parse; - } - catch { + } catch { cjsParse = require('internal/deps/cjs-module-lexer/lexer').parse; } }