is there a way to force esbuild to include files t...
# help
t
is there a way to force esbuild to include files that are only imported dynamically in the bundle? or if not is there any way to make SST use tsc instead of esbuild?
looking into it some more esbuild might support
import
being used dynamically with a string literal, but since I’m also constructing a file path dynamically that doesn’t work in this case
t
Dynamic imports can't be automatically bundled. You can use copyFiles to include additional files into the bundle. This should be the case in tsc also
t
I originally had the app working with tsc but not using sst, and just needed to add
"resolveJsonModule": true,
and
include: ["/path/to/files/**/*.json"]
in tsconfig.json
I’ll look at using copyFiles
t
Ah include is operating sort of like copyFiles in this case
t
that doesn’t seem to be doing anything, but does
copyFiles
support deep copying a directory structure?
I also just realized that the code gets bundled into a single js file and doesn’t have the app’s original directory structure, so the relative paths I’m trying to import would be wrong anyway
t
you can copy a directory yeah
t
I was trying to test with sst start, so this might be why
copyFiles
wasn’t working https://serverless-stack.slack.com/archives/C01JG3B20RY/p1652471935927579?thread_ts=1652457061.502819&cid=C01JG3B20RY
t
yeah I need to think about how to implement this, think we can use symlinks locally to make this feel the same as production. This is an annoying work around but what you can do is look for the files in a different place when
process.env.IS_LOCAL
is true