You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When [bundling](https://esbuild.github.io/api/#bundle) is enabled the default output [format](https://esbuild.github.io/api/#format) is set to cjs, which stands for CommonJS (the module format used by node). ES6-style exports using export statements will be converted into getters on the CommonJS exports object.
However, this makes it extremely difficult to stub things that are compiled by esbuild. Is there an option to NOT make the ES6-style exports into getters?
Doing something simple such as the above is impossible given that Object.defineProperty(...) will not override the property, and libraries such as Sinon, Proxyquire, ts-mock-imports, etc will also not work. Basically, testing ES6 code using esbuild is impossible at the moment.
The text was updated successfully, but these errors were encountered:
The testing libraries that you want to use are likely designed for CommonJS code and are not designed for use with ES modules (see sinonjs/sinon#2168 and thlorenz/proxyquire#217 for example).
@evanw Looks like it might be an impossibility even with modern tools: https://www.npmjs.com/package/esmock
I'm using tsx for running typescript, which uses esbuild in the background.
I have read https://esbuild.github.io/api/#platform and am aware that it clearly states:
However, this makes it extremely difficult to stub things that are compiled by
esbuild
. Is there an option to NOT make the ES6-style exports into getters?Doing something simple such as the above is impossible given that
Object.defineProperty(...)
will not override the property, and libraries such as Sinon, Proxyquire, ts-mock-imports, etc will also not work. Basically, testing ES6 code using esbuild is impossible at the moment.The text was updated successfully, but these errors were encountered: