Skip to content

Commit 446e967

Browse files
authored
Revert "allow resolving unenv aliases to packages (#11083)" (#11086)
This reverts commit 57fc660.
1 parent 57fc660 commit 446e967

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

.changeset/petite-rules-kneel.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/vite-plugin-cloudflare/src/plugins/nodejs-compat.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -403,24 +403,15 @@ export class NodeJsCompat {
403403
): { unresolved: string; resolved: string } | undefined {
404404
const alias = this.#env.alias[source];
405405

406+
// These aliases must be resolved from the context of this plugin since the alias will refer to one of the
407+
// `@cloudflare/unenv-preset` or the `unenv` packages, which are direct dependencies of this package,
408+
// and not the user's project.
406409
// We exclude `externals` as these should be externalized rather than optimized.
407410
if (alias && !this.externals.has(alias)) {
408-
try {
409-
// These aliases must be resolved from the context of this plugin since the alias can refer to one of
410-
// the `@cloudflare/unenv-preset` or the `unenv` packages, which are direct dependencies of this package,
411-
// and not the user's project.
412-
// When the alias is a package (i.e. the `debug` npm package), `resolvePathSync` will throw
413-
return {
414-
unresolved: alias,
415-
resolved: resolvePathSync(alias, { url: import.meta.url }),
416-
};
417-
} catch {
418-
// Returns the raw alias when it can not be resolved.
419-
return {
420-
unresolved: source,
421-
resolved: alias,
422-
};
423-
}
411+
return {
412+
unresolved: alias,
413+
resolved: resolvePathSync(alias, { url: import.meta.url }),
414+
};
424415
}
425416

426417
if (this.entries.has(source)) {

0 commit comments

Comments
 (0)