-
Notifications
You must be signed in to change notification settings - Fork 125
Added ts-loader example #167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "happypack-examples__ts-loader", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"author": "John Reilly <[email protected]> ", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"fork-ts-checker-webpack-plugin": "^0.1.2", | ||
"ts-loader": "^2.0.3", | ||
"typescript": "^2.2.2", | ||
"webpack": "^2.2.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
const x: number = 1; | ||
|
||
console.log('success'); | ||
|
||
export = x; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
import * as x1 from './fileWithoutError'; | ||
|
||
export = x1 + 2; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"compilerOptions": { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
var process = require('process'); | ||
var path = require('path'); | ||
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
|
||
module.exports = { | ||
context: __dirname, // to automatically find tsconfig.json | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].raw.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be:
:) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oooh you might be right! |
||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
exclude: /node_modules/, | ||
loader: 'ts-loader', | ||
options: { transpileOnly: true } | ||
} | ||
] | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.tsx', 'js'] | ||
}, | ||
plugins: [ | ||
new ForkTsCheckerWebpackPlugin({ | ||
tslint: false, // disable tslint support | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is unnecessary now - it's disabled by default |
||
watch: './src', // optional but improves performance (less stat calls) | ||
workers: ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE, // use multi-process mode, leave 2 cpu's free for builder and system | ||
blockEmit: process.env.NODE_ENV === 'production' // for production make it synchronous | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please, remove this - this is no longer useful - it's computed automatically |
||
}) | ||
] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict'; | ||
|
||
var process = require('process'); | ||
var path = require('path'); | ||
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
var HappyPack = require('../../'); | ||
|
||
module.exports = { | ||
context: __dirname, // to automatically find tsconfig.json | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: '[name].js' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
exclude: /node_modules/, | ||
loader: path.resolve(__dirname, '../../loader?id=ts') | ||
} | ||
] | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.tsx', 'js'] | ||
}, | ||
plugins: [ | ||
new HappyPack({ | ||
id: 'ts', | ||
threads: 2, | ||
loaders: [ | ||
{ | ||
path: 'ts-loader', | ||
query: { happyPackMode: true } | ||
} | ||
] | ||
}), | ||
new ForkTsCheckerWebpackPlugin({ | ||
tslint: false, // disable tslint support | ||
watch: './src', // optional but improves performance (less stat calls) | ||
workers: ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE, // use multi-process mode, leave 2 cpu's free for builder and system | ||
blockEmit: process.env.NODE_ENV === 'production' // for production make it synchronous | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above - tslint and blockEmit is no longer needed :) |
||
] | ||
}; |
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.
Please, change it to ^2.0.0 :)