question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request]: Babel plugin to transform imports to subpackage imports

See original GitHub issue

Summary

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
brandonescommented, Sep 15, 2021

Yes, it appears that this app has an import from carbon-components-react/lib. Thanks for your help!

0reactions
joshblackcommented, Sep 14, 2021

@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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found