Skip to content
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

Implement TypeScript support #131

Merged
merged 7 commits into from
Apr 10, 2020

Conversation

KubaJastrz
Copy link
Contributor

@KubaJastrz KubaJastrz commented Apr 9, 2020

Closes #130

What:

Allow building TypeScript files with kcd-scripts build --bundle command.

Also, I've changed the default for babel's runtimeHelpers to hasAnyDep('@babel/runtime') and I'm not entirely sure why this is needed.

Why:

TypeScript is awesome and we want to use it in @testing-library source code.

More in #130 and testing-library/dom-testing-library#494

How:

  1. Detect if project is using TypeScript by checking for typescript dependency and tsconfig.json file in root directory.
  2. If TS was detected, add @babel/preset-typescript to default babel configuration.
  3. If TS was detected, add .ts and .tsx file extensions to default rollup configuration.
  4. If TS was detected, support src/index.ts and src/index.tsx entry files.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

I'm not exactly sure what and how to test this feature but if you have any ideas, I can help. I did some smoke tests on dom-testing-library repo and it seemed to work out-of-the-box.

Also, I think that kcd-scripts lint will fail on TypeScript files when using the default configuration. https://github.com/kentcdodds/eslint-config-kentcdodds should also be updated.

@codecov
Copy link

codecov bot commented Apr 9, 2020

Codecov Report

Merging #131 into master will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   87.50%   87.65%   +0.15%     
==========================================
  Files          18       18              
  Lines         328      332       +4     
  Branches       76       78       +2     
==========================================
+ Hits          287      291       +4     
  Misses         34       34              
  Partials        7        7              
Impacted Files Coverage Δ
src/config/babelrc.js 76.92% <100.00%> (ø)
src/config/rollup.config.js 72.22% <100.00%> (+0.79%) ⬆️
src/utils.js 88.15% <100.00%> (+0.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f75a86...8160121. Read the comment docs.

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Just one small thing. Thank you!

}),
commonjs({include: 'node_modules/**'}),
json(),
rollupBabel({
presets: babelPresets,
babelrc: !useBuiltinConfig,
runtimeHelpers: useBuiltinConfig,
runtimeHelpers: hasAnyDep('@babel/runtime'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use hasDep rather than hasAnyDep (looks like we'll need to create that). If they don't have it in their regular deps then it may not work for consumers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to hasDep

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super. Thank you :)

@kentcdodds kentcdodds merged commit a944898 into kentcdodds:master Apr 10, 2020
@kentcdodds
Copy link
Owner

🎉 This PR is included in version 5.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@KubaJastrz KubaJastrz deleted the feat/typescript branch April 10, 2020 15:53
@MichaelDeBoey
Copy link
Contributor

Is there a reason we don't support typescript with kcd-scripts build? 🤔

@kentcdodds
Copy link
Owner

Nope. I'd be happy to have support for typescript throughout the project 👍

@kentcdodds
Copy link
Owner

@all-contributors please add @KubaJastrz for code

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @KubaJastrz! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript support
3 participants