Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: run tests on node.js v21 nightly #199

Merged
merged 24 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/node.js.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ jobs:
runs-on: ${{ matrix.os }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
# node-14's npm must be updated, but no longer updatable due to:
# https://github.com/npm/cli/issues/2663
# because of this, node-14 test strategy is removed :(
node-version: [16.x, 18.x, 19.x]
# node-version: [16.x, 18.x, 19.x, 20.x, 20-nightly]
node-version: [16.x, 18.x, 19.x, 21-nightly]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"rewire"
],
"engines": {
"node": ">=14.16.0 <=19.9.0"
"node": ">=14.16.0"
},
"dependencies": {
"resolvewithplus": "^2.0.1"
Expand Down
2 changes: 2 additions & 0 deletions src/esmockCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const esmockCache = {
}

const esmockTreeIdSet = (key, keylong) => (
(typeof global.postMessageEsmk === 'function')
iambumblehead marked this conversation as resolved.
Show resolved Hide resolved
&& global.postMessageEsmk({ key, keylong }),
global.mockKeys[String(key)] = keylong)

const esmockTreeIdGet = key => (
Expand Down
9 changes: 8 additions & 1 deletion src/esmockLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ const withHashRe = /.*#-#/
const isesmRe = /isesm=true/
const isnotfoundRe = /isfound=false/

const globalPreload = (({ port }) => (
port.addEventListener('message', ev => (
global.mockKeys[ev.data.key] = ev.data.keylong)),
port.unref(),
'global.postMessageEsmk = d => port.postMessage(d)'
))

// new versions of node: when multiple loaders are used and context
// is passed to nextResolve, the process crashes in a recursive call
// see: /esmock/issues/#48
Expand Down Expand Up @@ -123,4 +130,4 @@ const load = async (url, context, nextLoad) => {
// node lt 16.12 require getSource, node gte 16.12 warn remove getSource
const getSource = isLT1612 && load

export {load, resolve, getSource, loaderIsVerified}
export {load, resolve, getSource, loaderIsVerified, globalPreload}