Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Resolve dependencies using .next/serverless as base path #425

Merged
merged 7 commits into from
Jun 3, 2020

Conversation

thiagozf
Copy link
Contributor

@thiagozf thiagozf commented Jun 3, 2020

Problem

When using the new experimental-serverless-trace build target, the Next.js Serverless Component is copying Lambda dependencies to wrong destinations in two identified scenarios (see issue #236):

  • Dynamic chunks are currently going to "<root>/.next/serverless", when they should be placed directly into "<root>".
  • In monorepo setups, node_modules should always be copied to <root>

PS.: <root> is "<next config path>/.serverless_nextjs/<lambda handler>"

Solution

The component now uses <next config path>/.next/serverless as the relative base path to calculate Lambda handler dependencies destinations. Also, all node_modules files are now copied to <root>/node_modules, ignoring relative parent paths. These changes should resolve the issues in both scenarios.

Copy link
Contributor

@danielcondemarin danielcondemarin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thiagozf Awesome work 🙌

I've added an integration test to ensure there aren't regression issues introduced later. Will get this merged and published soon!

@danielcondemarin
Copy link
Contributor

Getting this merged despite the test failures. They seem to be Travis specific issues. I'll take a look at that separately.

@danielcondemarin danielcondemarin merged commit d60982f into serverless-nextjs:master Jun 3, 2020
sclaughl pushed a commit to sclaughl/serverless-next.js that referenced this pull request Jul 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants