@modern-js/server-utils 2.0.0-beta.3 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,105 +1,148 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var stdin_exports = {};
25
+ __export(stdin_exports, {
26
+ compileByTs: () => compileByTs
5
27
  });
6
- exports.compileByTs = void 0;
7
- var _path = _interopRequireDefault(require("path"));
8
- var _utils = require("@modern-js/utils");
9
- var _typescript = _interopRequireDefault(require("typescript"));
10
- var _typescriptLoader = require("./typescript-loader");
11
- var _tsconfigPathsPlugin = require("./tsconfig-paths-plugin");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- const readTsConfigByFile = tsConfigFile => {
17
- const parsedCmd = _typescript.default.getParsedCommandLineOfConfigFile(tsConfigFile, undefined, _typescript.default.sys);
18
- const {
19
- options,
20
- fileNames,
21
- projectReferences
22
- } = parsedCmd;
23
- return {
24
- options,
25
- fileNames,
26
- projectReferences
27
- };
28
+ module.exports = __toCommonJS(stdin_exports);
29
+ var import_path = __toESM(require("path"));
30
+ var import_utils = require("@modern-js/utils");
31
+ var import_typescript = __toESM(require("typescript"));
32
+ var import_typescript_loader = require("./typescript-loader");
33
+ var import_tsconfig_paths_plugin = require("./tsconfig-paths-plugin");
34
+ var __defProp2 = Object.defineProperty;
35
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
36
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
37
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
38
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
39
+ var __spreadValues = (a, b) => {
40
+ for (var prop in b || (b = {}))
41
+ if (__hasOwnProp2.call(b, prop))
42
+ __defNormalProp(a, prop, b[prop]);
43
+ if (__getOwnPropSymbols)
44
+ for (var prop of __getOwnPropSymbols(b)) {
45
+ if (__propIsEnum.call(b, prop))
46
+ __defNormalProp(a, prop, b[prop]);
47
+ }
48
+ return a;
49
+ };
50
+ var __async = (__this, __arguments, generator) => {
51
+ return new Promise((resolve, reject) => {
52
+ var fulfilled = (value) => {
53
+ try {
54
+ step(generator.next(value));
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ };
59
+ var rejected = (value) => {
60
+ try {
61
+ step(generator.throw(value));
62
+ } catch (e) {
63
+ reject(e);
64
+ }
65
+ };
66
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
67
+ step((generator = generator.apply(__this, __arguments)).next());
68
+ });
28
69
  };
29
- const copyFiles = async (from, to, tsconfigPath) => {
30
- if (await _utils.fs.pathExists(from)) {
31
- const basename = _path.default.basename(from);
32
- const targetDir = _path.default.join(to, basename);
33
- await _utils.fs.copy(from, targetDir, {
34
- filter: src => !['.ts'].includes(_path.default.extname(src)) && src !== tsconfigPath
70
+ const readTsConfigByFile = (tsConfigFile) => {
71
+ const parsedCmd = import_typescript.default.getParsedCommandLineOfConfigFile(
72
+ tsConfigFile,
73
+ void 0,
74
+ import_typescript.default.sys
75
+ );
76
+ const { options, fileNames, projectReferences } = parsedCmd;
77
+ return { options, fileNames, projectReferences };
78
+ };
79
+ const copyFiles = (from, to, tsconfigPath) => __async(void 0, null, function* () {
80
+ if (yield import_utils.fs.pathExists(from)) {
81
+ const basename = import_path.default.basename(from);
82
+ const targetDir = import_path.default.join(to, basename);
83
+ yield import_utils.fs.copy(from, targetDir, {
84
+ filter: (src) => ![".ts"].includes(import_path.default.extname(src)) && src !== tsconfigPath
35
85
  });
36
86
  }
37
- };
38
- const compileByTs = async (appDirectory, config, compileOptions) => {
39
- _utils.logger.info(`Running ts compile...`);
40
- const {
41
- sourceDirs,
42
- distDir,
43
- tsconfigPath
44
- } = compileOptions;
87
+ });
88
+ const compileByTs = (appDirectory, config, compileOptions) => __async(void 0, null, function* () {
89
+ import_utils.logger.info(`Running ts compile...`);
90
+ const { sourceDirs, distDir, tsconfigPath } = compileOptions;
45
91
  if (!tsconfigPath) {
46
92
  return;
47
93
  }
48
- const ts = new _typescriptLoader.TypescriptLoader({
94
+ const ts2 = new import_typescript_loader.TypescriptLoader({
49
95
  appDirectory
50
96
  }).load();
51
- const createProgram = ts.createIncrementalProgram || ts.createProgram;
52
- const formatHost = getFormatHost(ts);
53
- const {
54
- alias
55
- } = config;
56
- const aliasOption = (0, _utils.getAliasConfig)(alias, {
97
+ const createProgram = ts2.createIncrementalProgram || ts2.createProgram;
98
+ const formatHost = getFormatHost(ts2);
99
+ const { alias } = config;
100
+ const aliasOption = (0, import_utils.getAliasConfig)(alias, {
57
101
  appDirectory,
58
102
  tsconfigPath
59
103
  });
60
- const {
61
- paths = {},
62
- absoluteBaseUrl = './'
63
- } = aliasOption;
64
- const {
65
- options,
66
- fileNames,
67
- projectReferences
68
- } = readTsConfigByFile(tsconfigPath);
69
- const sourcePosixPaths = sourceDirs.map(sourceDir => sourceDir.split(_path.default.sep).join(_path.default.posix.sep));
70
- const rootNames = fileNames.filter(fileName => {
71
- return fileName.endsWith('.d.ts') || sourcePosixPaths.some(sourceDir => {
104
+ const { paths = {}, absoluteBaseUrl = "./" } = aliasOption;
105
+ const { options, fileNames, projectReferences } = readTsConfigByFile(tsconfigPath);
106
+ const sourcePosixPaths = sourceDirs.map(
107
+ (sourceDir) => sourceDir.split(import_path.default.sep).join(import_path.default.posix.sep)
108
+ );
109
+ const rootNames = fileNames.filter((fileName) => {
110
+ return fileName.endsWith(".d.ts") || sourcePosixPaths.some((sourceDir) => {
72
111
  return fileName.includes(sourceDir);
73
112
  });
74
113
  });
75
- const program = createProgram.call(ts, {
114
+ const program = createProgram.call(ts2, {
76
115
  rootNames,
77
116
  projectReferences,
78
- options: _objectSpread({
117
+ options: __spreadValues({
79
118
  rootDir: appDirectory,
80
119
  outDir: distDir
81
120
  }, options)
82
121
  });
83
- const tsconfigPathsPlugin = (0, _tsconfigPathsPlugin.tsconfigPathsBeforeHookFactory)(ts, absoluteBaseUrl, paths);
84
- const emitResult = program.emit(undefined, undefined, undefined, undefined, {
122
+ const tsconfigPathsPlugin = (0, import_tsconfig_paths_plugin.tsconfigPathsBeforeHookFactory)(
123
+ ts2,
124
+ absoluteBaseUrl,
125
+ paths
126
+ );
127
+ const emitResult = program.emit(void 0, void 0, void 0, void 0, {
85
128
  before: [tsconfigPathsPlugin]
86
129
  });
87
- const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
130
+ const allDiagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
88
131
  if (allDiagnostics.length > 0) {
89
- _utils.logger.error(ts.formatDiagnosticsWithColorAndContext(allDiagnostics, formatHost));
90
- // eslint-disable-next-line no-process-exit
132
+ import_utils.logger.error(
133
+ ts2.formatDiagnosticsWithColorAndContext(allDiagnostics, formatHost)
134
+ );
91
135
  process.exit(1);
92
136
  }
93
137
  for (const source of sourceDirs) {
94
- await copyFiles(source, distDir, tsconfigPath);
138
+ yield copyFiles(source, distDir, tsconfigPath);
95
139
  }
96
- _utils.logger.info(`Ts compile succeed`);
97
- };
98
- exports.compileByTs = compileByTs;
99
- const getFormatHost = ts => {
140
+ import_utils.logger.info(`Ts compile succeed`);
141
+ });
142
+ const getFormatHost = (ts2) => {
100
143
  return {
101
- getCanonicalFileName: path => path,
102
- getCurrentDirectory: ts.sys.getCurrentDirectory,
103
- getNewLine: () => ts.sys.newLine
144
+ getCanonicalFileName: (path2) => path2,
145
+ getCurrentDirectory: ts2.sys.getCurrentDirectory,
146
+ getNewLine: () => ts2.sys.newLine
104
147
  };
105
- };
148
+ };
@@ -1,22 +1,41 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var stdin_exports = {};
25
+ __export(stdin_exports, {
26
+ tsconfigPathsBeforeHookFactory: () => tsconfigPathsBeforeHookFactory
5
27
  });
6
- exports.tsconfigPathsBeforeHookFactory = tsconfigPathsBeforeHookFactory;
7
- var os = _interopRequireWildcard(require("os"));
8
- var _path = _interopRequireWildcard(require("path"));
9
- var ts = _interopRequireWildcard(require("typescript"));
10
- var _tsconfigPaths = require("@modern-js/utils/tsconfig-paths");
11
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- const isRegExpKey = str => {
14
- return str.startsWith('^') || str.endsWith('$');
28
+ module.exports = __toCommonJS(stdin_exports);
29
+ var os = __toESM(require("os"));
30
+ var import_path = __toESM(require("path"));
31
+ var ts = __toESM(require("typescript"));
32
+ var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
33
+ const isRegExpKey = (str) => {
34
+ return str.startsWith("^") || str.endsWith("$");
15
35
  };
16
36
  const resolveAliasPath = (baseUrl, filePath) => {
17
- // exclude absolute path and alias
18
- if (filePath.startsWith('.') || filePath.startsWith('..')) {
19
- return _path.default.resolve(baseUrl, filePath);
37
+ if (filePath.startsWith(".") || filePath.startsWith("..")) {
38
+ return import_path.default.resolve(baseUrl, filePath);
20
39
  }
21
40
  return filePath;
22
41
  };
@@ -32,10 +51,8 @@ const createAliasMatcher = (baseUrl, alias) => {
32
51
  }
33
52
  return o;
34
53
  }, []);
35
- const cacheMap = new Map();
36
-
37
- // eslint-disable-next-line consistent-return
38
- return requestedModule => {
54
+ const cacheMap = /* @__PURE__ */ new Map();
55
+ return (requestedModule) => {
39
56
  if (cacheMap.has(requestedModule)) {
40
57
  return cacheMap.get(requestedModule);
41
58
  }
@@ -59,7 +76,7 @@ const isDynamicImport = (tsBinary, node) => {
59
76
  function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
60
77
  const tsPaths = {};
61
78
  const alias = {};
62
- Object.keys(paths).forEach(key => {
79
+ Object.keys(paths).forEach((key) => {
63
80
  if (Array.isArray(paths[key])) {
64
81
  tsPaths[key] = paths[key];
65
82
  } else {
@@ -67,37 +84,55 @@ function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
67
84
  }
68
85
  });
69
86
  const matchAliasPath = createAliasMatcher(baseUrl, alias);
70
- const matchTsPath = (0, _tsconfigPaths.createMatchPath)(baseUrl, tsPaths, ['main']);
87
+ const matchTsPath = (0, import_tsconfig_paths.createMatchPath)(baseUrl, tsPaths, ["main"]);
71
88
  const matchPath = (requestedModule, readJSONSync, fileExists, extensions) => {
72
- const result = matchTsPath(requestedModule, readJSONSync, fileExists, extensions);
89
+ const result = matchTsPath(
90
+ requestedModule,
91
+ readJSONSync,
92
+ fileExists,
93
+ extensions
94
+ );
73
95
  if (result) {
74
96
  return result;
75
97
  }
76
98
  return matchAliasPath(requestedModule);
77
99
  };
78
100
  if (Object.keys(paths).length === 0) {
79
- return undefined;
101
+ return void 0;
80
102
  }
81
- return ctx => {
82
- return sf => {
83
- const visitNode = node => {
103
+ return (ctx) => {
104
+ return (sf) => {
105
+ const visitNode = (node) => {
106
+ var _a;
84
107
  if (isDynamicImport(tsBinary, node)) {
85
108
  const importPathWithQuotes = node.arguments[0].getText(sf);
86
- const text = importPathWithQuotes.slice(1, importPathWithQuotes.length - 1);
109
+ const text = importPathWithQuotes.slice(
110
+ 1,
111
+ importPathWithQuotes.length - 1
112
+ );
87
113
  const result = getNotAliasedPath(sf, matchPath, text);
88
114
  if (!result) {
89
115
  return node;
90
116
  }
91
- return tsBinary.factory.updateCallExpression(node, node.expression, node.typeArguments, tsBinary.factory.createNodeArray([tsBinary.factory.createStringLiteral(result)]));
117
+ return tsBinary.factory.updateCallExpression(
118
+ node,
119
+ node.expression,
120
+ node.typeArguments,
121
+ tsBinary.factory.createNodeArray([
122
+ tsBinary.factory.createStringLiteral(result)
123
+ ])
124
+ );
92
125
  }
93
126
  if (tsBinary.isImportDeclaration(node) || tsBinary.isExportDeclaration(node) && node.moduleSpecifier) {
94
127
  try {
95
- var _node$moduleSpecifier;
96
- const importPathWithQuotes = node === null || node === void 0 ? void 0 : (_node$moduleSpecifier = node.moduleSpecifier) === null || _node$moduleSpecifier === void 0 ? void 0 : _node$moduleSpecifier.getText();
128
+ const importPathWithQuotes = (_a = node == null ? void 0 : node.moduleSpecifier) == null ? void 0 : _a.getText();
97
129
  if (!importPathWithQuotes) {
98
130
  return node;
99
131
  }
100
- const text = importPathWithQuotes.substring(1, importPathWithQuotes.length - 1);
132
+ const text = importPathWithQuotes.substring(
133
+ 1,
134
+ importPathWithQuotes.length - 1
135
+ );
101
136
  const result = getNotAliasedPath(sf, matchPath, text);
102
137
  if (!result) {
103
138
  return node;
@@ -106,13 +141,28 @@ function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
106
141
  moduleSpecifier.parent = node.moduleSpecifier.parent;
107
142
  let newNode;
108
143
  if (tsBinary.isImportDeclaration(node)) {
109
- newNode = tsBinary.factory.updateImportDeclaration(node, node.decorators, node.modifiers, node.importClause, moduleSpecifier, node.assertClause);
144
+ newNode = tsBinary.factory.updateImportDeclaration(
145
+ node,
146
+ node.decorators,
147
+ node.modifiers,
148
+ node.importClause,
149
+ moduleSpecifier,
150
+ node.assertClause
151
+ );
110
152
  } else {
111
- newNode = tsBinary.factory.updateExportDeclaration(node, node.decorators, node.modifiers, node.isTypeOnly, node.exportClause, moduleSpecifier, node.assertClause);
153
+ newNode = tsBinary.factory.updateExportDeclaration(
154
+ node,
155
+ node.decorators,
156
+ node.modifiers,
157
+ node.isTypeOnly,
158
+ node.exportClause,
159
+ moduleSpecifier,
160
+ node.assertClause
161
+ );
112
162
  }
113
163
  newNode.flags = node.flags;
114
164
  return newNode;
115
- } catch (_unused) {
165
+ } catch (e) {
116
166
  return node;
117
167
  }
118
168
  }
@@ -122,44 +172,41 @@ function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
122
172
  };
123
173
  };
124
174
  }
125
-
126
- // fork from https://github.com/nestjs/nest-cli/blob/HEAD/lib/compiler/hooks/tsconfig-paths.hook.ts
127
175
  function getNotAliasedPath(sf, matcher, text) {
128
- let result = matcher(text, undefined, undefined, ['.ts', '.tsx', '.js', '.jsx']);
176
+ let result = matcher(text, void 0, void 0, [
177
+ ".ts",
178
+ ".tsx",
179
+ ".js",
180
+ ".jsx"
181
+ ]);
129
182
  if (!result) {
130
183
  return;
131
184
  }
132
- if (os.platform() === 'win32') {
133
- result = result.replace(/\\/g, '/');
185
+ if (os.platform() === "win32") {
186
+ result = result.replace(/\\/g, "/");
134
187
  }
135
- if (!_path.default.isAbsolute(result)) {
136
- // handle alias to alias
137
- if (!result.startsWith('.') && !result.startsWith('..')) {
188
+ if (!import_path.default.isAbsolute(result)) {
189
+ if (!result.startsWith(".") && !result.startsWith("..")) {
138
190
  try {
139
- // Installed packages (node modules) should take precedence over root files with the same name.
140
- // Ref: https://github.com/nestjs/nest-cli/issues/838
141
191
  const packagePath = require.resolve(result, {
142
192
  paths: [process.cwd(), ...module.paths]
143
193
  });
144
194
  if (packagePath) {
145
- // eslint-disable-next-line consistent-return
146
195
  return result;
147
196
  }
148
- } catch (_unused2) {}
197
+ } catch (e) {
198
+ }
149
199
  }
150
200
  try {
151
- // Installed packages (node modules) should take precedence over root files with the same name.
152
- // Ref: https://github.com/nestjs/nest-cli/issues/838
153
201
  const packagePath = require.resolve(text, {
154
202
  paths: [process.cwd(), ...module.paths]
155
203
  });
156
204
  if (packagePath) {
157
- // eslint-disable-next-line consistent-return
158
205
  return text;
159
206
  }
160
- } catch (_unused3) {}
207
+ } catch (e) {
208
+ }
161
209
  }
162
- const resolvedPath = _path.posix.relative((0, _path.dirname)(sf.fileName), result) || './';
163
- // eslint-disable-next-line consistent-return
164
- return resolvedPath[0] === '.' ? resolvedPath : `./${resolvedPath}`;
165
- }
210
+ const resolvedPath = import_path.posix.relative((0, import_path.dirname)(sf.fileName), result) || "./";
211
+ return resolvedPath[0] === "." ? resolvedPath : `./${resolvedPath}`;
212
+ }
@@ -1,16 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var stdin_exports = {};
19
+ __export(stdin_exports, {
20
+ TypescriptLoader: () => TypescriptLoader
5
21
  });
6
- exports.TypescriptLoader = void 0;
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
+ module.exports = __toCommonJS(stdin_exports);
8
23
  class TypescriptLoader {
9
- constructor({
10
- appDirectory
11
- }) {
12
- _defineProperty(this, "tsBinary", void 0);
13
- _defineProperty(this, "appDirectory", void 0);
24
+ constructor({ appDirectory }) {
14
25
  this.appDirectory = appDirectory;
15
26
  }
16
27
  load() {
@@ -18,14 +29,15 @@ class TypescriptLoader {
18
29
  return this.tsBinary;
19
30
  }
20
31
  try {
21
- const tsPath = require.resolve('typescript', {
32
+ const tsPath = require.resolve("typescript", {
22
33
  paths: [this.appDirectory || process.cwd()]
23
34
  });
24
35
  const ts = require(tsPath);
25
36
  return ts;
26
37
  } catch (error) {
27
- throw new Error('TypeScript could not be found! Please, install "typescript" package.');
38
+ throw new Error(
39
+ 'TypeScript could not be found! Please, install "typescript" package.'
40
+ );
28
41
  }
29
42
  }
30
43
  }
31
- exports.TypescriptLoader = TypescriptLoader;
@@ -1,27 +1,25 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- compile: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
8
  };
9
- Object.defineProperty(exports, "compile", {
10
- enumerable: true,
11
- get: function () {
12
- return _common.compile;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
14
  }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var stdin_exports = {};
20
+ __export(stdin_exports, {
21
+ compile: () => import_common.compile
14
22
  });
15
- var _babel = require("./compilers/babel");
16
- Object.keys(_babel).forEach(function (key) {
17
- if (key === "default" || key === "__esModule") return;
18
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
- if (key in exports && exports[key] === _babel[key]) return;
20
- Object.defineProperty(exports, key, {
21
- enumerable: true,
22
- get: function () {
23
- return _babel[key];
24
- }
25
- });
26
- });
27
- var _common = require("./common");
23
+ module.exports = __toCommonJS(stdin_exports);
24
+ __reExport(stdin_exports, require("./compilers/babel"), module.exports);
25
+ var import_common = require("./common");