DenoDDeno
Powered by
PhatsoP
Denoโ€ข4y agoโ€ข
2 replies
Phatso

Import from variable path?

Howdy - I'm trying to make my Cloudflare Workers app self-hostable in a Docker Container.

To do this, I'm going to run it with Deno when self-hosting.
Ideally I would like to change none of my actual application code and defer any environment-specific setup to different files.

i.e.:
src/
  - index.js
  - selfhost.js
  - cloudflare.js
src/
  - index.js
  - selfhost.js
  - cloudflare.js


And then:
// index.js
import { app, serve } from (isSelfHost ? "./selfhost.js" : "./cloudflare.js")
// index.js
import { app, serve } from (isSelfHost ? "./selfhost.js" : "./cloudflare.js")


I know this doesn't work, so my question is how do I achieve something like this?

Ultimately the problem is I can't be requiring Deno packages in cloudflare workers or vice versa.
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

setting module scope variable based on module import path
shultz๐Ÿ‡ฎ๐Ÿ‡ฑSshultz๐Ÿ‡ฎ๐Ÿ‡ฑ / help
3y ago
VIM - ALE - import-prefix-missing: Relative import path
darkelfDdarkelf / help
16mo ago
Import path autocomplete doesn't work
babakfpBbabakfp / help
2y ago
restrict path applied for import maps
scarfSscarf / help
3y ago