Skip to content

fix(globals): use globals for globals #397

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

avivkeller
Copy link
Member

Description

The globals library is updated with every builtin global every month (https://github.com/sindresorhus/globals/blob/main/.github/workflows/update.yml), so we can safely rely on it to populate our builtin globals.

IMO this is a safer alternative than having us manually update this list.

Related Issues

Ref #319

@Copilot Copilot AI review requested due to automatic review settings August 9, 2025 16:15
@avivkeller avivkeller requested a review from a team as a code owner August 9, 2025 16:15
Copy link

vercel bot commented Aug 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Updated (UTC)
api-docs-tooling Ready Preview Aug 14, 2025 3:37pm

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the hardcoded list of JavaScript global objects to use the globals library, which automatically updates with new ES specifications monthly. This change simplifies maintenance by removing the need to manually track and update global objects.

  • Replaces hardcoded arrays of JavaScript globals with dynamic imports from the globals library
  • Moves the globals dependency from devDependencies to dependencies
  • Simplifies the primitive types mapping from an object to an array structure

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
src/utils/parser/constants.mjs Replaces manual global object lists with globals.builtin and converts primitive mapping to array
src/utils/parser/index.mjs Updates primitive type transformation to work with new array-based mapping
package.json Moves globals from devDependencies to dependencies
.github/dependabot.yml Removes globals from linting dependency group

Copy link

codecov bot commented Aug 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.20%. Comparing base (f850fd4) to head (9aac677).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #397      +/-   ##
==========================================
- Coverage   74.29%   74.20%   -0.09%     
==========================================
  Files         118      118              
  Lines       11025    10987      -38     
  Branches      695      695              
==========================================
- Hits         8191     8153      -38     
  Misses       2831     2831              
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avivkeller avivkeller changed the title fix(globals): use \globals\ for globals fix(globals): use globals for globals Aug 9, 2025
@avivkeller
Copy link
Member Author

Blocked by nodejs/node#59421

@avivkeller
Copy link
Member Author

Unrelated, but https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures#Data_types isn't a valid URL, which is also defined in this file

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going down this approach, wouldn't it be easier to use Object.keys(self)?

@ovflowd
Copy link
Member

ovflowd commented Aug 10, 2025

cc @aduh95 / @nodejs/collaborators

@avivkeller
Copy link
Member Author

If we're going down this approach, wouldn't it be easier to use Object.keys(self)?

No, firstly, see #397 (comment). Secondly, we aren't building the docs on for same version of Node.js as we are on, so the list would be incomplete

@cclauss

This comment has been minimized.

@ovflowd

This comment has been minimized.

@cclauss

This comment has been minimized.

@avivkeller

This comment has been minimized.

@avivkeller

This comment has been minimized.

@ovflowd

This comment was marked as off-topic.

@avivkeller
Copy link
Member Author

Need to fix one thing, then this'll be good to go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants