-
-
Notifications
You must be signed in to change notification settings - Fork 261
fix: #893 #896
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
fix: #893 #896
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There is a logical contradiction, see my specific description above. @egoist |
I may not understand the inner workings, but what I need to continue to work is: https://tsup.egoist.dev/#es5-support
So I suspect esbuild works with es2020 and then swc turns it back to es5 afterwards. |
When I set target: "es5" in the tsconfig.json I get an error, but when I set target: "es5" in the tsup.config.ts, it works as https://tsup.egoist.dev/#es5-support So I suspect esbuild reads it's target from the tsconfig.json file. |
So I think this Pull Request will break ES5 support (https://tsup.egoist.dev/#es5-support) |
Of course, So, esbuild.build should set the target from --tsconfig path? @ComLock Can you improve this pull request, and commit your update. @ComLock |
Ideally setting target only once, in one place would be nice. But the most important thing for me is the ES5 support (https://tsup.egoist.dev/#es5-support) esbuild isn't able to do that yet, which is why swc is used. |
I can try, but it might be Greek to me :) |
There seems to be no solution that is compatible with both scenarios. |
It seems esbuild looks into the tsconfig.json and throws errors before tsup looks into the tsconfig.custom.json |
So esbuild is probably used by bundle-require (in loadTsupConfig in load.ts) to transpile the tsup.config.ts file. |
So there are at least two "environments".
By default the tsconfig.json file is used by everyone, my code editor program too :) It's possible to use a custom tsconfig.json file with bundle-require |
So, I add an attribute to distinguish them. I finished the job. Tips:
|
@@ -7,9 +7,8 @@ export const es5 = (): Plugin => { | |||
return { | |||
name: 'es5-target', | |||
|
|||
esbuildOptions(options) { | |||
if (options.target === 'es5') { | |||
options.target = 'es2020' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still worries me. I think I will get an error from esbuild about it not supporting es5, rather than esbuild working with es2020 and then swc transpiling it back to es5?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know what you worry about. See here, the usage:
--target es5/tsup.target=es5
andtsconfig.compilerOptions.target: "es5"
can not use at the same time.- can only use
--target es5/tsup.target=es5
to compile the code down to es5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested your branch and it breaks ES5 Support as I expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a pleasure to work with you. @ComLock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither target on cmdline, in tsup.config.json nor tsconfig.custom.json works. All gives es5 not supported by esbuild errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all the best, after git pull
, you should run npm run build
, then run npm run test-only
. @ComLock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to avoid the error I have to set esbuildOptions target: 'es2020' in addition to 'es5' (cmdline or tsup.config or tsconfig.custom)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -7,9 +7,8 @@ export const es5 = (): Plugin => { | |||
return { | |||
name: 'es5-target', | |||
|
|||
esbuildOptions(options) { | |||
if (options.target === 'es5') { | |||
options.target = 'es2020' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested your branch and it breaks ES5 Support as I expected
Everything works without this patch, I closed the issue #893 because it was all confusion. See the closing comment on it. |
Good learning journey though :) |
Sidenote: egoist/bundle-require#38 |
Fixes #893
After the two, the test can pass (But it conflict with the other 2 test cases !!!!!!)
These got failed!!!!!! (line 849). because I deleted the
options.target = 'es2020'
This is a problem. @egoist