Open Chriscbr opened 2 months ago
For this particular example, I think we can work around it by adding code to Wing SDK for "shimming" in a substitute value for import.meta.url
: https://github.com/evanw/esbuild/issues/3099. Here's where we call esbuild
inside Wing today: https://github.com/winglang/wing/blob/fb852cfe686b2e6ae840c4acc43b414a90cb7640/packages/%40winglang/sdk/src/shared/bundling.ts#L71-L93
Though it might be worthwhile to understand how broad this issue is (what fraction of libraries can't be reliably bundled without esbuild warnings or runtime errors? are there any ways to surface this issue more broadly?)
I tried this:
I wrote a Wing app that uses the
crypto-hash
npm library:Extern code:
This happened:
When I run
wing test
I get this error:Worse, if I compile this to a cloud target like
tf-aws
, it will happily bundle the code even though it will fail at runtime.I expected this:
I expected the example to work, or to have a more helpful error
Is there a workaround?
Avoid using npm libraries that use features which prevent their code from being bundled like
import.meta.url
Anything else?
No response
Wing Version
0.83.8
Node.js Version
20.12.2
Platform(s)
MacOS
Community Notes