From f59f01a762e80fbdd3b014c78860ed21ef70a78f Mon Sep 17 00:00:00 2001 From: Eneas Rotterdam Date: Thu, 5 Dec 2024 22:09:01 +0100 Subject: [PATCH] chore: fix cosmos to start with the latest Node version The --experimental-policy flag was removed in Node v22.2.0. --- cosmos-import.js | 12 ++++++++++++ cosmos-policy.json | 12 ------------ package.json | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 cosmos-import.js delete mode 100644 cosmos-policy.json diff --git a/cosmos-import.js b/cosmos-import.js new file mode 100644 index 0000000000..8dcbfdc3d4 --- /dev/null +++ b/cosmos-import.js @@ -0,0 +1,12 @@ +import { register } from 'node:module'; +import { pathToFileURL } from 'node:url'; + +register(pathToFileURL('cosmos-import.js')); + +export async function resolve(specifier, context, nextResolve) { + if (specifier === 'react') { + return nextResolve('preact/compat', context); + } + + return nextResolve(specifier, context); +} diff --git a/cosmos-policy.json b/cosmos-policy.json deleted file mode 100644 index 6f8a78d3d8..0000000000 --- a/cosmos-policy.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "dependencies": true, - "scopes": { - "": { - "cascade": true, - "integrity": true, - "dependencies": { - "react": "./node_modules/preact/compat/dist/compat.mjs" - } - } - } -} diff --git a/package.json b/package.json index 499d28ef92..0c3a825799 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "build:safari": "rspack --env target=safari", "build:thunderbird": "rspack --env target=thunderbird", "check-keys": "tsx scripts/check-keys", - "cosmos": "node --experimental-policy=cosmos-policy.json node_modules/react-cosmos/bin/cosmos.js", - "cosmos-export": "node --experimental-policy=cosmos-policy.json node_modules/react-cosmos/bin/cosmos-export.js", + "cosmos": "node --import=./cosmos-import.js node_modules/react-cosmos/bin/cosmos.js", + "cosmos-export": "node --import=./cosmos-import.js node_modules/react-cosmos/bin/cosmos-export.js", "postinstall": "if-env RELEASE_BUILD=1 || husky", "lint": "web-ext lint && eslint src/", "package": "rspack --env package",