@vercel/redwood 2.0.10 → 2.1.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.
Files changed (2) hide show
  1. package/dist/index.js +18 -13
  2. package/package.json +6 -7
package/dist/index.js CHANGED
@@ -26,6 +26,8 @@ __export(src_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(src_exports);
28
28
  var import_path = require("path");
29
+ var import_ts_morph = require("ts-morph");
30
+ var import_static_config = require("@vercel/static-config");
29
31
  var import_fs = require("fs");
30
32
  var import_semver = require("semver");
31
33
  var import_build_utils = require("@vercel/build-utils");
@@ -142,20 +144,21 @@ var build = async ({
142
144
  staticOutputs[(0, import_path.relative)(webDistPath, pathWithoutHtmlExtension)] = fileFsRef;
143
145
  }
144
146
  }
145
- const functionFiles = {
146
- ...await (0, import_build_utils.glob)("*.js", apiDistPath),
147
- // top-level
148
- ...await (0, import_build_utils.glob)("*/*.js", apiDistPath)
149
- // one-level deep
150
- };
147
+ const functionFiles = await (0, import_build_utils.glob)("**/*.{js,ts}", apiDistPath);
151
148
  const sourceCache = /* @__PURE__ */ new Map();
152
149
  const fsCache = /* @__PURE__ */ new Map();
150
+ const project = new import_ts_morph.Project();
153
151
  for (const [funcName, fileFsRef] of Object.entries(functionFiles)) {
154
152
  const outputName = (0, import_path.join)(apiDir, (0, import_path.parse)(funcName).name);
155
153
  const absEntrypoint = fileFsRef.fsPath;
156
154
  const relativeEntrypoint = (0, import_path.relative)(workPath, absEntrypoint);
157
155
  const awsLambdaHandler = getAWSLambdaHandler(relativeEntrypoint, "handler");
158
- const sourceFile = relativeEntrypoint.replace("/dist/", "/src/");
156
+ let sourceFile = relativeEntrypoint.replace("/dist/", "/src/");
157
+ const sourceFileBase = (0, import_path.basename)(sourceFile, ".js");
158
+ const sourceFileDir = (0, import_path.dirname)(sourceFile);
159
+ if ((0, import_fs.existsSync)((0, import_path.join)(sourceFileDir, `${sourceFileBase}.ts`))) {
160
+ sourceFile = (0, import_path.join)(sourceFileDir, `${sourceFileBase}.ts`);
161
+ }
159
162
  const { fileList, esmFileList, warnings } = await (0, import_nft.nodeFileTrace)(
160
163
  [absEntrypoint],
161
164
  {
@@ -204,18 +207,20 @@ var build = async ({
204
207
  });
205
208
  }
206
209
  lambdaFiles[(0, import_path.relative)(workPath, fileFsRef.fsPath)] = fileFsRef;
207
- const lambdaOptions = await (0, import_build_utils.getLambdaOptionsFromFunction)({
208
- sourceFile,
209
- config
210
- });
210
+ const staticConfig = (0, import_static_config.getConfig)(project, sourceFile);
211
+ const regions = staticConfig?.regions;
212
+ if (regions && !Array.isArray(regions)) {
213
+ throw new Error('"regions" configuration must be an array');
214
+ }
211
215
  const lambda = new import_build_utils.NodejsLambda({
216
+ ...staticConfig,
217
+ regions,
212
218
  files: lambdaFiles,
213
219
  handler: relativeEntrypoint,
214
220
  runtime: nodeVersion.runtime,
215
221
  shouldAddHelpers: false,
216
222
  shouldAddSourcemapSupport: false,
217
- awsLambdaHandler,
218
- ...lambdaOptions
223
+ awsLambdaHandler
219
224
  });
220
225
  lambdaOutputs[outputName] = lambda;
221
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/redwood",
3
- "version": "2.0.10",
3
+ "version": "2.1.1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs",
@@ -13,24 +13,23 @@
13
13
  "directory": "packages/redwood"
14
14
  },
15
15
  "dependencies": {
16
- "@vercel/nft": "0.27.2",
16
+ "@vercel/nft": "0.27.3",
17
17
  "@vercel/routing-utils": "3.1.0",
18
- "semver": "6.3.1"
18
+ "@vercel/static-config": "3.0.0",
19
+ "semver": "6.3.1",
20
+ "ts-morph": "12.0.0"
19
21
  },
20
22
  "devDependencies": {
21
23
  "@types/aws-lambda": "8.10.19",
22
24
  "@types/node": "14.18.33",
23
25
  "@types/semver": "6.0.0",
24
- "@vercel/build-utils": "8.2.2",
26
+ "@vercel/build-utils": "8.3.2",
25
27
  "execa": "3.2.0",
26
28
  "fs-extra": "11.1.0",
27
29
  "jest-junit": "16.0.0"
28
30
  },
29
31
  "scripts": {
30
32
  "build": "node ../../utils/build-builder.mjs",
31
- "test-e2e": "pnpm test test/test.js",
32
- "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand",
33
- "test-unit": "pnpm test test/prepare-cache.test.js",
34
33
  "type-check": "tsc --noEmit"
35
34
  }
36
35
  }