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

[code-infra] Fully resolve imports in ESM target #14234

Merged
merged 8 commits into from
Aug 29, 2024

Conversation

Janpot
Copy link
Member

@Janpot Janpot commented Aug 16, 2024

Stepping stone towards full ESM support.
This babel plugin replaces imports with their full resolved path + extension.

./path/to/module becomes ./path/to/module.js or ./path/to/module/index.js, depending on where it resolves to.

See mui/material-ui#43294

blocked on

@Janpot Janpot added the scope: code-infra Specific to the core-infra product label Aug 16, 2024
@mui-bot
Copy link

mui-bot commented Aug 16, 2024

Deploy preview: https://deploy-preview-14234--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 2ef7f64

@Janpot
Copy link
Member Author

Janpot commented Aug 19, 2024

Tried out with the dataGrid through the csbci published packages and no issues found

@Janpot Janpot marked this pull request as ready for review August 19, 2024 15:30
@JCQuintas
Copy link
Member

@alexfauquette added you here cause you might have feedback based on #13608

@Janpot
Copy link
Member Author

Janpot commented Aug 19, 2024

For reference, the next steps are

  • replace extension for esm modules with .mjs
  • remove nested package.json files
  • add exports field (this one likely will need to go on a semver major)

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 21, 2024
@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Aug 21, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 22, 2024
@Janpot Janpot requested a review from a team August 23, 2024 08:37
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 26, 2024
@Janpot
Copy link
Member Author

Janpot commented Aug 29, 2024

@JCQuintas @alexfauquette This PR doesn't touch the build process of @mui/x-charts-vendor. This package (so far) doesn't seem to have any relative imports in its ESM target. It looks like it's already ESM compliant.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Aug 29, 2024
@alexfauquette
Copy link
Member

This PR doesn't touch the build process of @mui/x-charts-vendor. This package (so far) doesn't seem to have any relative imports in its ESM target. It looks like it's already ESM compliant.

Just to be sure, "this PR does not touch the build process of @mui/x-charts-vendor" and "It looks like it's already ESM compliant" are not related.

  1. The PR does not impact the package because it is a dedicated babel config that is used in the build script
  2. Tt's already ESM compliant because ESM files are fairly simple
// `x-charts-vendor/d3-color` (ESM)
// See upstream license: https://github.com/d3/d3-color/blob/main/LICENSE
//
// Our ESM package uses the underlying installed dependencies of `node_modules/d3-color`
export * from "d3-color";

Copy link
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

I tried two codesandboxes, and looked at some of the diff in the build folders. The modification looks ok.

@Janpot
Copy link
Member Author

Janpot commented Aug 29, 2024

  1. Yes, the vendor package does its own build, what I add in this PR has no influence in it whatsoever.
  2. Yes, it has an exports field and all relative modules specifiers inside contain the file extension ("all" because there are none 😉)

@Janpot Janpot merged commit 3ff993c into mui:master Aug 29, 2024
18 checks passed
@Janpot Janpot deleted the babel-resolve-imports branch August 29, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: code-infra Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants