denoland / denoland/deploy_feedback
"True" (non-statically-analyzable) dynamic imports
- Dominant language
- No language data
- Stars
- 79
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
### What problem are you trying to solve?
Separate tracking issue for non-statically-analyzable dynamic imports, as [the fix](https://deno.com/deploy/changelog#statically-analyzable-dynamic-imports) for [#1 Dynamic imports](https://github.com/denoland/deploy_feedback/issues/1) only solves statically-analyzable use cases.
Among other use cases, this would be useful for framework authors wishing to skip build steps entirely; without this feature, at a minimum, a file containing literal paths for routes/components has to be generated.
Example (currently possible in Deno, but not on Deno Deploy):
```ts
import { serve } from 'https://deno.land/std@0.190.0/http/server.ts'
import { resolve } from 'https://deno.land/std@0.190.0/path/mod.ts'
import html from 'https://deno.land/x/htm@0.2.1/mod.ts'
serve(async (req: Request) => {
try {
const { default: route } = await import(
resolve('./routes', `.${new URL(req.url).pathname}.tsx`),
)
return html({ body: route({ req }) })
} catch (e) {
if (e.code === 'ERR_MODULE_NOT_FOUND') {
return new Response(null, { status: 404 })
} else throw e
}
})
```
### Describe the solution you'd like
* True dynamic local path/URL imports to be available in Deploy, supporting js/ts/jsx/tsx/json (via `{ assert: { type: 'json' } }`) file types (is this list exhaustive?)
* Dynamic non-local URL imports — not sure how much demand there is for this, but it'd be nice to have full feature parity with Deno.
* On-the-fly SWC transpilation of dynamically imported ts/tsx/jsx files, falling back to the current eszip-based solution for statically analyzable paths/URLs for better performance.
### Describe alternatives you've considered
A partial solution could involve only supporting js/json files, with transpilation not supported. However, my guess is that wouldn't support most use cases, as most developers using Deno primarily author in TypeScript.
### Documentation, Adoption, Migration Strategy
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.