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

[test] Split the test package #39061

Merged
merged 7 commits into from
Sep 22, 2023
Merged

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Sep 19, 2023

This is a step towards removing circular package dependencies.
This PR splits the test package into two: @mui-internal/test-utils (that live under the packages directory) and @mui-internal/tests (which remains under the test directory). @mui-internal/test-utils contains the files from the old test/utils directory.

I renamed the remains to @mui-internal/tests, as test is the name of Node's built-in package.

This PR does not remove the actual dependency cycles. It requires refactoring of several modules under test-utils. I'll open a separate PR for this.

@michaldudak michaldudak requested a review from a team September 19, 2023 16:42
@mui-bot
Copy link

mui-bot commented Sep 19, 2023

Netlify deploy preview

https://deploy-preview-39061--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 91b1972

@@ -211,15 +211,6 @@ module.exports = {
rules: {
// does not work with wildcard imports. Mistakes will throw at runtime anyway
'import/named': 'off',
'no-restricted-imports': [
Copy link
Member Author

Choose a reason for hiding this comment

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

No need to do this anymore as package.json's export field controls visibility of exports.

Copy link
Member

Choose a reason for hiding this comment

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

Which linting process is now controlling this? The typescript type checker?

Copy link
Member Author

Choose a reason for hiding this comment

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

Node doesn't allow importing arbitrary files from the package when any subpath exports are defined.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, 👍 that assumes there is at least one Node.js process importing this natively

"noUnusedLocals": true,
"skipLibCheck": true,
"esModuleInterop": true
"esModuleInterop": true,
"moduleResolution": "node16",
Copy link
Member Author

Choose a reason for hiding this comment

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

This lets TS respect the exports field in other packages (making adding the new package to root tsconfig's paths unnecessary).

@michaldudak michaldudak marked this pull request as ready for review September 19, 2023 21:22
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 20, 2023
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Ok, so as a first step it's getting all the imports in order without really touching the implementation. So if I understand correctly, the only cycle that is really left is one between test and @mui/test-utilities? Which will be tackled separately? (I really like this style of development, especially for code infra stuff which often touches a lot of code, makes things much easier to review)

If I had to nit about one thing it'd be about nomenclature. Across the codebases we tend to name these packages/folders "utils" not "utilities".

@michaldudak
Copy link
Member Author

So if I understand correctly, the only cycle that is really left is one between test and @mui/test-utilities?

No, there's no cycle between them. The ones remaining are between [@mui/material, @mui/base, @mui/joy] and @mui-internal/test-utilities as the describeConformance utilities use components from these packages. I'll open a separate PR for this as it requires some code changes.

Across the codebases we tend to name these packages/folders "utils" not "utilities".

Actually, I named this package after docs-utilities. I realize it's not consistent with @mui/utils. I suppose we could call the new package test-utils and later rename docs-utilities to docs-utils.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Sep 22, 2023
@michaldudak michaldudak merged commit 9d5bcd6 into mui:master Sep 22, 2023
9 checks passed
@michaldudak michaldudak deleted the split-test-package branch September 22, 2023 12:47
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants