Skip to content

Instantly share code, notes, and snippets.

@esamattis
Last active September 12, 2018 20:55
Show Gist options
  • Save esamattis/bb8ae386f9dbb2a4ae2159e1f265fd56 to your computer and use it in GitHub Desktop.
Save esamattis/bb8ae386f9dbb2a4ae2159e1f265fd56 to your computer and use it in GitHub Desktop.
Typescript type stripping with Babel 7 using few extra Babel plugins
{
"presets": [
"typescript",
"react",
[
"env",
{
"targets": {
"uglify": true
}
}
]
],
"plugins": ["transform-object-rest-spread", "glamorous-displayname"]
}
{
"name": "tsbabel",
"version": "0.1.0",
"dependencies": {
"@types/node": "^8.0.28",
"@types/react": "^16.0.5",
"@types/react-dom": "^15.5.4",
"@types/react-redux": "^5.0.7",
"babel-core": "^7.0.0-beta.0",
"babel-loader": "^7.0.0-beta.0",
"babel-plugin-glamorous-displayname": "^2.1.0",
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.0",
"babel-preset-env": "^2.0.0-alpha.20",
"babel-preset-react": "^7.0.0-beta.0",
"babel-preset-typescript": "^7.0.0-alpha.19",
"glamor": "^2.20.40",
"glamorous": "^4.8.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"typescript": "^2.5.2",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.7.1"
}
}
{
"compilerOptions": {
"module": "es6",
"target": "esnext",
"lib": ["es6", "dom"],
"sourceMap": true,
"jsx": "react",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noUnusedLocals": false
}
}
module.exports = {
entry: "./src/index.tsx",
output: {
filename: "bundle.js",
path: __dirname + "/public",
},
resolve: {
// Add '.ts' and '.tsx' as resolvable extensions.
extensions: [".ts", ".tsx", ".js", ".json"],
},
module: {
rules: [{test: /\.(ts|tsx|js)$/, loader: "babel-loader"}],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment