Repository URL to install this package:
|
Version:
3.8.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
/**
* @todo https://github.com/TypeStrong/ts-loader/blob/master/examples/happypack/webpack.config.js
*/
const happypack_1 = tslib_1.__importDefault(require("happypack"));
const typescriptBabel_1 = tslib_1.__importDefault(require("./typescriptBabel"));
const TYPESCRIPT_ENV = true;
/**
* @@pnp @note - does not work with pnp yet but can turn off
* @todo no need for happypack on build prod?
*/
// process.env.PNP === undefined
const IS_HAPPYPACK_ENABLED = false;
let happypackPlugin;
function getHappy() {
if (happypackPlugin) {
return happypackPlugin;
}
console.log('getHappy');
const happypackConfig = {
id: 'ts',
threads: 2,
loaders: [
{
path: 'ts-loader',
query: {
happyPackMode: true,
},
},
],
};
const plugin = new happypack_1.default(happypackConfig);
happypackPlugin = plugin;
return happypackPlugin;
}
function typescriptPlugin(config, options) {
if (TYPESCRIPT_ENV && !IS_HAPPYPACK_ENABLED) {
// const pathsToTranspile = options.bundleConfig.srcPaths.map(resolveToRoot)
const typescriptLoader = {
test: /\.(tsx|ts|jsx|js)$/,
exclude: /(node_modules)/,
// exclude: /node_modules(?!\/\@skava\/ui)/,
// include: pathsToTranspile,
use: [
{
/**
* @see https://github.com/Microsoft/TypeScriptSamples/blob/master/react-flux-babel-karma/webpack.config.js
* @see https://github.com/amireh/happypack/issues/32
*/
loader: require.resolve('babel-loader'),
options: Object.assign({}, typescriptBabel_1.default(config, options), {
// false if debugging
// cacheDirectory: false,
cacheDirectory: true }),
},
{
/**
* @see https://webpack.js.org/guides/build-performance/#typescript-loader
* @see https://github.com/TypeStrong/ts-loader#ignorediagnostics-number-default
*/
loader: require.resolve('ts-loader'),
options: {
// disable type checker - we will use it in fork plugin
transpileOnly: true,
experimentalWatchApi: true,
},
},
],
};
config.module.rules.unshift(typescriptLoader);
}
if (process.env.SHOULD_BUILD_CHECK_STRICT_TYPESCRIPT) {
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const checker = new ForkTsCheckerWebpackPlugin();
config.plugins.push(checker);
}
}
exports.default = typescriptPlugin;
//# sourceMappingURL=typescript.js.map