Closed wmelton closed 2 years ago
Thanks for the issue.
I can't reproduce though. Can you link to a repository containing a minimal reproduction?
Yeah no problem, I will put that together and update with a link.
Will re-open once reproduction is provided
I have a minimal reproduction at https://github.com/TehShrike/tsx_issue_86_repro
I ran into the issue importing TypeScript files from a module.
Thanks for the reproduction @TehShrike
Your issue is the same as https://github.com/esbuild-kit/tsx/issues/38
Bug description
When utilizing the
@tensorflow-models/universal-sentence-encoder
npm package, we experienced a weird bug that went unnoticed until deployment to production. We utilizedesmo
by @antfu for all local dev development on a typescript express api.Using:
import use from '@tensorflow-models/universal-sentence-encoder'
in our script worked perfectly locally. After building (ts->cjs/esm) and deploying to production, we got errors essentially saying many of the module functions wereundefined
.After messing with it, we discovered that updating the import statement to:
import * as use from '@tensorflow-models/universal-sentence-encoder'
fixed the issue both when running uncompiled ts from the cli and post-build js in our production environment.I'm not familiar enough with the build process ts->cjs/esm to understand the details of what could cause this. However, on the face of it, it does seem to me that if an import would fail post-compile, then tsx should fail too.
Reproduction
import use from '@tensorflow-models/universal-sentence-encoder'
tsc -p ./tsconfig.json
model = await use.load()
in the resulting codeimport * as use from '@tensorflow-models/universal-sentence-encoder'
Environment
Can you contribute a fix?