Skip to content

[WIP] Migrate browserslist-config package to TypeScript#70521

Closed
himanshupathak95 wants to merge 7 commits intoWordPress:trunkfrom
himanshupathak95:try/convert-browserlist-config-ts
Closed

[WIP] Migrate browserslist-config package to TypeScript#70521
himanshupathak95 wants to merge 7 commits intoWordPress:trunkfrom
himanshupathak95:try/convert-browserlist-config-ts

Conversation

@himanshupathak95
Copy link
Contributor

What?

Part of: #67691

Migrating the packages/browserslist-config package to TypeScript.

Why?

How?

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

Before After

@himanshupathak95
Copy link
Contributor Author

I am debugging the failing tests and working on fixing them.

@t-hamano t-hamano mentioned this pull request Jun 24, 2025
40 tasks
@t-hamano t-hamano added [Type] Code Quality Issues or PRs that relate to code quality [Tool] Browserslist config /packages/browserslist-config labels Jun 25, 2025
@himanshupathak95 himanshupathak95 force-pushed the try/convert-browserlist-config-ts branch from 576bce8 to 80c05d4 Compare June 26, 2025 08:12
@himanshupathak95
Copy link
Contributor Author

So, the reason for still keeping the index.js in the root is a workaround for a circular dependency issue during TypeScript migration.

The @wordpress/browserslist-config package is a foundational dependency that other packages need during their build process. As we migrate packages to TypeScript in a specific order, we've hit a circular dependency problem.

Here's what happens when the main entry points to build/index.js:

Cannot find module '/Users/hp/gutenberg/node_modules/@wordpress/browserslist-config/build/index.js' 

This error occurs because:

  • Other packages try to import from @wordpress/browserslist-config
  • The package.json main field points to build/index.js
  • But build/index.js doesn't exist because TypeScript hasn't been compiled yet
  • TypeScript can't be compiled because the build process itself needs browserslist-config
  • This creates a dependency loop; the build system needs browserslist-config to build other packages, but browserslist-config itself needs to be built first

This same issue affects other config packages too - see #70533

So the question is: What's the proper solution? The current workaround prevents build failures but isn't a complete migration.

This also raises another question: Do config packages even need to be migrated? They don't have complex logic that would benefit from type safety. They're just low-level dependencies that other packages import during build.

cc: @manzoorwanijk @t-hamano

@manzoorwanijk
Copy link
Member

I think it's fine to leave this package as js only.

@t-hamano
Copy link
Contributor

I think it's fine to leave this package as js only.

I agree with this; this package is just a configuration file and does not contain any logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Tool] Browserslist config /packages/browserslist-config [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants