-
Notifications
You must be signed in to change notification settings - Fork 970
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
feat(vite): add plugin to remove modules from the bundle #8973
Conversation
packages/vite/src/plugins/__tests__/remove-from-bundle.test.mts
Outdated
Show resolved
Hide resolved
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
This is rightfully failing CI—can't get the contact page to render at all when serving, and get an error in the console about the request splash-page returning the wrong mime type |
Yeah I guess making it external isn't good enough, we need to make it load "nothing" when building. Let me try another approach! |
@jtoar pushed up a new version, have a look please! I don't think node:test has been configured correctly - but I'm not going to bite on this.. is there a reason to not use Jest like all the other packages? The strange way of importing is something to do with module resolution in tsconfig compiler settings, but my preference would've just been to use jest. @Tobbe maybe you configured node:test mind taking a look what's going on? |
Thanks @dac09. I think we played around with node's test runner just to see what it would be like, since if we moved our packages to ESM Jest wouldn't understand how to test those files without Babel, or without other experimental Jest config. Now that I've got some experience with it, node's test runner doesn't seem that much better than Jest w/ Babel. At least not if our TS tooling still thinks a package isn't ESM. Update: was about to merge but noticed something here @dac09: #8973 (comment). |
name: 'remove-from-bundle', | ||
apply: 'build', // <-- @MARK important | ||
load: (id) => { | ||
excludeOnMatch(modulesToExclude, id) |
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.
Do we need to return
here?
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.
Yep yep! Must've broken it trying get it working for the test! Pushing up in a bit
Analyzing the bundle produced by
yarn rw build web
with Vite reveals a few things we could improve. This PR improves one of them, which is not bundling the splash page you see when you have no Routes in dev. This sheds ~4% off a default Redwood app:Next would be core-js-pure.
Note that I actually can't get this test to run. When I runyarn test
inpackages/vite
, I get the following error...@Tobbe was hoping you had ideas since I think you wrote the test in this package? I need to merge this, so not going to wait for that to be resolved. Will confirm it works manually for now, but if you get the chance, you can tell me or open a PRGot them working.