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
The output-1.js only specified tsconfig with target. } catch {, which is an error in es2015 and others. output-2.js specified not only tsconfig, but also the target of the API. It is converted to } catch (t3) {, which works fine.
I tried two things before making this sample.
Directly in input.ts try { ... } catch { ... } directly in input.ts, no problem.
In module/try-catch.ts export const tryCatch = try { ... } catch { ... }
in module/try-catch.ts and imported and used in input.ts, there was no problem.
It probably happens when using libraries.
Before I try any further, I thought that specifying the target directly, rather than just the target in tsconfig, might be what the following quote is about, so I asked the question first.
By default esbuild takes advantage of modern JavaScript features to make your code smaller. For example, a === undefined || a === null ? 1 : a could be minified to a ? If you do not want esbuild to take advantage of modern JavaScript features when minifying, you should use an older language target such as --target=es6. - https://esbuild.github.io/api/#minify-considerations
Thanks.
The text was updated successfully, but these errors were encountered:
This used to work, but was changed on request: #1355. The rationale was that the workflow that esbuild's TypeScript support is replacing is first running tsc to convert TypeScript into JavaScript followed by running a bundler to bundle the JavaScript together. In that workflow, the tsconfig.json file is only relevant for your TypeScript code and not the code of your dependencies inside of node_modules because you only run tsc on your code, not on your dependencies. Arguably esbuild should work the same way, which is why esbuild deliberately ignores your tsconfig.json file for your dependencies inside of node_modules.
Q. Do I have to specify the target directly in the esbuild option, apart from the target loaded in tsconfig?
From the behavior, I may have found a bug.
I can't find the specific cause, right away, so I have a sample to reproduce for illustrative purposes.
https://github.com/tenzyu/20220715-esbuild-not-transforming
This is about the try-catch syntax from es2019.
The output-1.js only specified tsconfig with target.
} catch {
, which is an error in es2015 and others.output-2.js specified not only tsconfig, but also the target of the API. It is converted to
} catch (t3) {
, which works fine.The actual build code is here.
I tried two things before making this sample.
Directly in input.ts
try { ... } catch { ... }
directly in input.ts, no problem.In module/try-catch.ts
export const tryCatch = try { ... } catch { ... }
in module/try-catch.ts and imported and used in input.ts, there was no problem.
It probably happens when using libraries.
Before I try any further, I thought that specifying the target directly, rather than just the target in tsconfig, might be what the following quote is about, so I asked the question first.
Thanks.
The text was updated successfully, but these errors were encountered: