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

[core] Include TS modules in rollup import resolution #28094

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Sep 1, 2021

Fixes the problem discussed in #28074 (comment) by searching for index.ts in addition to index.js in rollup config.

@mui-pr-bot
Copy link

mui-pr-bot commented Sep 1, 2021

No bundle size changes (experimental)

Generated by 🚫 dangerJS against 6f2f3a3

@michaldudak michaldudak added the core Infrastructure work going on behind the scenes label Sep 1, 2021
@michaldudak michaldudak marked this pull request as ready for review September 1, 2021 15:14
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Looks good.

In the future you could remove the custom resolveId entirely in favor of using the exports field. For example,

diff --git a/packages/material-ui-unstyled/package.json b/packages/material-ui-unstyled/package.json
index 106e9d89b5..41841c3c46 100644
--- a/packages/material-ui-unstyled/package.json
+++ b/packages/material-ui-unstyled/package.json
@@ -5,6 +5,10 @@
   "author": "Material-UI Team",
   "description": "Unstyled React components with which to implement custom design systems.",
   "main": "./src/index.js",
+  "exports": {
+    "./ModalUnstyled": "./src/ModalUnstyled/index.ts",
+    "./*": "./src/*/index.js"
+  },
   "keywords": [
     "react",
     "react-component",

already works but you have to hard-code the modules written in TS and make sure you're not publishing the package with exports.

@michaldudak
Copy link
Member Author

All right, I'll take a look at it in another PR. I think we could even default to index.ts and avoid having .js and .d.ts with mostly the same content in each component's directory.

@michaldudak michaldudak merged commit 832a245 into mui:next Sep 2, 2021
@michaldudak michaldudak deleted the rollup-ts-imports branch September 2, 2021 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants