-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError with newer JS features (nullish coalescing, optional chaining) by using TypeScript #3
Comments
@gossi will look into this. i get back you. |
@gossi what version of esbuild-jest you are using? just update to new version of esbuild-jest@0.2.x test('nullish coalescing, optional chaining', () => {
const response = {
data: [
{ age: 30, name: 'Jane' }
]
}
expect(response.data).toBeTruthy()
// @ts-ignore
expect(response?.status).toBeFalsy()
}) |
Two things to it:
Following your example I made these scripts which compile my src for now: const path = require('path');
const { buildSync } = require('esbuild');
const { builtinModules } = require('module');
const fs = require('fs');
const pkg = require(path.resolve('package.json'))
const external = [
...builtinModules,
...Object.keys(pkg.dependencies || {})
]
const build = (outfile, options) => {
buildSync({
entryPoints: ['src/index.ts'],
outfile,
minify: false,
bundle: true,
write: true,
target: 'es2015',
sourcemap: true,
platform: 'node',
external,
...options
});
}
build('dist/theemo.esm-build.js', {
format: 'esm'
}); |
@gossi im glad that it works, but have you updated the version of esbuild-jest? |
I was seeing this on I pushed the branch: theemo-tokens/theemo#3 Keep in mind, there is tsdx and esbuild running in parallel at the moment, I prefer to switch to esbuild (as ofc it is faster). |
@gossi yes theres some issue on esbuild-jest not sure why target = esnext is not working, i updated the target to "es2018" also theres issue on esbuild with exporting default type i created bug to esbuild But i have workaround to make esbuild-jest work.
Let me know if you still encounter the issue |
I just had the time to come back to this. Thanks to your findings and passing on an upstream bug and its fix, this is working brilliantly now. I'm using esbuild ( I can happily close this now :) Thank you so much for your support |
Thanks for
esbuild-jest
,unfortunately I'm not able to fully use it. I'm working on a CLI library running on node written in TS. I'm trying to switch from tsdx to esbuild. So far, I do have the build running, with this command (early/first build command):
Now I wanna try to use jest with esbuild and TS getting this error:
My feeling here is, that esbuild is either not picking up my tsconfig or something is not passed on properly from jest to esbuild to instruct it to do the ts transform.
Any ideas? How can I support this?
The text was updated successfully, but these errors were encountered: