-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some tests to incremental typescript compiler.
- Loading branch information
0xorial
committed
Dec 30, 2018
1 parent
e5774ed
commit 53d690b
Showing
10 changed files
with
304 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
var ForkTsCheckerWebpackPlugin = require('../../lib/index'); | ||
var IncrementalChecker = require('../../lib/IncrementalChecker') | ||
.IncrementalChecker; | ||
|
||
var webpackMajorVersion = require('./webpackVersion')(); | ||
var VueLoaderPlugin = | ||
webpackMajorVersion >= 4 ? require('vue-loader/lib/plugin') : undefined; | ||
|
||
exports.createVueCompiler = function(options) { | ||
var plugin = new ForkTsCheckerWebpackPlugin({ ...options, silent: true }); | ||
|
||
var compiler = webpack({ | ||
...(webpackMajorVersion >= 4 ? { mode: 'development' } : {}), | ||
context: path.resolve(__dirname, './vue'), | ||
entry: './src/index.ts', | ||
output: { | ||
path: path.resolve(__dirname, '../../tmp') | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.js', '.vue', '.json'], | ||
alias: { | ||
'@': path.resolve(__dirname, './vue/src') | ||
} | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.vue$/, | ||
loader: 'vue-loader' | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
loader: 'ts-loader', | ||
options: { | ||
appendTsSuffixTo: [/\.vue$/], | ||
transpileOnly: true, | ||
silent: true | ||
} | ||
}, | ||
{ | ||
test: /\.css$/, | ||
loader: 'css-loader' | ||
} | ||
] | ||
}, | ||
plugins: | ||
webpackMajorVersion >= 4 ? [new VueLoaderPlugin(), plugin] : [plugin] | ||
}); | ||
|
||
var files = { | ||
'example.vue': path.resolve(compiler.context, 'src/example.vue'), | ||
'syntacticError.ts': path.resolve(compiler.context, 'src/syntacticError.ts') | ||
}; | ||
|
||
var checker = new IncrementalChecker( | ||
plugin.tsconfigPath, | ||
{}, | ||
plugin.tslintPath || false, | ||
plugin.tslintAutoFix || false, | ||
[compiler.context], | ||
ForkTsCheckerWebpackPlugin.ONE_CPU, | ||
1, | ||
plugin.checkSyntacticErrors, | ||
plugin.vue | ||
); | ||
|
||
checker.nextIteration(); | ||
|
||
return { plugin, compiler, files, checker }; | ||
}; | ||
|
||
exports.createCompiler = function( | ||
options, | ||
happyPackMode, | ||
entryPoint = './src/index.ts' | ||
) { | ||
var plugin = new ForkTsCheckerWebpackPlugin({ ...options, silent: true }); | ||
|
||
var tsLoaderOptions = happyPackMode | ||
? { happyPackMode: true, silent: true } | ||
: { transpileOnly: true, silent: true }; | ||
|
||
var webpackInstance = webpack({ | ||
...(webpackMajorVersion >= 4 ? { mode: 'development' } : {}), | ||
context: path.resolve(__dirname, './project'), | ||
entry: entryPoint, | ||
output: { | ||
path: path.resolve(__dirname, '../../tmp') | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
loader: 'ts-loader', | ||
options: tsLoaderOptions | ||
} | ||
] | ||
}, | ||
plugins: [plugin] | ||
}); | ||
|
||
return { webpack: webpackInstance, plugin }; | ||
}; |
Oops, something went wrong.