Skip to content

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

Merged
Janpot merged 8 commits intomui:masterfrom
Janpot:babel-resolve-imports
Aug 29, 2024
Merged

[code-infra] Fully resolve imports in ESM target#14234
Janpot merged 8 commits intomui:masterfrom
Janpot:babel-resolve-imports

Conversation

@Janpot
Copy link
Copy Markdown
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

@mui-bot
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member

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

@Janpot
Copy link
Copy Markdown
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)

@github-actions
Copy link
Copy Markdown
Contributor

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
@github-actions
Copy link
Copy Markdown
Contributor

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
@github-actions
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 😉)

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

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants