Skip to content

Commit

Permalink
Bump to TypeScript 2.1 for importing helpers
Browse files Browse the repository at this point in the history
Allows ES5 helpers such as _extends to be placed into one external
source file, rather than inlined into every module.

Also removes ts-loader in favour of experimenting with just tsc.

See: microsoft/TypeScript#9097
  • Loading branch information
eddiegroves committed Oct 20, 2016
1 parent 7a1529e commit fb8431a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Project ###
dist/
*.js

### JetBrains IDEs ###
# Ignore entire .idea folder vs gitignore.io/api/jetbrains
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<div id="app"></div>

<script src="./dist/common.js"></script>
<script src="./dist/bundle.js"></script>
</body>
</html>
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "1.0.0",
"description": "Another template for React with TypeScript, Webpack, Mobx and CSS Modules.",
"scripts": {
"gitignore": "curl https://www.gitignore.io/api/visualstudiocode,node > gitignore_merge_me"
"gitignore": "curl https://www.gitignore.io/api/visualstudiocode,node > gitignore_merge_me",
"tsc": "./node_modules/.bin/tsc --pretty"
},
"repository": {
"type": "git",
Expand All @@ -18,14 +19,14 @@
"devDependencies": {
"@types/react": "^0.14.37",
"@types/react-dom": "^0.14.17",
"ts-loader": "^0.8.2",
"typescript": "^2.0.3",
"typescript": "^2.1.0-dev.20161020",
"webpack": "^1.13.2"
},
"dependencies": {
"mobx": "^2.5.1",
"mobx-react": "^3.5.6",
"react": "^15.3.2",
"react-dom": "^15.3.2"
"react-dom": "^15.3.2",
"tslib": "^1.0.0"
}
}
2 changes: 1 addition & 1 deletion src/Clicker.tsx → src/clicker/Clicker.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { UiStore } from "./store";
import { UiStore } from "../store";

export interface ClickerProps { store: UiStore; }

Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { UiStateStore as Store } from './store'
import { Hello } from './Hello';
import { Clicker } from "./Clicker";
import { Clicker } from "./clicker/Clicker";

ReactDOM.render(
<div>
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"noImplicitAny": false,
"sourceMap": false,
"jsx": "react",
"experimentalDecorators": true
"experimentalDecorators": true,
"importHelpers": true
}
}
27 changes: 15 additions & 12 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');

module.exports = {
entry: "./src/index.tsx",
output: {
filename: "./dist/bundle.js",
entry: {
app: [ './src/index.js' ],
common: [ 'react', 'mobx', 'mobx-react', 'tslib' ],
},

resolve: {
extensions: ["", ".ts", ".tsx", ".js"]
output: {
filename: "./dist/app.js",
},

module: {
loaders: [
// All files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'.
{ test: /\.tsx?$/, loader: "ts-loader" }
]
}
plugins: [
// Places common modules into single js file
new CommonsChunkPlugin({
name: "common",
filename: "./dist/common.js",
})
]
};

0 comments on commit fb8431a

Please sign in to comment.