-
Notifications
You must be signed in to change notification settings - Fork 420
Build with tsc instead of tsup #842
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
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Thanks a whole lot. This looks mighty promising. Too tired today to check
it out. Hopefully will manage tomorrow.
…On Sun, Mar 16, 2025, 19:32 codesandbox-ci[bot] ***@***.***> wrote:
This pull request is automatically built and testable in CodeSandbox
<https://codesandbox.io>.
To see build info of the built libraries, click here
<https://ci.codesandbox.io/status/sql-formatter-org/sql-formatter/pr/842/builds/597741>
or the icon next to each commit SHA.
—
Reply to this email directly, view it on GitHub
<#842 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA43OIPIOMNV6SKEWPUYDT2UWYR5AVCNFSM6AAAAABZD3SD32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRXGU2TKMJZGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
[image: codesandbox-ci[bot]]*codesandbox-ci[bot]* left a comment
(sql-formatter-org/sql-formatter#842)
<#842 (comment)>
This pull request is automatically built and testable in CodeSandbox
<https://codesandbox.io>.
To see build info of the built libraries, click here
<https://ci.codesandbox.io/status/sql-formatter-org/sql-formatter/pr/842/builds/597741>
or the icon next to each commit SHA.
—
Reply to this email directly, view it on GitHub
<#842 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA43OIPIOMNV6SKEWPUYDT2UWYR5AVCNFSM6AAAAABZD3SD32VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMRXGU2TKMJZGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target": "
#842 (comment)",
"url": "
#842 (comment)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url": "
https://github.com" } } ]
|
@@ -63,9 +63,10 @@ | |||
"prepare": "yarn clean && yarn grammar && yarn fix && yarn check && yarn build", | |||
"pre-commit": "npm-run-all --parallel ts:changes lint:changes", | |||
"grammar": "nearleyc src/parser/grammar.ne -o src/parser/grammar.ts", | |||
"build:tsup": "tsup src/index.ts --format cjs,esm --sourcemap --dts", | |||
"build:cjs": "tsc -p tsconfig.cjs.json && echo \"{\"type\": \"commonjs\"}\" > dist/cjs/package.json", |
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.
Hmm... I think this doesn't work quite as intended. I generates a file containing:
{type: commonjs}
which isn't valid JSON. I tweaked it a bit: 14e5daf
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.
Great catch! Sorry about that.
So I merged this in and released as |
As reported in #836 (comment), my previous changes from #670 broke the ability for this package to be tree-shaken.
This PR takes the other approach I had proposed in #604: it runs
tsc
twice, once to produce a CJS build and once to produce an ESM one. It writes apackage.json
file containing{"type": "commonjs"}
todist/cjs/package.json
so that the files in that directory are treated as CJS.Since #670 introduced an
exports
field, the internal changes to paths shouldn't be visible to consumers, so this should be safe to release as a patch or minor version. That said, I wouldn't blame you if you wanted to release this as a major version to play it safe.