Repository navigation
Conversation
…annot link Since #924 an optional peer was never an edge of the dependency walk, so a workspace library listing expo as an optional peer and importing it left expo's dependencies uncompiled, and Node failed to link them. A peer is now followed when the package loads it, optional or not, from a reached workspace library too. A link error in an uncompiled dependency of an undeclared package fails with UNDECLARED_DEPENDENCY_UNCOMPILED.
It fails as its bug on a833f71 and passes before it and on the fix.
Workspace source is TypeScript of any shape, so a peer edge that needs the scan to find the import misses NodeNext './x.js' imports and a main naming an unbuilt dist/. The scan now maps .js imports to TypeScript sources for installed packages. A link error is attributed to an uncompiled dependency only when a file of the requested name in it exports the name.
2 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A package reached only as an optional peer has its dependencies compiled again. A dependency Node cannot link fails with
UNDECLARED_DEPENDENCY_UNCOMPILEDwhen compiling it would fix the link. A genuinely missing export stays Node's own error.Why
Since 0.16.0 (#924), the dependency walk never followed an optional peer. Take a workspace library that lists
expoas an optional peer and imports it.expowas compiled, but its dependencies were not. Node then ran expo-modules-core's ES module build as published, and every test file failed with "The requested module './EventEmitter' does not provide an export named 'EventEmitter'".Changes
ecosystem.ts(loadedPeers): a workspace member's own optional React Native peer is followed without reading its imports. Workspace source is TypeScript of any shape, so an import the scan misses would be this bug again../x.js,.mjsand.cjsimports to their TypeScript sources.dependencieswere.explain.mjs: Node's link error ("does not provide an export named") is attributed to a recorded uncompiled dependency only when that dependency, or a recorded dependency it links, has a file of the requested name that exports the name.tests/optional-peer-edge.test.tscovers CommonJS, NodeNext./x.js, an unbuiltdist/, undetected libraries and an installed non-Expo library.tests/scan-found-dependency.test.tscovers platform-file, cross-package and genuinely missing exports. The bug museum gains exhibitres-optional-peer-workspace(a TypeScript workspace library), recorded as guard proven against a833f71.How to review
Start at
loadedPeersinecosystem.tsand its two call sites, the walk and the reached-member seed. Then readlinkedExportSourceinexplain.mjs.Notes
ecosystem-closure.test.tsreverses an assertion from fix(native): compile a required React Native peer a compiled package loads, though nothing declares it #519, because that peer is installed and imported.perf-evidence/runs/20261204-runtime975-detection-sets.Every edge rule in the walk, checked for dropping an edge because of how a dependency is declared rather than whether it is installed and loaded:
./x.jsimportsdependenciesoptionalDependenciesare not followeddependenciesonlypeerDependenciesare neither candidates nor seedsCloses #975