Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test: /\.(j|t)sx?$/,
loader: `ts-loader`,
options: {
configFile: options.tsConfig,
transpileOnly: true,
// https://github.com/TypeStrong/ts-loader/pull/685
experimentalWatchApi: true
}
}
]
},
resolve: {
extensions,
alias: getAliases(options),
plugins: [
new TsConfigPathsPlugin({
configFile: options.tsConfig,
extensions,
mainFields
})
],
mainFields
},
performance: {
hints: false
},
plugins: [
new ForkTsCheckerWebpackPlugin({
tsconfig: options.tsConfig,
workers: options.maxWorkers || ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
useTypescriptIncrementalApi: false // FIXME: disabled incremental api in favour of max workers until it will be supported
})
getResolve() {
return {
/* root: this.resolvePath('src'),
modulesDirectories: ['node_modules'], */
alias: this.getResolveAlias(),
extensions: this.getResolveExtensions(),
modules: [
this.resolvePath('src'),
'node_modules',
],
...(this.isTypescriptSupport() ? {
plugins: [
new TsconfigPathsPlugin({ configFile: this.resolvePath('tsconfig.json') }),
],
} : {}),
};
}
getResolve() {
return {
/* root: this.resolvePath(srcDir),
modulesDirectories: ['node_modules'], */
alias: this.getResolveAlias(),
extensions: this.getResolveExtensions(),
modules: [
this.resolvePath(srcDir),
'node_modules',
],
...(this.isTypescriptSupport() ? {
plugins: [
new TsconfigPathsPlugin({ configFile: this.resolvePath('tsconfig.json') }),
]
} : {}),
};
}
test: /\.(j|t)sx?$/,
loader: `ts-loader`,
options: {
configFile: options.tsConfig,
transpileOnly: true,
// https://github.com/TypeStrong/ts-loader/pull/685
experimentalWatchApi: true
}
}
]
},
resolve: {
extensions,
alias: getAliases(options),
plugins: [
new TsConfigPathsPlugin({
configFile: options.tsConfig,
extensions,
mainFields
})
],
mainFields
},
performance: {
hints: false
},
plugins: [
new ForkTsCheckerWebpackPlugin({
tsconfig: options.tsConfig,
workers: options.maxWorkers || ForkTsCheckerWebpackPlugin.TWO_CPUS_FREE,
useTypescriptIncrementalApi: false
})
getResolve() {
return {
/* root: this.resolvePath(srcDir),
modulesDirectories: ['node_modules'], */
alias: this.getResolveAlias(),
extensions: this.getResolveExtensions(),
modules: [
this.resolvePath(srcDir),
'node_modules',
],
...(this.isTypescriptSupport() ? {
plugins: [
new TsconfigPathsPlugin({ configFile: this.resolvePath('tsconfig.json') }),
]
} : {}),
};
}
}
// Extensions
if (config.resolve.extensions) {
config.resolve.extensions.push(".ts", ".tsx");
} else {
config.resolve.extensions = [".ts", ".tsx"];
}
// Modules
if (config.resolve.modules) {
config.resolve.modules.push(resolveSourceRoot());
config.resolve.modules.push("node_modules");
} else {
config.resolve.modules = [resolveSourceRoot(), "node_modules"];
}
// Resolve
const tsPathPlugin = new TsconfigPathsPlugin({
configFile: resolveTsConfig(),
});
if (config.resolve.plugins) {
config.resolve.plugins.push(tsPathPlugin);
} else {
config.resolve.plugins = [tsPathPlugin];
}
}
return config;
}
return function webpackConfig(config, { defaultLoaders }) {
const mainFields = ['es2015', 'module', 'main'];
const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
config.resolve.plugins = [
new TsConfigPathsPlugin({
configFile: path.resolve(root, 'tsconfig.json'),
extensions,
mainFields
})
];
config.module.rules.push({
test: /\.tsx/,
use: [defaultLoaders.babel]
});
return config;
};
}