Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove optional peer dependencies #542

Merged
merged 2 commits into from Jun 11, 2020
Merged

Remove optional peer dependencies #542

merged 2 commits into from Jun 11, 2020

Conversation

j0k3r
Copy link
Member

@j0k3r j0k3r commented Oct 16, 2019

What did you implement:

When fetching peer dependencies we now remove those which are optional.

And optional dependencies can be defined using Yarn (only at the moment) when using the peerDependenciesMeta field:

"peerDependenciesMeta": {
  "peer-deps": {
    "optional": true
  }
}

I got that issue because jsdom recently added a peer dependency as optional: jsdom/jsdom#2605

The peerDependenciesMeta exist in Yarn since almost a year now: yarnpkg/yarn#6671

How did you implement it:

If the peer dependency is defined as optional, I removed it from the peer dependencies.

How can we verify it:

Build a project which contains the jsdom deps as of 15.2.0.
It'll try to fetch the canvas deps which is defined as peer dependency but optional.
You should get that error when build the package using serverless:

Serverless: Bundling with Webpack...
   XX modules
Serverless: Fetch dependency graph from /Users/jeremy/project/package.json
...
Serverless: Adding explicit peers for dependency jsdom
Serverless: WARNING: Could not determine version of module canvas
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: jsdom@^15.2.0, canvas

  Error --------------------------------------------------

  Error: yarn install --frozen-lockfile --non-interactive --ignore-scripts failed with code 1
      at ChildProcess.child.on.exitCode (/Users/jeremy/Sites/project/node_modules/serverless-webpack/lib/utils.js:92:16)
      at emitTwo (events.js:126:13)
      at ChildProcess.emit (events.js:214:7)
      at maybeClose (internal/child_process.js:925:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

With that PR the optional peer dependency will be ignored:

Serverless: Bundling with Webpack...
   XX modules
Serverless: Fetch dependency graph from /Users/jeremy/project/package.json
...
Serverless: Adding explicit peers for dependency jsdom
Serverless: Skipping peers dependency canvas for dependency jsdom because it's optional
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: jsdom@^15.2.0
Serverless: Package took [3123 ms]

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

Copy link
Member

@miguel-a-calles-mba miguel-a-calles-mba left a comment

Choose a reason for hiding this comment

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

Code coverage decreased significantly.

@j0k3r
Copy link
Member Author

j0k3r commented Apr 13, 2020

I’ll take a look!

@j0k3r
Copy link
Member Author

j0k3r commented Apr 14, 2020

I force pushed to remove the merge commit from master and rebased against the master so the branch is clean and up to date.

I've also added more test to cover each scenarii: with & without optional peer deps.

I've duplicated the whole peer dependencies tests because I didn't know how to achieve same test with a different package.json.

@j0k3r
Copy link
Member Author

j0k3r commented May 5, 2020

Force pushed to make the PR up-to-date with the master branch.

Also coverage dropped because there is an issue on Travis. The Node 6 build generate a good coverage while the Node 8 build generate less coverage:

When fetching peer dependencies we now remove those which are optional.
And optional dependencies can be defined using Yarn (only at the moment) when using the `peerDependenciesMeta` field.
@j0k3r
Copy link
Member Author

j0k3r commented May 27, 2020

Rebased again from master so it's tested on Node 10 & 12.

@miguel-a-calles-mba miguel-a-calles-mba requested a review from a team June 2, 2020 02:04
@miguel-a-calles-mba miguel-a-calles-mba added this to the 5.3.3 milestone Jun 2, 2020
@miguel-a-calles-mba miguel-a-calles-mba changed the base branch from master to release/5.3.3 June 2, 2020 02:06
@miguel-a-calles-mba miguel-a-calles-mba requested a review from a team June 2, 2020 02:09
@miguel-a-calles-mba miguel-a-calles-mba merged commit 6507cff into serverless-heaven:release/5.3.3 Jun 11, 2020
@j0k3r j0k3r deleted the fix/remove-optional-peer-deps branch June 12, 2020 05:23
@miguel-a-calles-mba
Copy link
Member

@j0k3r Would you be interested in joining the Serverless Webpack team?

@j0k3r
Copy link
Member Author

j0k3r commented Jun 22, 2020

@miguel-a-calles-mba Sure!
I can help you manage issues & PRs from time to time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants