fork-ts-checker-webpack-plugin
Version:
Runs typescript type checker and linter on separate process.
77 lines (76 loc) • 3.42 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertTypeScriptSupport = assertTypeScriptSupport;
const os_1 = __importDefault(require("os"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const semver = __importStar(require("semver"));
function assertTypeScriptSupport(config) {
let typescriptVersion;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
typescriptVersion = require(config.typescriptPath).version;
}
catch (error) {
// silent catch
}
if (!typescriptVersion) {
throw new Error('When you use ForkTsCheckerWebpackPlugin with typescript reporter enabled, you must install `typescript` package.');
}
if (semver.lt(typescriptVersion, '3.6.0')) {
throw new Error([
`ForkTsCheckerWebpackPlugin cannot use the current typescript version of ${typescriptVersion}.`,
'The minimum required version is 3.6.0.',
].join(os_1.default.EOL));
}
if (config.build && semver.lt(typescriptVersion, '3.8.0')) {
throw new Error([
`ForkTsCheckerWebpackPlugin doesn't support build option for the current typescript version of ${typescriptVersion}.`,
'The minimum required version is 3.8.0.',
].join(os_1.default.EOL));
}
if (!fs_extra_1.default.existsSync(config.configFile)) {
throw new Error([
`Cannot find the "${config.configFile}" file.`,
`Please check webpack and ForkTsCheckerWebpackPlugin configuration.`,
`Possible errors:`,
' - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
' - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)',
].join(os_1.default.EOL));
}
}