File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -74,12 +74,17 @@ function getSource(url) {
7474let cjsParse ;
7575/**
7676 * Initializes the CommonJS module lexer parser using the JavaScript version.
77- * TODO(joyeecheung): Use `require('internal/deps/cjs-module-lexer/dist/lexer').initSync()`
78- * when cjs-module-lexer 1.4.0 is rolled in.
7977 */
8078function initCJSParseSync ( ) {
8179 if ( cjsParse === undefined ) {
82- cjsParse = require ( 'internal/deps/cjs-module-lexer/lexer' ) . parse ;
80+ if ( typeof WebAssembly !== 'undefined' ) {
81+ const { parse, initSync } = require ( 'internal/deps/cjs-module-lexer/dist/lexer' ) ;
82+ initSync ( ) ;
83+ cjsParse = parse ;
84+ } else {
85+ const { parse } = require ( 'internal/deps/cjs-module-lexer/lexer' ) ;
86+ cjsParse = parse ;
87+ }
8388 }
8489}
8590
Original file line number Diff line number Diff line change 1+ // Flags: --jitless
2+
3+ // Tests that importing a CJS module works in JIT-less mode (i.e. falling back to the
4+ // JS parser if WASM is not available).
5+ import '../common/index.mjs' ;
6+ import '../fixtures/empty.cjs' ;
You can’t perform that action at this time.
0 commit comments