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

Hard fork node-parent-require #1062

Closed
kethinov opened this issue Jun 6, 2021 · 0 comments · Fixed by #1240
Closed

Hard fork node-parent-require #1062

kethinov opened this issue Jun 6, 2021 · 0 comments · Fixed by #1240
Assignees
Labels
enhancement Planned feature good first issue If you're new to the project, this would be a good issue to try resolving first help wanted mentor available A maintainer is available to help you work on this if you take it up

Comments

@kethinov
Copy link
Member

kethinov commented Jun 6, 2021

One of our dependencies hasn't been updated in 8 years: https://github.com/jaredhanson/node-parent-require

It's a small module, so I think we should just bundle it in our lib directory and provide some necessary updates to it (see repo's issue queue):

"As a result of nodejs/node#32217, module.parent is deprecated (DEP0144), at least in part because it is not set for a CJS module imported using the ESM loader. The deprecation causes parent-require to print a warning if node is run with --pending-deprecation (or throw if run with --throw-deprecation):

node --pending-deprecation -e "require('parent-require')('parent-require')"
(node:483687) [DEP0144] DeprecationWarning: module.parent is deprecated due to accuracy issues. Please use require.main to find program entry point instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

"The suggestion in the DEP0144 docs is to use require.cache with module.children to find parents:

const moduleParents = Object.values(require.cache)
  .filter((m) => m.children.includes(module));

Unfortunately, I don't think this would work with the ESM loader, which does not use require.cache. I'm not sure there is a way to support the ESM loader, but I thought it was worth opening this issue so that you are aware."

@kethinov kethinov added enhancement Planned feature good first issue If you're new to the project, this would be a good issue to try resolving first help wanted mentor available A maintainer is available to help you work on this if you take it up labels Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Planned feature good first issue If you're new to the project, this would be a good issue to try resolving first help wanted mentor available A maintainer is available to help you work on this if you take it up
Development

Successfully merging a pull request may close this issue.

2 participants