Skip to content

Commit

Permalink
back out the vite-specific prefix matching hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Dec 19, 2024
1 parent cef16b4 commit 68673d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 40 deletions.
36 changes: 4 additions & 32 deletions packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,7 @@ export class Resolver {
}

private handleImplicitTestScripts<R extends ModuleRequest>(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;
}

Expand All @@ -427,14 +420,7 @@ export class Resolver {
}

private handleTestSupportStyles<R extends ModuleRequest>(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;
}

Expand Down Expand Up @@ -485,14 +471,7 @@ export class Resolver {
}

private handleVendorStyles<R extends ModuleRequest>(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;
}

Expand Down Expand Up @@ -958,14 +937,7 @@ export class Resolver {
}

private handleVendor<R extends ModuleRequest>(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;
}

Expand Down
14 changes: 6 additions & 8 deletions packages/core/src/virtual-entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 68673d4

Please sign in to comment.