[Feature Request]: Babel plugin to transform imports to subpackage imports
See original GitHub issueSummary
Asking for development of a babel plugin which would transform standard Carbon imports into subpackage imports.
Justification
This would provide the best possible DX, since developers wouldn’t have to worry about identifying the right way to do a subpackage import, which presently is not obvious.
This would also solve https://github.com/carbon-design-system/carbon/issues/9540, since Typescript would work on the main namespace import.
Desired UX and success metrics
No response
Required functionality
The plugin should transform standard imports like
import { Button } from 'carbon-components-react';
into subpackage imports like
import Button from 'carbon-components-react/lib/components/Button';
or
import Button from 'carbon-components-react/es/components/Button';
Where a configuration option specifies whether to use lib
or es
(or any other option).
Specific timeline issues / requests
No response
Available extra resources
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
babel-plugin-transform-imports - npm
Transforms member style imports (import {x} from 'y') into default style imports (import x from 'y/lib/x'). Latest version: 2.0.0, ...
Read more >babel-plugin-transform-default-named-imports - npm package
This simple Babel plugin makes these warnings and errors go away by transforming named import declarations of CJS and JSON modules into default...
Read more >Modules: Packages | Node.js v19.3.0 Documentation
Exports sugar; Subpath imports; Subpath patterns; Conditional exports; Nested conditions ... Defines a package where require('pkg/feature.js') and import ...
Read more >Package exports - webpack
The exports field in the package.json of a package allows to declare which module should be used when using module requests like import...
Read more >Complete guide to using ES6 modules to create Node.js ...
The issue is that the import() function returns a Promise, making it difficult to follow the normal pattern of assigning the module object...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, it appears that this app has an import from
carbon-components-react/lib
. Thanks for your help!@brandones typically when all of the icons are included, there is a CommonJS import somewhere in the code. Here is a comment where we touched on this briefly: https://github.com/carbon-design-system/carbon/issues/6602#issuecomment-729207760
Hope this helps!