Skip to content
This repository was archived by the owner on May 29, 2022. It is now read-only.

Commit e1ac6d6

Browse files
committed
feat(all): support awesome-typescript-loader ^2.0
1 parent cab0802 commit e1ac6d6

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
declare module 'awesome-typescript-loader' {
22
export class ForkCheckerPlugin {}
3+
export class TsConfigPathsPlugin { constructor(options?: any) }
34
}

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
"devDependencies": {
3232
"ava": "^0.15.2",
3333
"semantic-release": "^4.3.5",
34-
"ts-node": "^0.9.1",
35-
"tslint": "^3.11.0",
36-
"tslint-config-standard": "^1.2.2",
34+
"ts-node": "^0.9.3",
35+
"tslint": "^3.13.0",
36+
"tslint-config-standard": "^1.3.0",
3737
"typescript": ">=1.9.0-dev.20160619-1.0 || ^2.0.0",
38-
"typings": "^1.3.0"
38+
"typings": "^1.3.1"
3939
},
4040
"dependencies": {
41-
"awesome-typescript-loader": "^1.1.1",
42-
"babel-core": "^6.9.1",
41+
"awesome-typescript-loader": "^2.0.1",
42+
"babel-core": "^6.10.4",
4343
"babel-polyfill": "^6.9.1",
4444
"babel-preset-es2015": "^6.9.0",
4545
"babel-preset-es2015-loose": "^7.0.0",

src/index.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
import {WebpackConfig, get} from '@easy-webpack/core'
22
import * as path from 'path'
3-
import {ForkCheckerPlugin} from 'awesome-typescript-loader'
4-
import 'regenerator-runtime/runtime'
3+
import {ForkCheckerPlugin, TsConfigPathsPlugin} from 'awesome-typescript-loader'
54

65
/**
76
* Typescript loader support for .ts
87
* See: https://github.com/s-panferov/awesome-typescript-loader
98
*/
10-
export = function typescript({options = {}, exclude = null} = {}) {
9+
export = function typescript({options = undefined, exclude = null} = {}) {
1110
return function typescript(this: WebpackConfig): WebpackConfig {
11+
const loader = {
12+
test: /\.tsx?$/,
13+
loader: 'awesome-typescript',
14+
exclude: exclude || this.metadata.root ? [path.join(this.metadata.root, 'node_modules')] : []
15+
} as any
16+
17+
if (options) {
18+
loader.query = options
19+
}
20+
1221
return {
1322
resolve: {
1423
extensions: get(this, 'resolve.extensions', ['', '.js']).concat(['.ts'])
1524
},
1625
module: {
17-
loaders: get(this, 'module.loaders', []).concat([{
18-
test: /\.tsx?$/,
19-
loader: 'awesome-typescript',
20-
exclude: exclude || this.metadata.root ? [path.join(this.metadata.root, 'node_modules')] : [],
21-
query: options
22-
}])
26+
loaders: get(this, 'module.loaders', []).concat([loader])
2327
},
2428
plugins: [
2529
/*
@@ -28,7 +32,8 @@ export = function typescript({options = {}, exclude = null} = {}) {
2832
*
2933
* See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
3034
*/
31-
new ForkCheckerPlugin()
35+
new ForkCheckerPlugin(),
36+
new TsConfigPathsPlugin(options)
3237
].concat(get(this, 'plugins', []))
3338
}
3439
}

0 commit comments

Comments
 (0)