feat: add ForkTsChecker

This commit is contained in:
Igor Randjelovic
2020-11-25 12:41:45 +01:00
committed by Nathan Walker
parent f967606b3a
commit e8888719be
7 changed files with 116 additions and 2 deletions

View File

@ -158,6 +158,14 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
] ]
}, },
plugins: [ plugins: [
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {
@ -383,6 +391,14 @@ exports[`react configuration > android > base config 1`] = `
] ]
}, },
plugins: [ plugins: [
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {
@ -608,6 +624,14 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
] ]
}, },
plugins: [ plugins: [
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {
@ -836,6 +860,14 @@ exports[`react configuration > ios > base config 1`] = `
] ]
}, },
plugins: [ plugins: [
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {

View File

@ -138,7 +138,8 @@ exports[`svelte configuration for android 1`] = `
hotOptions: { hotOptions: {
injectCss: false, injectCss: false,
'native': true 'native': true
} },
onwarn: function () { /* omitted long function */ }
} }
} }
] ]
@ -172,6 +173,14 @@ exports[`svelte configuration for android 1`] = `
] ]
}, },
plugins: [ plugins: [
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {
@ -375,7 +384,8 @@ exports[`svelte configuration for ios 1`] = `
hotOptions: { hotOptions: {
injectCss: false, injectCss: false,
'native': true 'native': true
} },
onwarn: function () { /* omitted long function */ }
} }
} }
] ]
@ -409,6 +419,14 @@ exports[`svelte configuration for ios 1`] = `
] ]
}, },
plugins: [ plugins: [
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {

View File

@ -169,6 +169,20 @@ exports[`vue configuration for android 1`] = `
plugins: [ plugins: [
/* config.plugin('VueLoaderPlugin') */ /* config.plugin('VueLoaderPlugin') */
new VueLoaderPlugin(), new VueLoaderPlugin(),
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096,
extensions: {
vue: {
enabled: true,
compiler: 'nativescript-vue-template-compiler'
}
}
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {
@ -403,6 +417,20 @@ exports[`vue configuration for ios 1`] = `
plugins: [ plugins: [
/* config.plugin('VueLoaderPlugin') */ /* config.plugin('VueLoaderPlugin') */
new VueLoaderPlugin(), new VueLoaderPlugin(),
/* config.plugin('ForkTsCheckerWebpackPlugin') */
new ForkTsCheckerWebpackPlugin(
{
typescript: {
memoryLimit: 4096,
extensions: {
vue: {
enabled: true,
compiler: 'nativescript-vue-template-compiler'
}
}
}
}
),
/* config.plugin('CleanWebpackPlugin') */ /* config.plugin('CleanWebpackPlugin') */
new CleanWebpackPlugin( new CleanWebpackPlugin(
{ {

View File

@ -11,6 +11,17 @@ jest.mock(
{ virtual: true } { virtual: true }
); );
jest.mock('cosmiconfig', () => ({
cosmiconfigSync(moduleName) {
return {
search() {
// no-op in tests
return null;
},
};
},
}));
jest.mock('path', () => ({ jest.mock('path', () => ({
...jest.requireActual('path'), ...jest.requireActual('path'),
// we are mocking resolve to just simply join the paths for tests // we are mocking resolve to just simply join the paths for tests

View File

@ -26,6 +26,7 @@
"copy-webpack-plugin": "^6.3.2", "copy-webpack-plugin": "^6.3.2",
"css": "^3.0.0", "css": "^3.0.0",
"css-loader": "^5.0.1", "css-loader": "^5.0.1",
"fork-ts-checker-webpack-plugin": "^6.0.3",
"loader-utils": "^2.0.0", "loader-utils": "^2.0.0",
"react-refresh": "^0.9.0", "react-refresh": "^0.9.0",
"sass": "^1.29.0", "sass": "^1.29.0",

View File

@ -2,6 +2,7 @@ import { DefinePlugin, HotModuleReplacementPlugin } from 'webpack';
import Config from 'webpack-chain'; import Config from 'webpack-chain';
import path from 'path'; import path from 'path';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
import { CleanWebpackPlugin } from 'clean-webpack-plugin'; import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import CopyWebpackPlugin from 'copy-webpack-plugin'; import CopyWebpackPlugin from 'copy-webpack-plugin';
@ -134,6 +135,15 @@ export default function (config: Config, env: IWebpackEnv): Config {
}, },
}); });
// Use Fork TS Checker to do type checking in a separate non-blocking process
config.plugin('ForkTsCheckerWebpackPlugin').use(ForkTsCheckerWebpackPlugin, [
{
typescript: {
memoryLimit: 4096,
},
},
]);
// set up js // set up js
// todo: do we need babel-loader? It's useful to support it // todo: do we need babel-loader? It's useful to support it
config.module config.module

View File

@ -39,6 +39,20 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
}); });
}); });
config.plugin('ForkTsCheckerWebpackPlugin').tap((args) => {
args[0] = merge(args[0], {
typescript: {
extensions: {
vue: {
enabled: true,
compiler: 'nativescript-vue-template-compiler',
},
},
},
});
return args;
});
// add VueLoaderPlugin as the first plugin // add VueLoaderPlugin as the first plugin
config config
.plugin('VueLoaderPlugin') .plugin('VueLoaderPlugin')