Skip to content

fix: loaders 20.5 #1028

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

Closed
wants to merge 1 commit into from
Closed

fix: loaders 20.5 #1028

wants to merge 1 commit into from

Conversation

reggi
Copy link

@reggi reggi commented May 31, 2024

related: #950

so some versions of node (19 - 20 ) in the transition from --loaders to --imports broke the execution order of loaders, in a way the spec around loaders using other loaders was kinda janky.

looking at https://github.com/tapjs/tapjs/blob/main/src/run/src/test-argv.ts#L44-L51 and pulling out combinations of what's generated for 20.5 we see

node \
--loader=./node_modules/@isaacs/ts-node-temp-fork-for-pr-2009/esm.mjs \
--loader=./node_modules/@tapjs/mock/dist/esm/legacy-loader.mjs \
--enable-source-maps \
--loader=./node_modules/@tapjs/processinfo/dist/esm/loader-legacy.mjs \
./test/main.js

this fails, however when you remove the processinfo loader it passes, or when you remove the mock it works, which led me to think this was an error with chaining the two.

the issue lies in the mock loader reading in the processinfo imports before the mock has be initialized this can be fixed in three ways.

  1. just don't throw for the mock loader, the initial calls are all from processinfo then the mock loader initializes and it works again
  2. as in this pr, don't throw after the mock loader has initialized the client
  3. some kind of janky ban list of modules that processinfo uses like which works but it's really manual
const invalid = (url) => {
    if (!url) return false
    return (
        url.includes('/node_modules/@tapjs/processinfo') ||
        url.includes('/node_modules/uuid/') ||
        url.includes('/node_modules/process-on-spawn/') ||
        url.includes('/node_modules/signal-exit/') ||
        url.includes('/node_modules/pirates/') ||
        url.includes('/node_modules/signal-exit/') ||
        url === 'node:inspector'
    )
}

@reggi
Copy link
Author

reggi commented May 31, 2024

related effort to get tap working with older versions of node: isaacs/resolve-import#5

@reggi
Copy link
Author

reggi commented May 31, 2024

tbh I don't think this makes much sense as it is I'd rather just return if there's no client, why would the client exist then not exist... 🤔 this was an effort to keep the error but I don't think it makes sense.

@isaacs
Copy link
Member

isaacs commented May 31, 2024

To be honest? I'm super tempted to just set the engines to exclude v20.0.0 - 20.5.x, or even require >=20.6, because it's such a mess to support both loader and import arguments.

@reggi reggi closed this May 31, 2024
wraithgar pushed a commit to npm/template-oss that referenced this pull request Jan 30, 2025
Resurfaces an old PR that updated tap 16 -> 19 (still not sure what's
needed from that until i see the diff.
Had to do some googling to find why `/* istanbul ignore next */` doesn't
work anymore.

tapjs/tapjs#1027

got some node 22
failures - ENOENT: no such file or directory, open
'/home/runner/work/template-oss/template-oss/.tap/fixtures/test-apply-esm.js-basic/file.js'

doesn't work on 20.5.0 because of
tapjs/tapjs#1028
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy