1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getOptions = void 0;
|
4 | const validOptions = [
|
5 | "configFile",
|
6 | "extensions",
|
7 | "baseUrl",
|
8 | "silent",
|
9 | "logLevel",
|
10 | "logInfoToStdOut",
|
11 | "context",
|
12 | "mainFields",
|
13 | ];
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function getOptions(rawOptions) {
|
19 | validateOptions(rawOptions);
|
20 | const options = makeOptions(rawOptions);
|
21 | return options;
|
22 | }
|
23 | exports.getOptions = getOptions;
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | function validateOptions(rawOptions) {
|
30 | const loaderOptionKeys = Object.keys(rawOptions);
|
31 | for (let i = 0; i < loaderOptionKeys.length; i++) {
|
32 | const option = loaderOptionKeys[i];
|
33 | const isUnexpectedOption = validOptions.indexOf(option) === -1;
|
34 | if (isUnexpectedOption) {
|
35 | throw new Error(`tsconfig-paths-webpack-plugin was supplied with an unexpected loader option: ${option}
|
36 | Please take a look at the options you are supplying; the following are valid options:
|
37 | ${validOptions.join(" / ")}
|
38 | `);
|
39 | }
|
40 | }
|
41 | }
|
42 | function makeOptions(rawOptions) {
|
43 | const options = Object.assign(Object.assign({}, {
|
44 | configFile: "tsconfig.json",
|
45 | extensions: [".ts", ".tsx"],
|
46 | baseUrl: undefined,
|
47 | silent: false,
|
48 | logLevel: "WARN",
|
49 | logInfoToStdOut: false,
|
50 | context: undefined,
|
51 | colors: true,
|
52 | mainFields: ["main"],
|
53 | }), rawOptions);
|
54 | const options2 = Object.assign(Object.assign({}, options), { logLevel: options.logLevel.toUpperCase() });
|
55 | return options2;
|
56 | }
|