Skip to content
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

fix(css): workaround tsx esModule interop of sass-embedded import #19182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Jan 11, 2025

Description

As seen in privatenumber/tsx#627, tsx unwraps named exports for __esModule and thus strips off default export. 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 unwrap default for __esModule automatically (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

  • node + sass-embedded
  • node + sass
  • tsx + sass-embedded (this was failing before)
  • tsx + sass

Copy link

pkg-pr-new bot commented Jan 11, 2025

Open in Stackblitz

npm i https://pkg.pr.new/vite@19182

commit: fb54eaf

@hi-ogawa hi-ogawa marked this pull request as ready for review January 11, 2025 07:05
@bluwy
Copy link
Member

bluwy commented Jan 13, 2025

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 .js files in node_modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sass dynamic import is undefined when building with "modern-compiler" and sass-embedded
2 participants