UNPKG

3.83 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 var desc = Object.getOwnPropertyDescriptor(m, k);
5 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6 desc = { enumerable: true, get: function() { return m[k]; } };
7 }
8 Object.defineProperty(o, k2, desc);
9}) : (function(o, m, k, k2) {
10 if (k2 === undefined) k2 = k;
11 o[k2] = m[k];
12}));
13var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14 Object.defineProperty(o, "default", { enumerable: true, value: v });
15}) : function(o, v) {
16 o["default"] = v;
17});
18var __importStar = (this && this.__importStar) || function (mod) {
19 if (mod && mod.__esModule) return mod;
20 var result = {};
21 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22 __setModuleDefault(result, mod);
23 return result;
24};
25var __importDefault = (this && this.__importDefault) || function (mod) {
26 return (mod && mod.__esModule) ? mod : { "default": mod };
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29exports.defOptions = void 0;
30/* eslint-disable class-methods-use-this */
31const typescript_1 = __importStar(require("typescript"));
32const path_1 = __importDefault(require("path"));
33const os_1 = __importDefault(require("os"));
34const versionContainer_1 = require("./versionContainer");
35function defineTarget() {
36 if (versionContainer_1.nodeJsVer.major >= 10) {
37 return typescript_1.default.ScriptTarget.ES2017;
38 }
39 if (versionContainer_1.nodeJsVer.major >= 6) {
40 return typescript_1.default.ScriptTarget.ES5;
41 }
42 return typescript_1.default.ScriptTarget.ES3;
43}
44const outDir = path_1.default.join(os_1.default.tmpdir(), "webpack-mock-server", new Date().getTime().toString());
45class MockServerOptions {
46 constructor() {
47 /** Enable/disable console.log */
48 this.verbose = false;
49 /** Port for webpack-mock-server */
50 this.port = 8079;
51 /** Enable/disable console.log for requests */
52 this.logRequests = false;
53 /** Enable/disable console.log for reponses */
54 this.logResponses = false;
55 /** Typescript compiler options that override options from 'tsconfig.json' */
56 this.compilerOptions = {
57 strictNullChecks: false,
58 noImplicitAny: false,
59 noUnusedLocals: false,
60 noUnusedParameters: false,
61 skipLibCheck: true,
62 resolveJsonModule: true,
63 // todo wait for transpileOnly option: https://github.com/microsoft/TypeScript/issues/29651
64 };
65 /** Typescript config file (used for compilation [entry] files) */
66 this.tsConfigFileName = "tsconfig.json";
67 /**
68 * Entry points for typescript-compiler
69 * If pointed an 'empty array' or 'undefined' entry will be defined
70 * from [tsConfigFileName]: 'files','include' and 'exclude' sections
71 */
72 this.entry = ["webpack.mock.ts"];
73 }
74 /** Must-have Typescript compiler options (impossible to override) */
75 get strictCompilerOptions() {
76 return {
77 outDir,
78 rootDir: process.cwd(),
79 noEmit: false,
80 noEmitHelpers: false,
81 esModuleInterop: true,
82 module: typescript_1.default.ModuleKind.CommonJS,
83 declaration: false,
84 moduelResolution: typescript_1.ModuleResolutionKind.NodeJs,
85 target: defineTarget(),
86 };
87 }
88}
89exports.default = MockServerOptions;
90exports.defOptions = new MockServerOptions();