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

Support for local dependencies for Node.js build command #106

Closed
wants to merge 18 commits into from

Conversation

stojanovic
Copy link

Issue #, if available:
Issue is not opened.

Description of changes:
Right now, Node.js builder can resolve dependencies from NPM or git, but it doesn't know how to resolve local dependencies. This PR allows users to have local dependencies, and even nested local dependencies in Node.js. For example, your package.json file can contain something similar to this:

{
  "name": "awesome-serverless-function",
  "version": "1.0.0",
  "dependencies": {
    "minimal-request-promise": "^1.3.0", // NPM dependency
    "logger": "file:../logger" // local dependency
  }
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@stojanovic stojanovic changed the title Feat/local dependencies Support for local dependencies for Node.js build command Mar 24, 2019
@sriram-mv
Copy link
Contributor

This requires 2 ways to think about it. Supporting the local use case (no mounting here, so it just works!) and then supporting this to work inside a container. Any local dependencies that are not mounted along with source code will break within the container, because they wont resolve.

@peterabarry
Copy link

It would be helpful if some workaround was covered here, as well as, perhaps disambiguating from layers, or other alternatives. Claudia pack is suggested as a workaround but it not that clear how exactly to use that in a workflow.

@jfuss
Copy link
Contributor

jfuss commented Feb 26, 2020

There was some conversations about this on this issue but will add details here as well.

This is something we want to support but we have a some challenges due to how we currently build functions in SAM CLI, which is what is holding this up not because we don't want it merged.

SAM CLI uses this library in order to build Lambda functions. SAM CLI mounts code into the container for each function. For the local dependency case (in the container), there is no way to build with local dependencies unless all the code is mounted, not just the CodeUri. To support this we need to change how we mount code into the container, most likely mount the project instead and execute sam build in the container. This fundamentally changes the current architecture. Now this could work in the non-container build but comes with a usability concern. That is customers who need local dependencies in build would fail if they try to do --use-container and cause further confusion on "this build works in the non-container build but not the container build“ (which is feedback we get on our current python build experience. To truly support building with local dependencies, we want to enable both use-cases.

As workarounds, you will need to build outside of sam build. You can use tools like Claudia or Webpack to achieve this in the meantime.

@stojanovic
Copy link
Author

I'll close this PR as it will not be merged anyway.

@stojanovic stojanovic closed this Feb 26, 2020
@jfuss
Copy link
Contributor

jfuss commented Feb 26, 2020

@stojanovic

I'll close this PR as it will not be merged anyway.

That isn't completely true. Our intention is to merge this but we need to have additional work done in SAM CLI to make sure we can fully support the local dependency case in the --use-container case. Otherwise, it becomes another place for confusion.

@stojanovic
Copy link
Author

It's 11 months old right now, and I guess it will be more than 18 months old when you can merge it, so I am sure it will be more complex to resolve conflicts than to rewrite it. I am no longer using the sam build command, anyway.

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.

5 participants