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

transformer: vite ssrTransform #9169

Open
Boshen opened this issue Feb 17, 2025 · 2 comments
Open

transformer: vite ssrTransform #9169

Boshen opened this issue Feb 17, 2025 · 2 comments
Assignees
Labels
C-enhancement Category - New feature or request

Comments

@Boshen Boshen added the C-enhancement Category - New feature or request label Feb 17, 2025
@Boshen Boshen added this to the Transformer Milestone 3 milestone Feb 17, 2025
@overlookmotel
Copy link
Contributor

overlookmotel commented Feb 17, 2025

Vite uses magic string for this transform. Some of the tests require that code in output is on same line as in input. e.g.:

https://github.com/vitejs/vite/blob/00deea4ff88e30e299cb40a801b5dc0205ac913d/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts#L239-L298

I assume this is to avoid the need for source maps.

Currently we don't have ability in oxc_codegen to retain same lines in output, so I guess we would need to either:

  1. Add that ability to oxc_codegen (probably not easy). or
  2. Do this transform using string manipulation (magic string). or
  3. Do transform via AST manipulation and generate source map.

Whether option (2) is a viable approach depends on whether this transform needs to run in concert with other transforms, or whether it always runs alone.

Broader thought: If best approach is magic string manipulation, there's an argument that this shouldn't be in Oxc transformer at all. It'd work completely differently from all the other transforms, and might be better considered a Rolldown thing.

@Dunqing
Copy link
Member

Dunqing commented Feb 18, 2025

Vite uses magic string for this transform. Some of the tests require that code in output is on same line as in input. e.g.:

https://github.com/vitejs/vite/blob/00deea4ff88e30e299cb40a801b5dc0205ac913d/packages/vite/src/node/ssr/__tests__/ssrTransform.spec.ts#L239-L298

Have you seen vitejs/vite#19004?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category - New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants