outsideurimagination
outsideurimagination
Explore posts from servers
CDCloudflare Developers
Created by outsideurimagination on 4/3/2024 in #pages-help
Dynamically import incompatible packages for dev only
I am currently dynamically importing a package that is incompatible in workers just during development, but the worker still won't compile when I try deploying since it still tries to get those packages. I am wondering how I can avoid that and truly just have that dependency in local development? I guess something is hoisting my dynamic import. Maybe there's a technique to make cloudflare ignore it?
let driver: Driver;
if (NODE_ENV === 'development') {
const {default: fsDriver} = await import("unstorage/drivers/fs-lite");
driver = fsDriver({ base: "./kv" })
}
let driver: Driver;
if (NODE_ENV === 'development') {
const {default: fsDriver} = await import("unstorage/drivers/fs-lite");
driver = fsDriver({ base: "./kv" })
}
1 replies