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

Node.js: Built projects contain the absolute path of the build directory #187

Open
coder17934 opened this issue Jul 26, 2020 · 0 comments
Open

Comments

@coder17934
Copy link

Description:

This is more of a feature request, so apologies if this doesn't belong here. Many versions ago NPM introduced adding metadata into package.json when building a project. As far as I can tell it was done as an extension point that future version could use, see [1] for more details. The problem is that one of the added pieces of metadata is the absolute location of where the project was built, which in itself isn't great but coupled with the fact that SAM uses a directory hash for tracking changes and that AWS CodeBuild uses ephemeral build directories means that files will always appear to have changed even when the only thing that's changed is the location of the build directory. While it doesn't look like NPM will fix the issue any time soon my hope was that the Node lambda builder can run a command after build to remove the metadata. As the metadata isn't used by NPM this is currently completely safe. In fact my current workaround uses [2] to remove the metadata after running sam build. I am happy to submit a PR if it's deemed appropriate, although it might take some time due to work commitments.

[1] npm/npm#10393
[2] https://www.npmjs.com/package/removeNPMAbsolutePaths

Steps to reproduce the issue:

  1. Run sam build on an NPM project with external dependencies
  2. In the build directory, in node_modules, look at a package.json

Observed result:

You will see properties such as "_where": "/Users/jshore/Documents/Projects/weewikipaint", containing the absolute path of build directory.

Expected result:

A build should be idempotent and not dependent on build location.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

Reproducible on both Mac and Amazon Linux

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

No branches or pull requests

3 participants