1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5 | }) : (function(o, m, k, k2) {
|
6 | if (k2 === undefined) k2 = k;
|
7 | o[k2] = m[k];
|
8 | }));
|
9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11 | }) : function(o, v) {
|
12 | o["default"] = v;
|
13 | });
|
14 | var __importStar = (this && this.__importStar) || function (mod) {
|
15 | if (mod && mod.__esModule) return mod;
|
16 | var result = {};
|
17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18 | __setModuleDefault(result, mod);
|
19 | return result;
|
20 | };
|
21 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
22 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
23 | };
|
24 | Object.defineProperty(exports, "__esModule", { value: true });
|
25 | exports.assertTypeScriptSupport = void 0;
|
26 | const os_1 = __importDefault(require("os"));
|
27 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
28 | const semver = __importStar(require("semver"));
|
29 | const type_script_vue_extension_support_1 = require("./extension/vue/type-script-vue-extension-support");
|
30 | function assertTypeScriptSupport(config) {
|
31 | let typescriptVersion;
|
32 | try {
|
33 |
|
34 | typescriptVersion = require(config.typescriptPath).version;
|
35 | }
|
36 | catch (error) {
|
37 |
|
38 | }
|
39 | if (!typescriptVersion) {
|
40 | throw new Error('When you use ForkTsCheckerWebpackPlugin with typescript reporter enabled, you must install `typescript` package.');
|
41 | }
|
42 | if (semver.lt(typescriptVersion, '3.6.0')) {
|
43 | throw new Error([
|
44 | `ForkTsCheckerWebpackPlugin cannot use the current typescript version of ${typescriptVersion}.`,
|
45 | 'The minimum required version is 3.6.0.',
|
46 | ].join(os_1.default.EOL));
|
47 | }
|
48 | if (config.build && semver.lt(typescriptVersion, '3.8.0')) {
|
49 | throw new Error([
|
50 | `ForkTsCheckerWebpackPlugin doesn't support build option for the current typescript version of ${typescriptVersion}.`,
|
51 | 'The minimum required version is 3.8.0.',
|
52 | ].join(os_1.default.EOL));
|
53 | }
|
54 | if (!fs_extra_1.default.existsSync(config.configFile)) {
|
55 | throw new Error([
|
56 | `Cannot find the "${config.configFile}" file.`,
|
57 | `Please check webpack and ForkTsCheckerWebpackPlugin configuration.`,
|
58 | `Possible errors:`,
|
59 | ' - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)',
|
60 | ' - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)',
|
61 | ].join(os_1.default.EOL));
|
62 | }
|
63 | if (config.extensions.vue.enabled) {
|
64 | (0, type_script_vue_extension_support_1.assertTypeScriptVueExtensionSupport)(config.extensions.vue);
|
65 | }
|
66 | }
|
67 | exports.assertTypeScriptSupport = assertTypeScriptSupport;
|