-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
always bundle devDependencies #6301
Conversation
🦋 Changeset detectedLatest commit: 0545345 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This configuration caused problems for me in dev mode with devdeps that were only in CJS, thus the |
Blurgh. Is that an argument for tucking this away in the plugin, where we can control that without making everyone's configs more complicated, or is that a bad idea? |
I'd probably be in favor of hiding this in the plugin, if we could figure out what sort of merging we wanted to do with the user's explicit config. Maybe only include it if they don't have an A library that is causing me problems with this is https://www.npmjs.com/package/accept-language-parser - I'm trying to use this in server code, and in dev mode with the proposed Vite config I'm getting the error
in the browser, which certainly makes it sound like Vite is trying to read the CJS module in the package as-is as an ESM module. I haven't spent any time figuring out what Vite's doing here, or what Vite should be doing here, or whether there's already an issue for this. |
Have you looked at the test failures? That they are mostly about |
The |
Unfortunately I don't think this is possible — by the time the |
Yeah, Vite dev bundling is a hot mess, so I definitely would not enable it in dev, but would follow @Conduitry's example. This PR feels like it's probably the best compromise to me. The only thing I don't love about it is that it makes the default template more complicated, but I could get on board with that I'd be quite hesitant to make it part of the plugin because then the default Vite config is different in ways that the user might not expect and are hard to override even if they do. E.g. if they want to bundle something that we've added to |
Some people in the issue said this didn't work for them - does anybody know more about why that is? |
Maybe this can be combined with the PR I planed to do: https://github.com/tylkomat/kit/tree/package_json The changes would generate a production This would solve the mentioned problems in #3176 that the result has to be run to figure out which packages should have been moved from devDeps to deps. |
vite-plugin-svelte does some automated processing to handle dependencies that contain This is required to be able to resolve If someone were to put such a dependency in |
Errors appear:
Solution: import { builtinModules } from "module";
...
{
build: {
rollupOptions: {
external: builtinModules,
},
}
} |
And look at Automattic/mongoose#12335 |
@tylkomat's solution is interesting: tylkomat@1a57072 |
Not sure I understand — looks like that creates a Feels like adding an additional |
Yes you understood correctly. The question is if you can safely bundle every piece of code without side effects. My assumption is if Vite can bundle the code, it will do so. Why should there be a need to force it? |
@AlexRMU thanks, but unfortunately I can't make sense of what's going on from your comments here. You'll need to provide a reproduction in order for us to understand what possible issues might exist @dominikg would it make sense to have |
Can be done and makes sense given the footgun it has. Ideally we solve this problem by prebundling once that stabilized @bluwy might have an opinion here too. |
Yeah I think it'd make sense to warn if the user is doing something unlikely to work. Prebundling in SSR may still have a long way to come. |
After discussion, closing this in favour of #6372 which limits the scope of the changes to |
Closes #3176.
This is really just an idea, I'd be curious to know if people think it's the right one. It causes
devDependencies
(or rather, everything that isn't explicitly marked as a prod dependency) to be bundled in the Vite output, which makes the result more portable — you don't need to installdevDependencies
to run your app. If everything is indevDependencies
then it means your app is completely self-contained and you don't need tonpm install
anything to run it.Since we use
esbuild
inside certain adapters (the ones where usingnode_modules
isn't an option, like Cloudflare Workers) this change really only affects users ofadapter-node
, and we could therefore argue that it doesn't belong in the default config. It also feels a bit messy putting it here. But aside from making builds very slightly slower (albeit in a way that's completely in users' control, just by moving things betweendependencies
anddevDependencies
) it seems like the most pragmatic solution.I also considered adding this logic to the Vite plugin so that it didn't need to be added to the user config, but that felt a bit aggressive.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0