@sveltejs/adapter-vercel 1.0.0-next.61 → 1.0.0-next.64

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/index.js +35 -3
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -93,7 +93,6 @@ export default function ({ external = [], edge, split } = {}) {
93
93
 
94
94
  const tmp = builder.getBuildDirectory('vercel-tmp');
95
95
 
96
- builder.rimraf(dir);
97
96
  builder.rimraf(tmp);
98
97
 
99
98
  const files = fileURLToPath(new URL('./files', import.meta.url).href);
@@ -152,6 +151,7 @@ export default function ({ external = [], edge, split } = {}) {
152
151
  );
153
152
 
154
153
  await create_function_bundle(
154
+ builder,
155
155
  `${tmp}/index.js`,
156
156
  `${dirs.functions}/${name}.func`,
157
157
  `nodejs${node_version.major}.x`
@@ -288,22 +288,54 @@ function get_node_version() {
288
288
  }
289
289
 
290
290
  /**
291
+ * @param {import('@sveltejs/kit').Builder} builder
291
292
  * @param {string} entry
292
293
  * @param {string} dir
293
294
  * @param {string} runtime
294
295
  */
295
- async function create_function_bundle(entry, dir, runtime) {
296
+ async function create_function_bundle(builder, entry, dir, runtime) {
297
+ fs.rmSync(dir, { force: true, recursive: true });
298
+
296
299
  let base = entry;
297
300
  while (base !== (base = path.dirname(base)));
298
301
 
299
302
  const traced = await nodeFileTrace([entry], { base });
300
303
 
304
+ /** @type {Map<string, string[]>} */
305
+ const resolution_failures = new Map();
306
+
301
307
  traced.warnings.forEach((error) => {
302
308
  // pending https://github.com/vercel/nft/issues/284
303
309
  if (error.message.startsWith('Failed to resolve dependency node:')) return;
304
- console.error(error);
310
+
311
+ if (error.message.startsWith('Failed to resolve dependency')) {
312
+ const match = /Cannot find module '(.+?)' loaded from (.+)/;
313
+ const [, module, importer] = match.exec(error.message);
314
+
315
+ if (!resolution_failures.has(importer)) {
316
+ resolution_failures.set(importer, []);
317
+ }
318
+
319
+ resolution_failures.get(importer).push(module);
320
+ } else {
321
+ throw error;
322
+ }
305
323
  });
306
324
 
325
+ if (resolution_failures.size > 0) {
326
+ const cwd = process.cwd();
327
+ builder.log.warn(
328
+ 'The following modules failed to locate dependencies that may (or may not) be required for your app to work:'
329
+ );
330
+
331
+ for (const [importer, modules] of resolution_failures) {
332
+ console.error(` ${path.relative(cwd, importer)}`);
333
+ for (const module of modules) {
334
+ console.error(` - \u001B[1m\u001B[36m${module}\u001B[39m\u001B[22m`);
335
+ }
336
+ }
337
+ }
338
+
307
339
  // find common ancestor directory
308
340
  let common_parts;
309
341
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-vercel",
3
- "version": "1.0.0-next.61",
3
+ "version": "1.0.0-next.64",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -24,10 +24,10 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@vercel/nft": "^0.20.0",
27
- "esbuild": "^0.14.42"
27
+ "esbuild": "^0.14.48"
28
28
  },
29
29
  "devDependencies": {
30
- "@sveltejs/kit": "1.0.0-next.372",
30
+ "@sveltejs/kit": "1.0.0-next.378",
31
31
  "@types/node": "^16.11.36",
32
32
  "typescript": "^4.7.4"
33
33
  },