fix(css): workaround tsx esModule interop of sass-embedded import#19182
fix(css): workaround tsx esModule interop of sass-embedded import#19182hi-ogawa wants to merge 1 commit intovitejs:mainfrom
Conversation
commit: |
|
I personally prefer to not add special handling here and have it fixed in tsx instead. It looks like it's going to affect more modules that only sass-embedded, and also it's not clear to me why it's mangling the exports of |
|
The solution to the original issue referred to by this PR — Add to |
|
The situation has just changed after Vite 7 release. As mentioned in migration guide in Vite 7 there is no way to use There are already three PRs in Vite trying to fix this:
All three PRs are almost identical :) I know that the source of the problem probably the issue in tsx, but as I understand it might be quite hard to fix it and the issue . My points to go ahead with such fix (maybe, we should change the PR a bit):
I am ready to provide any additional context or to create another PR with suggested changes if needed. @hi-ogawa, can we please proceed with this? |
|
Just an update. I finally found a quite simple and reliable way to use complex TypeScript Vite configurations in our project. Earlier before Vite 7 release we used Now we removed Instead, we now use tsx ESM Register API. It works like a charm without any errors and, because we use So finally, I think I am done with this approach. I am actually now not sure if we should fix this "SASS import" issue. Instead, maybe we can make Vite a bit better when using it with complex TypeScript configurations (#5370)? I know, there is now a So finally here are couple of things to consider: maybe we can just document how to use |
|
I'm currently experiencing an issue when using Vite+Vue+Cypress@15.0.0+TypeScript that can be fixed by this PR's changes (I've applied these change as patch, and it works well afterward). Since Cypress version 15.0.0, they've switched to using TSX under the hood, and we are having difficulty using Vite as file preprocessor ever since (if we have Here's the issue on Cypress repo: cypress-io/cypress#32362 Can these PR be included in a (near) future version of Vite? |
|
I'm one of Quasar framework maintainers, this is a blocker for supporting Cypress 15 in our Cypress integration package Related: quasarframework/quasar-testing#403 |
|
Fixed by #20918 |
Description
sassdynamic import is undefined when building with "modern-compiler" and sass-embedded #19052__esModuleinterop is applied to .cjs files privatenumber/tsx#627As seen in privatenumber/tsx#627, tsx unwraps named exports for
__esModuleand thus strips offdefaultexport. The issue seems to be acknowledged as node inconsistency bug, but I'm not sure about the plan. Vite side fallback is simple, so probably it's worth having it.From my quick read through, tsx transforms
import(xxx)to unwrapdefaultfor__esModuleautomatically (transform-dynamic-import.ts). This seems to happen for all esm code loaded via tsx (load.ts).I tested four combinations locally based on https://github.com/hi-ogawa/reproductions/tree/main/vite-19182-sass-tsx