@vercel/node 2.8.3 → 2.8.5

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,63 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fixConfigDev = exports.onDevRequest = void 0;
3
+ exports.onDevRequest = void 0;
4
4
  const entrypoint = process.env.VERCEL_DEV_ENTRYPOINT;
5
5
  delete process.env.VERCEL_DEV_ENTRYPOINT;
6
- const tsconfig = process.env.VERCEL_DEV_TSCONFIG;
7
- delete process.env.VERCEL_DEV_TSCONFIG;
8
6
  if (!entrypoint) {
9
7
  throw new Error('`VERCEL_DEV_ENTRYPOINT` must be defined');
10
8
  }
9
+ delete process.env.TS_NODE_TRANSPILE_ONLY;
10
+ delete process.env.TS_NODE_COMPILER_OPTIONS;
11
11
  const path_1 = require("path");
12
- const ts_node_1 = require("ts-node");
13
- const typescript_1 = require("./typescript");
14
- let useRequire = false;
15
- if (!process.env.VERCEL_DEV_IS_ESM) {
16
- const resolveTypescript = (p) => {
17
- try {
18
- return require.resolve('typescript', {
19
- paths: [p],
20
- });
21
- }
22
- catch (_) {
23
- return '';
24
- }
25
- };
26
- const requireTypescript = (p) => {
27
- // eslint-disable-next-line @typescript-eslint/no-var-requires
28
- return require(p);
29
- };
30
- let ts = null;
31
- // Use the project's version of Typescript if available and supports `target`
32
- let compiler = resolveTypescript(process.cwd());
33
- if (compiler) {
34
- ts = requireTypescript(compiler);
35
- }
36
- // Otherwise fall back to using the copy that `@vercel/node` uses
37
- if (!ts) {
38
- compiler = resolveTypescript(path_1.join(__dirname, '..'));
39
- ts = requireTypescript(compiler);
40
- }
41
- let config = {};
42
- if (tsconfig) {
43
- try {
44
- config = ts.readConfigFile(tsconfig, ts.sys.readFile).config;
45
- }
46
- catch (err) {
47
- if (err.code !== 'ENOENT') {
48
- console.error(`Error while parsing "${tsconfig}"`);
49
- throw err;
50
- }
51
- }
52
- }
53
- fixConfigDev(config);
54
- ts_node_1.register({
55
- compiler,
56
- compilerOptions: config.compilerOptions,
57
- transpileOnly: true,
58
- });
59
- useRequire = true;
60
- }
12
+ const useRequire = process.env.VERCEL_DEV_IS_ESM !== '1';
61
13
  const http_1 = require("http");
62
14
  const static_config_1 = require("@vercel/static-config");
63
15
  const ts_morph_1 = require("ts-morph");
@@ -149,19 +101,6 @@ async function onDevRequest(req, res) {
149
101
  }
150
102
  }
151
103
  exports.onDevRequest = onDevRequest;
152
- function fixConfigDev(config) {
153
- const nodeVersionMajor = Number(process.versions.node.split('.')[0]);
154
- typescript_1.fixConfig(config, nodeVersionMajor);
155
- // In prod, `.ts` inputs use TypeScript and
156
- // `.js` inputs use Babel to convert ESM to CJS.
157
- // In dev, both `.ts` and `.js` inputs use ts-node
158
- // without Babel so we must enable `allowJs`.
159
- config.compilerOptions.allowJs = true;
160
- // In prod, we emit outputs to the filesystem.
161
- // In dev, we don't emit because we use ts-node.
162
- config.compilerOptions.noEmit = true;
163
- }
164
- exports.fixConfigDev = fixConfigDev;
165
104
  main().catch(err => {
166
105
  utils_1.logError(err);
167
106
  process.exit(1);