-
I hope there is an easy solution for my challenge, let me give a quick overview: Frodo CLI is a command line tool based on node. Users can run it as a global NPM package or download a packaged binary (we use pkg) for linux, windows, and macos. Frodo CLI is based on Frodo Library. Both lib and cli are typescript projects (almost fully converted from CJS) and lib is a hybrid CJS/ESM library. It's been an adventure getting it all to work and one of the last pieces that finally got it all to function properly was the So one morning after an update to my laptop the NPM version of Frodo was broken and I found out that I had fallen victim to a change in node 19: nodejs/node#44859 . This is the error I was getting:
Reading through the PR description and comments I thought: wow, this might be a perfect opportunity to future-proof the tool and support node 19. Here is the challenge I'm seeking suggestions and ideas for: I've been using this as the first line in the
To start the migration to a custom loader, I added
Next I modified
If I now run the CLI from within the project directory, it works perfectly:
If, however, I run the CLI (which is installed as a global NPM package) from any other directory, node cannot find the custom loader:
How can I allow node to locate the custom loader when I launch from any directory outside the project folder? I greatly appreciate any suggestions. Thank y'all! |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 10 replies
-
The easiest workaround would be to use Another way is to use a data: URL that contains the whole loader, but that's not very practical. |
Beta Was this translation helpful? Give feedback.
The easiest workaround would be to use
--loader frodo/loader
(orfrodo/dist/loader.mjs
or similar if you're not using exports map) which would point to a file that doesexport * from 'commonjs-extension-resolution-loader';
(assumingcommonjs-extension-resolution-loader
is listed in the deps of your npm package). IIRC,frodo
installed globally means that Node.js should be able to resolvefrodo/loader
from anywhere, but maybe that's wrong, I don't know, I never use globally installed packages.Another way is to use a data: URL that contains the whole loader, but that's not very practical.