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

verify hermeticity of node_modules directory #1

Closed
alexeagle opened this issue Aug 26, 2017 · 4 comments
Closed

verify hermeticity of node_modules directory #1

alexeagle opened this issue Aug 26, 2017 · 4 comments

Comments

@alexeagle
Copy link
Collaborator

We encourage users to use the locking mechanism in their package manager, but we don't check that the dependencies match the versions in the lock file for each run.

Any time the node_modules directory changes, we should run yarn check --integrity.

  • catches issue with user having wrong yarn version installed
  • prevents builds failing due to unexpected changes in node_modules (eg. user has installed something and not updated the yarn.lock)

currently we only do this when the repository_rule runs, and it's not re-run until the WORKSPACE changes.

Not sure what to do about npm.

@jupp0r
Copy link

jupp0r commented Nov 6, 2017

There is one additional requirement needed for reproducibility: the npm registry needs to return identical packages for a given version. As I understand, this is not guaranteed to be the case for npmjs.org. Packages can change for any version without warning.

@alexeagle
Copy link
Collaborator Author

alexeagle commented Nov 6, 2017 via email

@jupp0r
Copy link

jupp0r commented Nov 6, 2017

Alex, you are right. Npm violated that rule during the left-pad disaster, thats where my misconception originated.

Once a package is published with a given name and version, that specific name and version combination can never be used again, even if it is removed with npm-unpublish.

https://docs.npmjs.com/cli/publish

alexeagle referenced this issue Dec 1, 2017
…e_modules during WORKSPACE instantiation.

If you add in your `WORKSPACE`:
```python
npm_install(
   name = "foo",
   packages = ":package.json",
)
```

Then in the `BUILD` file you can write:
```python
nodejs_binary(
   name = "bar",
   node_modules = "@foo//:node_modules",
   ...
)
```
@alexeagle
Copy link
Collaborator Author

In the time since this issue was filed, we introduced "bazel-managed node modules".

If you want the behavior that the node_modules is always up-to-date with the current build, you should use that feature.

I don't think we should fix this in the case of user-managed node_modules - if you install them yourself, then you are subject to the usual pitfall of forgetting to re-install after dependencies change.

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

2 participants