@vercel/node 2.7.0 → 2.7.1

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.
package/dist/index.js CHANGED
@@ -305317,15 +305317,21 @@ function register(opts = {}) {
305317
305317
  console.error('\x1b[31m%s\x1b[0m', error);
305318
305318
  }
305319
305319
  }
305320
- function getBuild(configFileName = '') {
305321
- let build = configFileToBuildMap.get(configFileName);
305322
- if (build)
305323
- return build;
305320
+ function getBuild(configFileName = '', skipTypeCheck) {
305321
+ const cachedGetOutput = configFileToBuildMap.get(configFileName);
305322
+ if (cachedGetOutput) {
305323
+ return cachedGetOutput;
305324
+ }
305325
+ const outFiles = new Map();
305324
305326
  const config = readConfig(configFileName);
305325
305327
  /**
305326
- * Create the basic required function using transpile mode.
305328
+ * Create the basic function for transpile only (ts-node --transpileOnly)
305327
305329
  */
305328
- const getOutput = function (code, fileName) {
305330
+ const getOutputTranspile = (code, fileName) => {
305331
+ const outFile = outFiles.get(fileName);
305332
+ if (outFile) {
305333
+ return outFile;
305334
+ }
305329
305335
  const result = ts.transpileModule(code, {
305330
305336
  fileName,
305331
305337
  transformers,
@@ -305336,84 +305342,94 @@ function register(opts = {}) {
305336
305342
  ? filterDiagnostics(result.diagnostics, ignoreDiagnostics)
305337
305343
  : [];
305338
305344
  reportTSError(diagnosticList, config.options.noEmitOnError);
305339
- return { code: result.outputText, map: result.sourceMapText };
305340
- };
305341
- // Use full language services when the fast option is disabled.
305342
- let getOutputTypeCheck;
305343
- {
305344
- const memoryCache = new MemoryCache(config.fileNames);
305345
- const cachedReadFile = cachedLookup(debugFn('readFile', readFile));
305346
- // Create the compiler host for type checking.
305347
- const serviceHost = {
305348
- getScriptFileNames: () => Array.from(memoryCache.fileVersions.keys()),
305349
- getScriptVersion: (fileName) => {
305350
- const version = memoryCache.fileVersions.get(fileName);
305351
- return version === undefined ? '' : version.toString();
305352
- },
305353
- getScriptSnapshot(fileName) {
305354
- let contents = memoryCache.fileContents.get(fileName);
305355
- // Read contents into TypeScript memory cache.
305356
- if (contents === undefined) {
305357
- contents = cachedReadFile(fileName);
305358
- if (contents === undefined)
305359
- return;
305360
- memoryCache.fileVersions.set(fileName, 1);
305361
- memoryCache.fileContents.set(fileName, contents);
305362
- }
305363
- return ts.ScriptSnapshot.fromString(contents);
305364
- },
305365
- readFile: cachedReadFile,
305366
- readDirectory: cachedLookup(debugFn('readDirectory', ts.sys.readDirectory)),
305367
- getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)),
305368
- fileExists: cachedLookup(debugFn('fileExists', fileExists)),
305369
- directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)),
305370
- getNewLine: () => ts.sys.newLine,
305371
- useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
305372
- getCurrentDirectory: () => cwd,
305373
- getCompilationSettings: () => config.options,
305374
- getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
305375
- getCustomTransformers: () => transformers,
305376
- };
305377
- const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd);
305378
- const service = ts.createLanguageService(serviceHost, registry);
305379
- // Set the file contents into cache manually.
305380
- const updateMemoryCache = function (contents, fileName) {
305381
- const fileVersion = memoryCache.fileVersions.get(fileName) || 0;
305382
- // Avoid incrementing cache when nothing has changed.
305383
- if (memoryCache.fileContents.get(fileName) === contents)
305384
- return;
305385
- memoryCache.fileVersions.set(fileName, fileVersion + 1);
305386
- memoryCache.fileContents.set(fileName, contents);
305345
+ const file = {
305346
+ code: result.outputText,
305347
+ map: result.sourceMapText,
305387
305348
  };
305388
- getOutputTypeCheck = function (code, fileName) {
305389
- updateMemoryCache(code, fileName);
305390
- const output = service.getEmitOutput(fileName);
305391
- // Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
305392
- const diagnostics = service
305393
- .getSemanticDiagnostics(fileName)
305394
- .concat(service.getSyntacticDiagnostics(fileName));
305395
- const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
305396
- reportTSError(diagnosticList, config.options.noEmitOnError);
305397
- if (output.emitSkipped) {
305398
- throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
305399
- }
305400
- // Throw an error when requiring `.d.ts` files.
305401
- if (output.outputFiles.length === 0) {
305402
- throw new TypeError('Unable to require `.d.ts` file.\n' +
305403
- 'This is usually the result of a faulty configuration or import. ' +
305404
- 'Make sure there is a `.js`, `.json` or another executable extension and ' +
305405
- 'loader (attached before `ts-node`) available alongside ' +
305406
- `\`${path_1.basename(fileName)}\`.`);
305349
+ outFiles.set(fileName, file);
305350
+ return file;
305351
+ };
305352
+ const memoryCache = new MemoryCache(config.fileNames);
305353
+ const cachedReadFile = cachedLookup(readFile);
305354
+ // Create the compiler host for type checking.
305355
+ const serviceHost = {
305356
+ getScriptFileNames: () => Array.from(memoryCache.fileVersions.keys()),
305357
+ getScriptVersion: (fileName) => {
305358
+ const version = memoryCache.fileVersions.get(fileName);
305359
+ return version === undefined ? '' : version.toString();
305360
+ },
305361
+ getScriptSnapshot(fileName) {
305362
+ let contents = memoryCache.fileContents.get(fileName);
305363
+ // Read contents into TypeScript memory cache.
305364
+ if (contents === undefined) {
305365
+ contents = cachedReadFile(fileName);
305366
+ if (contents === undefined)
305367
+ return;
305368
+ memoryCache.fileVersions.set(fileName, 1);
305369
+ memoryCache.fileContents.set(fileName, contents);
305407
305370
  }
305408
- return {
305409
- code: output.outputFiles[1].text,
305410
- map: output.outputFiles[0].text,
305411
- };
305371
+ return ts.ScriptSnapshot.fromString(contents);
305372
+ },
305373
+ readFile: cachedReadFile,
305374
+ readDirectory: cachedLookup(debugFn('readDirectory', ts.sys.readDirectory)),
305375
+ getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)),
305376
+ fileExists: cachedLookup(debugFn('fileExists', fileExists)),
305377
+ directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)),
305378
+ getNewLine: () => ts.sys.newLine,
305379
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
305380
+ getCurrentDirectory: () => cwd,
305381
+ getCompilationSettings: () => config.options,
305382
+ getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
305383
+ getCustomTransformers: () => transformers,
305384
+ };
305385
+ const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd);
305386
+ const service = ts.createLanguageService(serviceHost, registry);
305387
+ // Set the file contents into cache manually.
305388
+ const updateMemoryCache = function (contents, fileName) {
305389
+ const fileVersion = memoryCache.fileVersions.get(fileName) || 0;
305390
+ // Avoid incrementing cache when nothing has changed.
305391
+ if (memoryCache.fileContents.get(fileName) === contents)
305392
+ return;
305393
+ memoryCache.fileVersions.set(fileName, fileVersion + 1);
305394
+ memoryCache.fileContents.set(fileName, contents);
305395
+ };
305396
+ /**
305397
+ * Create complete function with full language services (normal behavior for `tsc`)
305398
+ */
305399
+ const getOutputTypeCheck = (code, fileName) => {
305400
+ const outFile = outFiles.get(fileName);
305401
+ if (outFile) {
305402
+ return outFile;
305403
+ }
305404
+ updateMemoryCache(code, fileName);
305405
+ const output = service.getEmitOutput(fileName);
305406
+ // Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
305407
+ const diagnostics = service
305408
+ .getSemanticDiagnostics(fileName)
305409
+ .concat(service.getSyntacticDiagnostics(fileName));
305410
+ const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
305411
+ reportTSError(diagnosticList, config.options.noEmitOnError);
305412
+ if (output.emitSkipped) {
305413
+ throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
305414
+ }
305415
+ // Throw an error when requiring `.d.ts` files.
305416
+ if (output.outputFiles.length === 0) {
305417
+ throw new TypeError('Unable to require `.d.ts` file.\n' +
305418
+ 'This is usually the result of a faulty configuration or import. ' +
305419
+ 'Make sure there is a `.js`, `.json` or another executable extension and ' +
305420
+ 'loader (attached before `ts-node`) available alongside ' +
305421
+ `\`${path_1.basename(fileName)}\`.`);
305422
+ }
305423
+ const file = {
305424
+ code: output.outputFiles[1].text,
305425
+ map: output.outputFiles[0].text,
305412
305426
  };
305413
- }
305414
- build = { getOutput, getOutputTypeCheck };
305415
- configFileToBuildMap.set(configFileName, build);
305416
- return build;
305427
+ outFiles.set(fileName, file);
305428
+ return file;
305429
+ };
305430
+ const getOutput = skipTypeCheck ? getOutputTranspile : getOutputTypeCheck;
305431
+ configFileToBuildMap.set(configFileName, getOutput);
305432
+ return getOutput;
305417
305433
  }
305418
305434
  // determine the tsconfig.json path for a given folder
305419
305435
  function detectConfig() {
@@ -305467,8 +305483,8 @@ function register(opts = {}) {
305467
305483
  // Create a simple TypeScript compiler proxy.
305468
305484
  function compile(code, fileName, skipTypeCheck) {
305469
305485
  const configFileName = detectConfig();
305470
- const build = getBuild(configFileName);
305471
- const { code: value, map: sourceMap } = (skipTypeCheck ? build.getOutput : build.getOutputTypeCheck)(code, fileName);
305486
+ const buildOutput = getBuild(configFileName, skipTypeCheck);
305487
+ const { code: value, map: sourceMap } = buildOutput(code, fileName);
305472
305488
  const output = {
305473
305489
  code: value,
305474
305490
  map: Object.assign(JSON.parse(sourceMap), {
@@ -141,15 +141,21 @@ function register(opts = {}) {
141
141
  console.error('\x1b[31m%s\x1b[0m', error);
142
142
  }
143
143
  }
144
- function getBuild(configFileName = '') {
145
- let build = configFileToBuildMap.get(configFileName);
146
- if (build)
147
- return build;
144
+ function getBuild(configFileName = '', skipTypeCheck) {
145
+ const cachedGetOutput = configFileToBuildMap.get(configFileName);
146
+ if (cachedGetOutput) {
147
+ return cachedGetOutput;
148
+ }
149
+ const outFiles = new Map();
148
150
  const config = readConfig(configFileName);
149
151
  /**
150
- * Create the basic required function using transpile mode.
152
+ * Create the basic function for transpile only (ts-node --transpileOnly)
151
153
  */
152
- const getOutput = function (code, fileName) {
154
+ const getOutputTranspile = (code, fileName) => {
155
+ const outFile = outFiles.get(fileName);
156
+ if (outFile) {
157
+ return outFile;
158
+ }
153
159
  const result = ts.transpileModule(code, {
154
160
  fileName,
155
161
  transformers,
@@ -160,84 +166,94 @@ function register(opts = {}) {
160
166
  ? filterDiagnostics(result.diagnostics, ignoreDiagnostics)
161
167
  : [];
162
168
  reportTSError(diagnosticList, config.options.noEmitOnError);
163
- return { code: result.outputText, map: result.sourceMapText };
164
- };
165
- // Use full language services when the fast option is disabled.
166
- let getOutputTypeCheck;
167
- {
168
- const memoryCache = new MemoryCache(config.fileNames);
169
- const cachedReadFile = cachedLookup(debugFn('readFile', readFile));
170
- // Create the compiler host for type checking.
171
- const serviceHost = {
172
- getScriptFileNames: () => Array.from(memoryCache.fileVersions.keys()),
173
- getScriptVersion: (fileName) => {
174
- const version = memoryCache.fileVersions.get(fileName);
175
- return version === undefined ? '' : version.toString();
176
- },
177
- getScriptSnapshot(fileName) {
178
- let contents = memoryCache.fileContents.get(fileName);
179
- // Read contents into TypeScript memory cache.
180
- if (contents === undefined) {
181
- contents = cachedReadFile(fileName);
182
- if (contents === undefined)
183
- return;
184
- memoryCache.fileVersions.set(fileName, 1);
185
- memoryCache.fileContents.set(fileName, contents);
186
- }
187
- return ts.ScriptSnapshot.fromString(contents);
188
- },
189
- readFile: cachedReadFile,
190
- readDirectory: cachedLookup(debugFn('readDirectory', ts.sys.readDirectory)),
191
- getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)),
192
- fileExists: cachedLookup(debugFn('fileExists', fileExists)),
193
- directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)),
194
- getNewLine: () => ts.sys.newLine,
195
- useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
196
- getCurrentDirectory: () => cwd,
197
- getCompilationSettings: () => config.options,
198
- getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
199
- getCustomTransformers: () => transformers,
169
+ const file = {
170
+ code: result.outputText,
171
+ map: result.sourceMapText,
200
172
  };
201
- const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd);
202
- const service = ts.createLanguageService(serviceHost, registry);
203
- // Set the file contents into cache manually.
204
- const updateMemoryCache = function (contents, fileName) {
205
- const fileVersion = memoryCache.fileVersions.get(fileName) || 0;
206
- // Avoid incrementing cache when nothing has changed.
207
- if (memoryCache.fileContents.get(fileName) === contents)
208
- return;
209
- memoryCache.fileVersions.set(fileName, fileVersion + 1);
210
- memoryCache.fileContents.set(fileName, contents);
211
- };
212
- getOutputTypeCheck = function (code, fileName) {
213
- updateMemoryCache(code, fileName);
214
- const output = service.getEmitOutput(fileName);
215
- // Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
216
- const diagnostics = service
217
- .getSemanticDiagnostics(fileName)
218
- .concat(service.getSyntacticDiagnostics(fileName));
219
- const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
220
- reportTSError(diagnosticList, config.options.noEmitOnError);
221
- if (output.emitSkipped) {
222
- throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
223
- }
224
- // Throw an error when requiring `.d.ts` files.
225
- if (output.outputFiles.length === 0) {
226
- throw new TypeError('Unable to require `.d.ts` file.\n' +
227
- 'This is usually the result of a faulty configuration or import. ' +
228
- 'Make sure there is a `.js`, `.json` or another executable extension and ' +
229
- 'loader (attached before `ts-node`) available alongside ' +
230
- `\`${path_1.basename(fileName)}\`.`);
173
+ outFiles.set(fileName, file);
174
+ return file;
175
+ };
176
+ const memoryCache = new MemoryCache(config.fileNames);
177
+ const cachedReadFile = cachedLookup(readFile);
178
+ // Create the compiler host for type checking.
179
+ const serviceHost = {
180
+ getScriptFileNames: () => Array.from(memoryCache.fileVersions.keys()),
181
+ getScriptVersion: (fileName) => {
182
+ const version = memoryCache.fileVersions.get(fileName);
183
+ return version === undefined ? '' : version.toString();
184
+ },
185
+ getScriptSnapshot(fileName) {
186
+ let contents = memoryCache.fileContents.get(fileName);
187
+ // Read contents into TypeScript memory cache.
188
+ if (contents === undefined) {
189
+ contents = cachedReadFile(fileName);
190
+ if (contents === undefined)
191
+ return;
192
+ memoryCache.fileVersions.set(fileName, 1);
193
+ memoryCache.fileContents.set(fileName, contents);
231
194
  }
232
- return {
233
- code: output.outputFiles[1].text,
234
- map: output.outputFiles[0].text,
235
- };
195
+ return ts.ScriptSnapshot.fromString(contents);
196
+ },
197
+ readFile: cachedReadFile,
198
+ readDirectory: cachedLookup(debugFn('readDirectory', ts.sys.readDirectory)),
199
+ getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)),
200
+ fileExists: cachedLookup(debugFn('fileExists', fileExists)),
201
+ directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)),
202
+ getNewLine: () => ts.sys.newLine,
203
+ useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
204
+ getCurrentDirectory: () => cwd,
205
+ getCompilationSettings: () => config.options,
206
+ getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
207
+ getCustomTransformers: () => transformers,
208
+ };
209
+ const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd);
210
+ const service = ts.createLanguageService(serviceHost, registry);
211
+ // Set the file contents into cache manually.
212
+ const updateMemoryCache = function (contents, fileName) {
213
+ const fileVersion = memoryCache.fileVersions.get(fileName) || 0;
214
+ // Avoid incrementing cache when nothing has changed.
215
+ if (memoryCache.fileContents.get(fileName) === contents)
216
+ return;
217
+ memoryCache.fileVersions.set(fileName, fileVersion + 1);
218
+ memoryCache.fileContents.set(fileName, contents);
219
+ };
220
+ /**
221
+ * Create complete function with full language services (normal behavior for `tsc`)
222
+ */
223
+ const getOutputTypeCheck = (code, fileName) => {
224
+ const outFile = outFiles.get(fileName);
225
+ if (outFile) {
226
+ return outFile;
227
+ }
228
+ updateMemoryCache(code, fileName);
229
+ const output = service.getEmitOutput(fileName);
230
+ // Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
231
+ const diagnostics = service
232
+ .getSemanticDiagnostics(fileName)
233
+ .concat(service.getSyntacticDiagnostics(fileName));
234
+ const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
235
+ reportTSError(diagnosticList, config.options.noEmitOnError);
236
+ if (output.emitSkipped) {
237
+ throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
238
+ }
239
+ // Throw an error when requiring `.d.ts` files.
240
+ if (output.outputFiles.length === 0) {
241
+ throw new TypeError('Unable to require `.d.ts` file.\n' +
242
+ 'This is usually the result of a faulty configuration or import. ' +
243
+ 'Make sure there is a `.js`, `.json` or another executable extension and ' +
244
+ 'loader (attached before `ts-node`) available alongside ' +
245
+ `\`${path_1.basename(fileName)}\`.`);
246
+ }
247
+ const file = {
248
+ code: output.outputFiles[1].text,
249
+ map: output.outputFiles[0].text,
236
250
  };
237
- }
238
- build = { getOutput, getOutputTypeCheck };
239
- configFileToBuildMap.set(configFileName, build);
240
- return build;
251
+ outFiles.set(fileName, file);
252
+ return file;
253
+ };
254
+ const getOutput = skipTypeCheck ? getOutputTranspile : getOutputTypeCheck;
255
+ configFileToBuildMap.set(configFileName, getOutput);
256
+ return getOutput;
241
257
  }
242
258
  // determine the tsconfig.json path for a given folder
243
259
  function detectConfig() {
@@ -291,8 +307,8 @@ function register(opts = {}) {
291
307
  // Create a simple TypeScript compiler proxy.
292
308
  function compile(code, fileName, skipTypeCheck) {
293
309
  const configFileName = detectConfig();
294
- const build = getBuild(configFileName);
295
- const { code: value, map: sourceMap } = (skipTypeCheck ? build.getOutput : build.getOutputTypeCheck)(code, fileName);
310
+ const buildOutput = getBuild(configFileName, skipTypeCheck);
311
+ const { code: value, map: sourceMap } = buildOutput(code, fileName);
296
312
  const output = {
297
313
  code: value,
298
314
  map: Object.assign(JSON.parse(sourceMap), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/node",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@edge-runtime/vm": "2.0.0",
33
33
  "@types/node": "14.18.33",
34
- "@vercel/build-utils": "5.6.0",
34
+ "@vercel/build-utils": "5.7.0",
35
35
  "@vercel/node-bridge": "3.1.2",
36
36
  "@vercel/static-config": "2.0.6",
37
37
  "edge-runtime": "2.0.0",
@@ -61,5 +61,5 @@
61
61
  "source-map-support": "0.5.12",
62
62
  "test-listen": "1.1.0"
63
63
  },
64
- "gitHead": "a19447f9cdc8c7be8aa3646dfb441dd9469d2ed3"
64
+ "gitHead": "b37ac5f798acbfb8f04e047301766440ad0d4c59"
65
65
  }