Skip to content

Commit

Permalink
Merge pull request #673 from trodrigues/master
Browse files Browse the repository at this point in the history
Add babel/react/allowjs example
  • Loading branch information
johnnyreilly committed Nov 22, 2017
2 parents f37e438 + 88809f9 commit c95bdfe
Show file tree
Hide file tree
Showing 9 changed files with 5,418 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/react-babel-allowjs/.babelrc
@@ -0,0 +1,11 @@
{
"presets": [
[
"env",
{
"modules": false
}
],
"react"
]
}
19 changes: 19 additions & 0 deletions examples/react-babel-allowjs/README.md
@@ -0,0 +1,19 @@
# TypeScript, Babel, React with `allowJs` for mixed codebases

This setup is mostly intended for people who want to migrate old codebases from JS to TypeScript without having to migrate all of the files at once, and being able to keep a mix of JS and TS files for some time.

Another issue this setup solves is related to the way some modules existent in the npm registry are created or exported. If you let TypeScript take care of the conversion of those modules to a format a browser can understand, some of these modules might end up unusable ([prop-types](https://www.npmjs.com/package/prop-types) is an example). Letting the modules reach webpack untouched (as ES2015 modules) will ensure this problem doesn't occur.

Babel can be removed from this setup unless you're relying on any babel specific plugins.

## Getting started

You'll need [node / npm](https://nodejs.org/) installed. To get up and running just enter:

```
# Download the npm packages you need (including the type definitions from DefinitelyTyped)
npm install
# Compile the code and serve it up at http://localhost:8080
npm start
```
3 changes: 3 additions & 0 deletions examples/react-babel-allowjs/index.html
@@ -0,0 +1,3 @@
<div id="appContainer"></div>

<script src="/bundle.js"></script>

0 comments on commit c95bdfe

Please sign in to comment.