-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix loading of built-in plugins when using an ESM or TypeScript config with the Standalone CLI #12506
Conversation
@RobinMalfait any objections to my I can't override loadConfig directly I'm pretty sure because it's compiled as a non-configurable property of the module's exports. |
…he standalone CLI Fix code style
a96f6c1
to
32b4a67
Compare
…g with the Standalone CLI (#12506)
If you're interested, tsx just released a Since tsx adoption is quite high, leveraging it if it's already available could be an option. |
In the case of a config that's not directly loadable by NodeJS — for example because it is TypeScript, ESM, or uses unsupported syntax, we invoke JITI to load the config file.
Normally there are no problems caused by this. However, in the standalone CLI we provide our plugins already built-in. This becomes a problem because JITI uses a version of require that we were not patching to load the built in plugins.
Making this work is a bit more complicated than it seems at first glance and relies on an internal implementation detail of JITI. However, it's probably one that's not subject to change too much (… famous last words — I know)
Basically we now:
require
andrequire.resolve
that's available natively to every module loaded by NodecreateRequire
to return patched require + resolve functions that work the same wayFixes #12374