Skip to content

refactor: complete move to Vite Environment API#3634

Merged
marvinhagemeister merged 5 commits intodenoland:mainfrom
lishaduck:envapi
Dec 9, 2025
Merged

refactor: complete move to Vite Environment API#3634
marvinhagemeister merged 5 commits intodenoland:mainfrom
lishaduck:envapi

Conversation

@lishaduck
Copy link
Contributor

@lishaduck lishaduck commented Nov 20, 2025

I was perusing the code whilst investigating #3606 and noticed that, despite the release post claiming that Fresh had "fully embrace[d]" the Vite Environment API, it was still using ssrLoadModule. Once I started looking, I noticed a bunch of other code that wasn't future-proof (env-wise, not rolldown-wise, which'll bring it's own swath of deprecations1), so I updated them as well.

The newly added source map tests from #3624 currently fail again because the ModuleRunner API at the heart of the Environment API relies on process.setSourceMapsEnabled, which is currently set to no-op in Deno.

Footnotes

  1. Separately tried to try out rolldown-vite but it seems that Deno doesn't support aliasing dependencies whatsoever? (I know there's not official support, but I was going to try to edit the lockfile to hack around it; however, it seems that there's not alias support in there at all?)

@lishaduck
Copy link
Contributor Author

which is currently set to no-op in Deno

Looked closer, the actual code has a comment saying source maps are always on, so not sure what's up with that?

Comment on lines +78 to +93
const key =
`${this.environment.config.consumer}::${resolved.id}::${importer}`;
if (!seen.has(key)) {
result = check(pluginOptions, resolved.id, env);
result = check(
pluginOptions,
resolved.id,
this.environment.config.consumer,
);
}

seen.add(key);
}
} else {
const key = `${env}::${id}::${importer}`;
const key = `${this.environment.config.consumer}::${id}::${importer}`;
if (!seen.has(key)) {
result = check(pluginOptions, id, env);
result = check(pluginOptions, id, this.environment.config.consumer);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code might be better off using this.environment.name for the keys.

Copy link
Collaborator

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll bring the missing process method up to the CLI team

EDIT: nvm made a patch myself denoland/deno#31358

@lishaduck
Copy link
Contributor Author

canary CI ran with denoland/deno#31358 and still failed, not sure what's up. I think it probably makes sense to split out the ModuleRunner commit, merge the others, and figure out the source map failures separately.

@lishaduck
Copy link
Contributor Author

I think it probably makes sense to split out the ModuleRunner commit [..] and figure out the source map failures separately.

Filed #3645 for further followup

@marvinhagemeister marvinhagemeister merged commit ab14d10 into denoland:main Dec 9, 2025
7 checks passed
@lishaduck lishaduck deleted the envapi branch December 9, 2025 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants