-
-
Notifications
You must be signed in to change notification settings - Fork 9.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
Core: Async load presets, replace interpret with esbuild-register #18619
Core: Async load presets, replace interpret with esbuild-register #18619
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 645e1b8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
@ndelangen so does this mean at the point we first require a user file we register esbuild and then from then on everything that gets required (including our own code) gets passed through it? I guess in node, everything of our own will have already been required before this point (no code splitting or async imports). I guess I am just a tiny bit concerned about inconsistencies of in some circumstances importing our code through esbuild and in others not. What's your thinking here @ndelangen? |
Every time a user's file get loaded I register the esbuild-register, then when it's loaded I unload it. |
How are you doing that? I'm not seeing it..? |
Hmm, I must have undone that work for some reason @tmeasday I'll change it to what I had. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I'd love to test this out in my vite project, but as far as I know, the future branch is not compatible with the vite-builder, right? |
2c04a75
to
fba9296
Compare
…d-presets-esbuild-register # Conflicts: # lib/core-common/src/presets.ts # lib/core-common/src/utils/interpret-require.ts
@tmeasday I think there's race conditions when registering and unregistering the esbuild loader in storyshots. 😢 |
the interpret package didn't unregister either btw |
…gister Future - prep for #18619
@tmeasday I agree with you that registering and then unregistering is better, and safer. But somehow storyshots is dependent on the registering happening globally and staying registered. I do not want to invest any time into storyshots, mainly because I'd rather work on improving testing library to replace it. I propose we merge as is. |
@ndelangen I would be happy to spend some time investigating, I've seen errors like this from SS before and I generally have figured them out. However, I did:
and all the tests passed 🤷 I'll rerun the job in CI. |
I also could not reproduce locally, at first, then after some trial and error I could get some story shots test to fail, but when running them in isolation they'd succeed. |
As discussed I think the register-once approach is probably better anyway. I would consider registering right at the start, rather than when we load our first user file; but if that's what we were doing before it's probably fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super excited about this @ndelangen 🚀
@tmeasday this kinda replaces your PR: #18025
It does not preserve the
import()
, but that's because there's no way to make that work with TypeScript AFAICS.This adds an esbuild-register as soon as it's needed, but only once; this mutates the
require
method in Node to run code through esbuild (which does support TypeScript and other stuff.I need to experiment more, but this also seems much faster!
@shilman the removes the interpreter "nonsense", too..