-
Notifications
You must be signed in to change notification settings - Fork 380
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: conditional type exports (T1177805) #3661
fix: conditional type exports (T1177805) #3661
Conversation
Co-authored-by: Timofey Traynenkov <[email protected]>
scripts/merge-dts.js
Outdated
const pkg = JSON.parse(readFileSync(join(packageDirectory, 'package.json'))); | ||
const dtsOutFile = join(packageDirectory, pkg.types); | ||
const pkg = getPackageInfo(packageDirectory); | ||
const dtsOutFile = getDtsOutFile(packageDirectory, pkg.types); |
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.
Looks like an overcomplicating. What's the difference between your function and using join
?
scripts/utils.js
Outdated
|
||
export const getPackageInfo = packageDir => JSON.parse(readFileSync(join(packageDir, 'package.json'))); | ||
|
||
export const getDtsOutFile = (packageDir, typesDir) => join(packageDir, typesDir); |
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.
We've simply duplicated using of join
. Remove this function
@@ -21,8 +21,8 @@ export default (packageDirectory, skipBundle = false) => { | |||
const dtsPath = join(packageDirectory, 'dist', 'dts'); | |||
|
|||
if (!skipBundle) { | |||
const pkg = JSON.parse(readFileSync(join(packageDirectory, 'package.json'))); | |||
const dtsOutFile = join(packageDirectory, pkg.types); | |||
const pkg = getPackageInfo(packageDirectory); |
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 think it is better to split this on steps instead of extracting this logic into util function
Testing with https://github.com/arethetypeswrong/arethetypeswrong.github.io, before/after: