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

import map generation not finding package.json for some libraries like tslib (when recursively segmenting entry point) #1386

Closed
thescientist13 opened this issue Jan 17, 2025 · 0 comments · Fixed by #1387
Assignees
Labels
alpha.5 bug Something isn't working CLI v0.31.0
Milestone

Comments

@thescientist13
Copy link
Member

Type of Change

Bug

Summary

Observed in AnalogStudiosRI/api#44 that Greenwood's import map generation was showing a warning that it could not find a package.json for tslib

{ segment: 'modules', resolvedPackageJson: { type: 'module' } }
recurse root {
  root: 'file:///Users/owenbuckley/Workspace/analogstudiosri/api/node_tslib/modules/'
}
 
WARNING: No supported entry point detected for => \`tslib\`

Which is odd because tslib definitely has main and module entry points defined. 🤔

Details

After a little debugging, the issue is in the naivety of our logic that recursively walks up from the entry point to the first valid package.json as it slowly trims the path as it walks up

root = root.replace(`${segment}/`, '');

The issue here is the tslib package has a directory called modules, so as we can see in the logs above, node_modules was getting string replaced instead of at the end of the path.

Doing this seems to work

root = root.substring(0, root.lastIndexOf(segment));
@thescientist13 thescientist13 added alpha.6 bug Something isn't working CLI v0.31.0 labels Jan 17, 2025
@thescientist13 thescientist13 added this to the 1.0 milestone Jan 17, 2025
@thescientist13 thescientist13 self-assigned this Jan 17, 2025
@thescientist13 thescientist13 changed the title import map generation not finding _package.json_ for some libraries like **tslib** (when recursively segmenting entry point) import map generation not finding package.json for some libraries like tslib (when recursively segmenting entry point) Jan 17, 2025
@thescientist13 thescientist13 moved this from 🏗 In progress to 👀 In review in [Greenwood] Phase 10 - Ecosystem Compat Jan 17, 2025
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in [Greenwood] Phase 10 - Ecosystem Compat Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpha.5 bug Something isn't working CLI v0.31.0
Projects
Development

Successfully merging a pull request may close this issue.

1 participant