-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-enable the module resolution build tests (#80)
* re-enable the module resolution build tests * completely remove the non-existing package module-resolution test
- Loading branch information
1 parent
2b0ec21
commit 40c0c52
Showing
6 changed files
with
35 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,29 @@ | ||
const allowedPaths = new Set([ | ||
'/require-ext', | ||
'/require-no-ext', | ||
'/require-json', | ||
'/cloudflare-imports', | ||
'/external-cloudflare-imports', | ||
|
||
'/third-party/react', | ||
'/third-party/remix', | ||
'/third-party/discord-api-types', | ||
'/third-party/slash-create', | ||
]); | ||
const modules = import.meta.glob('../src/**/*.ts'); | ||
|
||
export default { | ||
async fetch(request) { | ||
const url = new URL(request.url); | ||
const path = url.pathname; | ||
|
||
if (allowedPaths.has(path)) { | ||
const mod = await import(/* @vite-ignore */ `./${path}`); | ||
return Response.json(mod.default); | ||
const filePath = `${path.replace(/^\//, './')}.ts`; | ||
|
||
if (modules[filePath]) { | ||
const mod = await modules[filePath](); | ||
return Response.json((mod as { default: unknown }).default); | ||
} | ||
|
||
if (path === '/@alias/test') { | ||
const { test } = await import('@alias/test'); | ||
return test(); | ||
} | ||
|
||
if (path === '/@non-existing/pkg') { | ||
const { test } = await import('@non-existing/pkg'); | ||
return test(); | ||
} | ||
|
||
return new Response(`path not found: '${path}'`, { status: 404 }); | ||
return new Response( | ||
`path not found: '${path}' (the available paths are: ${Object.keys( | ||
modules, | ||
) | ||
.map((path) => path.replace(/^\.\//, '/').replace(/\.ts$/, '')) | ||
.join(', ')})`, | ||
{ status: 404 }, | ||
); | ||
}, | ||
} satisfies ExportedHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters