Skip to content

Commit

Permalink
Spelunking into #3270 incompatibility with ava test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jun 20, 2024
1 parent 6d99dd5 commit 44d160c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"scripts": {
"default": "npm run test",
"test": "npm run test:node && npm run test:ava",
"test:ava": "cross-env ELEVENTY_SKIP_ESM_RESOLVER=1 npx ava --verbose",
"test:ava": "npx ava --verbose --timeout 20s",
"test:node": "node --test test_node/tests.js",
"jsdoc": "rm -rf jsdoc && npx jsdoc src/* -r -d jsdoc",
"format": "prettier . --write",
Expand Down
6 changes: 4 additions & 2 deletions src/Util/Require.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const { port1, port2 } = new MessageChannel();
// ESM Cache Buster is an enhancement that works in Node 18.19+
// https://nodejs.org/docs/latest/api/module.html#moduleregisterspecifier-parenturl-options
// Fixes https://github.com/11ty/eleventy/issues/3270
// Temporary: ELEVENTY_SKIP_ESM_RESOLVER to opt-out of Node 22 Ubuntu tests

// Temporary: ELEVENTY_SKIP_ESM_RESOLVER for test suite only to workaround incompatibility
// with Ava’s worker threads (timed out on Node 22 Ubuntu)
if ("register" in module && !process.env.ELEVENTY_SKIP_ESM_RESOLVER) {
module.register("./EsmResolver.js", import.meta.url, {
data: {
Expand Down Expand Up @@ -57,7 +59,7 @@ eventBus.on("eleventy.importCacheReset", (fileQueue) => {
lastModifiedPaths.set(absolutePath, newDate);

// post to EsmResolver worker thread
if (port1) {
if (!process.env.ELEVENTY_SKIP_ESM_RESOLVER && port1) {
port1.postMessage({ path: absolutePath, newDate });
}

Expand Down

0 comments on commit 44d160c

Please sign in to comment.