-
Notifications
You must be signed in to change notification settings - Fork 50
fix: Throw an error on transpile if the package.json main or exports is not set properly #1297
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
base: main
Are you sure you want to change the base?
Conversation
…le test" This reverts commit fdee8b6.
|
i think the check is failing because of it's a Windows-only test running on macOS |
rushabhcodes
left a comment
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.
The test does not run on you device, i think there is a problem in the test or you introduced one
yaa fixed it ! Did a obvious mistake ;) |
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.
You should not be throwing an error for this, it should be a warning how it was before.
The issue lacked context when that was created
ok then ! should i close this commit ? |
…in entry point from package.json
/fix #1167
Overview
Changed the transpile command to throw an error instead of warning when
package.jsonmainorexportsfields are not properly configured to point to thedist/directory.Behavior Changes
1. Main Field Points Outside dist/
❌ BEFORE
$ cat package.json { "name": "my-package", "main": "index.tsx" } $ tsci transpile index.tsxOutput:
Exit Code:
0(SUCCESS - continues despite misconfiguration)✅ AFTER
$ cat package.json { "name": "my-package", "main": "index.tsx" } $ tsci transpile index.tsxOutput:
Exit Code:
1(ERROR - stops immediately)2. Missing Both main and exports Fields
❌ BEFORE
$ cat package.json { "name": "my-package", "version": "1.0.0" } $ tsci transpile index.tsxOutput:
Exit Code:
0(SUCCESS - no validation for missing fields)✅ AFTER
$ cat package.json { "name": "my-package", "version": "1.0.0" } $ tsci transpile index.tsxOutput:
Exit Code:
1(ERROR - stops immediately)3. Invalid exports Field (NEW - Only In AFTER)
❌ BEFORE
$ cat package.json { "exports": { ".": "./lib/index.js", "./utils": "./utils.js" } } $ tsci transpile index.tsxOutput:
Exit Code:
0(SUCCESS - no exports validation)✅ AFTER
$ cat package.json { "exports": { ".": "./lib/index.js", "./utils": "./utils.js" } } $ tsci transpile index.tsxOutput:
Exit Code:
1(ERROR - validates all export paths)Error Messages Summary
Implementation Details
Files Modified
cli/utils/validate-main-in-dist.tsconsole.warn()tothrow new Error()mainandexportsfieldsvalidateExports()helper functiontests/cli/transpile/transpile.test.tstests/cli/build/build-transpile.test.tsError Handling
Both
cli/transpile/register.tsandcli/build/register.tsalready have try-catch blocks that catch and properly handle the thrown errors:Test Results
Transpile Tests
Build Tests
mainandexportsfields