-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat(compartment-mapper): Relax package discovery #2642
Conversation
f6e4355
to
1a74f6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gosh, this seems swell.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have any effect on packages that are optionally require
d but not otherwise mentioned in package.json
?
An example from typescript
:
try {
require('source-map-support')
} catch {}
...where source-map-support
is a dev dependency of typescript
. So this require
would not throw if a) someone has a local working copy of Microsoft/typescript
or b) someone already has source-map-support
in their node_modules
(as they often do).
for (const [name, descriptor] of Object.entries( | ||
commonDependencyDescriptors, | ||
)) { | ||
if (Object(descriptor) === descriptor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, Object(x) === x
is new to me. what does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the terse way of checking typeof x === 'object' && x !== null
. Object(x)
returns x
iff x
is an object and not null, otherwise boxes primitives.
No, this just tolerates the absence in |
1a74f6a
to
ab885a2
Compare
@boneskull We could conceivably add an even sloppier |
Closes: #2636
Description
The compartment mapper is currently strict about the interpretation of
peerDependencies
andpeerDependenciesMeta.optional
as opposed tooptionalDependencies
and is technically correct, but that correctness and understanding is not evenly distributed among tools in the ecosystem.If the Compartment Mapper instead tolerates the physical absence of expected packages, it defers an error that would be experienced under
mapNodeModules
tolink/load
since that might attempt to load a module from the missing package. This is not a particularly observable difference in behavior, but the error message will be slightly less informative.In this change, we relax the behavior by default and provide a
strict
option to provide the more informative error and tolerate fewer ecosystem defficiencies.Security Considerations
None.
Scaling Considerations
None.
Documentation Considerations
News updated.
We do not yet publish API documentation for Compartment Mapper, but the necessary annotations are present when these devices are more public.
Testing Considerations
Includes positive and negative tests for the
strict
behavior.Compatibility Considerations
The nature of some errors during bundling may change. Bundling errors are not observed on Agoric’s chain, so that sensitivity should not cause problems.
Upgrade Considerations
None.