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