From e328a22d030edaab9a81be7a7e82666208cbcc66 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Thu, 19 Dec 2024 11:33:52 -0500 Subject: [PATCH] back out the vite-specific prefix matching hacks --- packages/core/src/module-resolver.ts | 36 +++---------------------- packages/core/src/virtual-entrypoint.ts | 14 +++++----- packages/vite/src/request.ts | 6 +++++ 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/packages/core/src/module-resolver.ts b/packages/core/src/module-resolver.ts index 2c57e556f..ef8f8f425 100644 --- a/packages/core/src/module-resolver.ts +++ b/packages/core/src/module-resolver.ts @@ -401,14 +401,7 @@ export class Resolver { } private handleImplicitTestScripts(request: R): R { - //TODO move the extra forwardslash handling out into the vite plugin - const candidates = [ - '@embroider/virtual/test-support.js', - '/@embroider/virtual/test-support.js', - './@embroider/virtual/test-support.js', - ]; - - if (!candidates.includes(request.specifier)) { + if (request.specifier !== '@embroider/virtual/test-support.js') { return request; } @@ -427,14 +420,7 @@ export class Resolver { } private handleTestSupportStyles(request: R): R { - //TODO move the extra forwardslash handling out into the vite plugin - const candidates = [ - '@embroider/virtual/test-support.css', - '/@embroider/virtual/test-support.css', - './@embroider/virtual/test-support.css', - ]; - - if (!candidates.includes(request.specifier)) { + if (request.specifier !== '@embroider/virtual/test-support.css') { return request; } @@ -485,14 +471,7 @@ export class Resolver { } private handleVendorStyles(request: R): R { - //TODO move the extra forwardslash handling out into the vite plugin - const candidates = [ - '@embroider/virtual/vendor.css', - '/@embroider/virtual/vendor.css', - './@embroider/virtual/vendor.css', - ]; - - if (!candidates.includes(request.specifier)) { + if (request.specifier !== '@embroider/virtual/vendor.css') { return request; } @@ -958,14 +937,7 @@ export class Resolver { } private handleVendor(request: R): R { - //TODO move the extra forwardslash handling out into the vite plugin - const candidates = [ - '@embroider/virtual/vendor.js', - '/@embroider/virtual/vendor.js', - './@embroider/virtual/vendor.js', - ]; - - if (!candidates.includes(request.specifier)) { + if (request.specifier !== '@embroider/virtual/vendor.js') { return request; } diff --git a/packages/core/src/virtual-entrypoint.ts b/packages/core/src/virtual-entrypoint.ts index 7955b4dfd..d509d365b 100644 --- a/packages/core/src/virtual-entrypoint.ts +++ b/packages/core/src/virtual-entrypoint.ts @@ -23,14 +23,12 @@ export function virtualEntrypoint( request: ModuleRequest, packageCache: PackageCachePublicAPI ): VirtualResponse | undefined { - //TODO move the extra forwardslash handling out into the vite plugin - const candidates = [ - '@embroider/virtual/compat-modules', - '/@embroider/virtual/compat-modules', - './@embroider/virtual/compat-modules', - ]; - - if (!candidates.some(c => request.specifier.startsWith(c + '/') || request.specifier === c)) { + const compatModulesSpecifier = '@embroider/virtual/compat-modules'; + + let isCompatModules = + request.specifier === compatModulesSpecifier || request.specifier.startsWith(compatModulesSpecifier + '/'); + + if (!isCompatModules) { return undefined; } diff --git a/packages/vite/src/request.ts b/packages/vite/src/request.ts index 7cab24b02..747944559 100644 --- a/packages/vite/src/request.ts +++ b/packages/vite/src/request.ts @@ -30,6 +30,12 @@ export class RollupRequestAdapter implements RequestAdapter