diff --git a/src/shell.js b/src/shell.js index 6629250620d6e..5a366dba92d00 100644 --- a/src/shell.js +++ b/src/shell.js @@ -105,7 +105,7 @@ if (ENVIRONMENT_IS_NODE) { // We need to use `createRequire()` to construct the require()` function. const { createRequire } = await import('module'); /** @suppress{duplicate} */ - var require = createRequire('/'); + var require = createRequire(import.meta.url); #endif #if PTHREADS || WASM_WORKERS diff --git a/test/common.py b/test/common.py index f40b1a330edd2..80787c259cde3 100644 --- a/test/common.py +++ b/test/common.py @@ -1334,7 +1334,7 @@ def verify_es5(self, filename): self.fail('es-check failed to verify ES5 output compliance') # Build JavaScript code from source code - def build(self, filename, libraries=None, includes=None, force_c=False, output_suffix='.js', emcc_args=None, output_basename=None): + def build(self, filename, libraries=None, includes=None, force_c=False, emcc_args=None, output_basename=None, output_suffix=None): if not os.path.exists(filename): filename = test_file(filename) compiler = [compiler_for(filename, force_c)] @@ -1343,6 +1343,9 @@ def build(self, filename, libraries=None, includes=None, force_c=False, output_s assert shared.suffix(filename) != '.c', 'force_c is not needed for source files ending in .c' compiler.append('-xc') + if not output_suffix: + output_suffix = '.mjs' if '-sEXPORT_ES6' in emcc_args else '.js' + if output_basename: output = output_basename + output_suffix else: diff --git a/test/other/codesize/test_codesize_minimal_esm.gzsize b/test/other/codesize/test_codesize_minimal_esm.gzsize index 57c7c05238e16..e496d6e71db34 100644 --- a/test/other/codesize/test_codesize_minimal_esm.gzsize +++ b/test/other/codesize/test_codesize_minimal_esm.gzsize @@ -1 +1 @@ -1542 +1543 diff --git a/test/other/codesize/test_codesize_minimal_esm.jssize b/test/other/codesize/test_codesize_minimal_esm.jssize index 465a35cfc4a0f..28206c2881752 100644 --- a/test/other/codesize/test_codesize_minimal_esm.jssize +++ b/test/other/codesize/test_codesize_minimal_esm.jssize @@ -1 +1 @@ -3210 +3222 diff --git a/test/test_sockets.py b/test/test_sockets.py index 7d3f342bc8d31..4253fdac43a9d 100644 --- a/test/test_sockets.py +++ b/test/test_sockets.py @@ -117,10 +117,11 @@ def __enter__(self): npm_checked = True # compile the server - proc = run_process([EMCC, '-Werror', test_file(self.filename), '-o', 'server.js', '-DSOCKK=%d' % self.listen_port] + self.args) + suffix = '.mjs' if '-sEXPORT_ES6' in self.args else '.js' + proc = run_process([EMCC, '-Werror', test_file(self.filename), '-o', 'server' + suffix, '-DSOCKK=%d' % self.listen_port] + self.args) print('Socket server build: out:', proc.stdout or '', '/ err:', proc.stderr or '') - process = Popen(config.NODE_JS + ['server.js']) + process = Popen(config.NODE_JS + ['server' + suffix]) self.processes.append(process) return self @@ -166,11 +167,6 @@ def setUpClass(cls): print('Running the socket tests. Make sure the browser allows popups from localhost.') print() - # Use emscripten root for node module lookup. This is needed because the unit tests each - # run with CWD set to a temporary directory outside the emscripten tree. - print('Setting NODE_PATH=' + path_from_root('node_modules')) - os.environ['NODE_PATH'] = path_from_root('node_modules') - # Note: in the WebsockifyServerHarness and CompiledServerHarness tests below, explicitly use # consecutive server listen ports, because server teardown might not occur deterministically # (python dtor time) and is a bit racy. @@ -283,7 +279,7 @@ def test_enet(self): @crossplatform @parameterized({ 'native': [WebsockifyServerHarness, 59160, ['-DTEST_DGRAM=0']], - 'tcp': [CompiledServerHarness, 59162, ['-DTEST_DGRAM=0']], + 'tcp': [CompiledServerHarness, 59162, ['-DTEST_DGRAM=0', '-sEXPORT_ES6', '--extern-post-js', test_file('modularize_post_js.js')]], 'udp': [CompiledServerHarness, 59164, ['-DTEST_DGRAM=1']], 'pthread': [CompiledServerHarness, 59166, ['-pthread', '-sPROXY_TO_PTHREAD']], })