-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
react-markdown doesn't work in SSR dev #5890
Comments
The code has:
In
It's encountering:
So this is not being treated as external. I think if we did it would fix this. @brillout has suggested several times that we treat all dependencies as external by default |
This seems suspect to me:
This was added in #5197. CC @natemoo-re |
Perhaps we should revisit the suggestion in this comment: #5544 (comment). I.e. rather than only externalizing packages that meet a certain specification, we should reverse that check, externalize by default, and only transform in certain cases where it's necessary. And I'm not sure it's ever necessary. I had been wondering about things like AMD or SystemJS, but I don't think Rollup works with those anyway? Because I realized that even to handle CommonJS, there's |
Isn't it actually necessary to transform in this case, at least in production build? If we don't transform, the CJS build will try to require an ESM module which will break the build. It doesn't break the dev for some reason, but build doesn't work. |
@cyco130 It's expected and a good thing, see #4340 (comment)
👍 And it makes reasoning about |
I dont think this issue should be added as a 2.7 goal. its not a breaking change and not a regression |
Hmm. This particular report was broken before 2.7, but the line that's breaking currently was added in 2.7, so I'm not 100% sure there wouldn't be a regression for other libraries given that there is newly added code that's incorrect. In any case, this shouldn't be hard to get into 2.7 since I've sent a fix for it already: #5903 |
I agree with Niputi here, the fix looks a bit involved for this point of the beta. Let's try to fix the other two remaining regressions and do the release (https://github.com/vitejs/vite/milestone/4) |
@patak-js I will have a look at these 2 regressions. (But let me finish 2 highest prio vite-plugin-ssr things I need to finish today. Hopefully I'll have some spare time for this later today.) |
I still think it's incorrect to say there's no regression here in 2.7. While the reproduction the reporter shared doesn't demonstrate a regression, if you read the code it sure looks like there's one and I'd expect we could create a reproduction. The newly introduced code says the package should be externalized if |
Describe the bug
react-markdown
fails withReferenceError: module is not defined
when I try to import it from a module loaded withssrLoadModule
. It seems to be caused by mixing ES modules and CJS modules in the transitive dependencies. Everything works as expected when I add"type": "module"
topackage.json
.Reproduction
node ssr-module.mjs
and observe thatreact-markdown
works correctly when run directly.node index.cjs
and observe loading with SSR fails."type": "module"
topackage.json
to fix it.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: