Skip to content

Commit 4a40de1

Browse files
authored
Revert use of import.meta.dirname in the compiler (#23410)
In #23349 we (I) accidentally broke running emscripten with node older than v19 and as it happens debian/stable still ships v18: https://packages.debian.org/bookworm/nodejs This change reverts #23349 and also explicitly bumps the minimum version up to v18. I've also added some testing to CI to ensure we can actually run using this version. See #23396 and #23407
1 parent 95dfa38 commit 4a40de1

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

.circleci/config.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ jobs:
642642
# version of node (node canary) when running the compiler output (e.g.
643643
# in configure tests.
644644
- run:
645-
name: configure node canary
645+
name: configure compiler to use node-canary
646646
command: echo "NODE_JS = NODE_JS_TEST" >> ~/emsdk/.emscripten
647647
- run-tests:
648648
title: "wasm64"
@@ -746,6 +746,18 @@ jobs:
746746
command: git submodule update --init
747747
- pip-install
748748
- install-emsdk
749+
# `install-node-version` only changes the NODE_JS_TEST (the version of
750+
# node used to run test), not NODE_JS (the version of node used to run the
751+
# compiler itself).
752+
# In order to test that the compiler itself can run under the oldest
753+
# supported version of node, we run all the tests in the runner under that
754+
# version.
755+
# Keep this in sync with MINIMUM_NODE_VERSION in tools/shared.py.
756+
- install-node-version:
757+
node_version: "18.0.0"
758+
- run:
759+
name: configure compiler to use 18.0.0
760+
command: echo "NODE_JS = '$(which node)'" >> ~/emsdk/.emscripten
749761
- install-node-canary
750762
- run-tests:
751763
title: "node (canary)"
@@ -760,7 +772,8 @@ jobs:
760772
core0.test_async_ccall_promise_exit_runtime_jspi
761773
core0.test_cubescript_jspi"
762774
# Run some basic tests with the minimum version of node that we currently
763-
# support.
775+
# support in the generated code.
776+
# Keep this in sync with `OLDEST_SUPPORTED_NODE` in `feature_matrix.py`
764777
- install-node-version:
765778
node_version: "10.19.0"
766779
- run-tests:

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.1 (in development)
2222
----------------------
23+
- The minimum version of node required to run emscripten was bumped from v16.20
24+
to v18. Version 4.0 was mistakenly shipped with a change that required v20,
25+
but that was revered. (#23410)
2326

2427
4.0.0 - 01/14/25
2528
----------------

src/utility.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// General JS utilities - things that might be useful in any JS project.
88
// Nothing specific to Emscripten appears here.
99

10+
import * as url from 'node:url';
1011
import * as path from 'node:path';
1112
import * as fs from 'node:fs';
1213
import * as vm from 'node:vm';
@@ -230,8 +231,11 @@ export function read(filename) {
230231
return fs.readFileSync(absolute, 'utf8');
231232
}
232233

234+
// Use import.meta.dirname here once we drop support for node v18.
235+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
236+
233237
function find(filename) {
234-
for (const prefix of [process.cwd(), import.meta.dirname]) {
238+
for (const prefix of [process.cwd(), __dirname]) {
235239
const combined = path.join(prefix, filename);
236240
if (fs.existsSync(combined)) {
237241
return combined;

test/test_sanity.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ def test_node(self):
286286
for version, succeed in (('v0.8.0', False),
287287
('v4.1.0', False),
288288
('v10.18.0', False),
289-
('v16.20.0', True),
290-
('v16.20.1-pre', True),
289+
('v16.20.0', False),
290+
('v18.0.0', True),
291+
('v18.0.1-pre', True),
291292
('cheez', False)):
292293
print(version, succeed)
293294
delete_file(SANITY_FILE)

tools/shared.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
# Minimum node version required to run the emscripten compiler. This is
5858
# distinct from the minimum version required to execute the generated code
5959
# (settings.MIN_NODE_VERSION).
60-
# This version currently matches the node version that we ship with emsdk
61-
# which means that we can say for sure that this version is well supported.
62-
MINIMUM_NODE_VERSION = (16, 20, 0)
60+
# This is currently set to v18 since this is the version of node available
61+
# in debian/stable (bookworm).
62+
MINIMUM_NODE_VERSION = (18, 0, 0)
6363
EXPECTED_LLVM_VERSION = 20
6464

6565
# These get set by setup_temp_dirs

0 commit comments

Comments
 (0)