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.

Support for dynamically exported components

See original GitHub issue

Using atomic design and @diegohaz arc boilerplate, you are able to reference components that are located anywhere in the components subdirectories i.e. atoms, molecules, organisms etc. For reference here is the link: https://github.com/diegohaz/arc/wiki/Atomic-Design#do-not-worry Per the link: This is possible because all components are dynamically exported on src-example/components/index.js and imported in a way that Atomic Design structure doesn’t matter:

import { Input, Label, Field, HomePage, PageTemplate } from 'components'

Has anyone been able to get the same functionality with create-react-app?

I have managed to get rid of the relative paths using .env and specifying NODE_PATH=src but I still have to explicitly include the entire subdirectory structure for the component.

Thanks

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
gaearoncommented, Jun 22, 2017

I don’t recommend doing this via index.js. It means code splitting won’t work because everything ends up in the same bundle.

At Facebook, we use a system called “haste” that lets you import any file by its unique name without relative paths. I’m open to supporting it as an opt-in in CRA projects, but somebody would need to write a Webpack plugin for it. Jest already supports it.

0reactions
gaearoncommented, Jan 8, 2018

Going to close this as overlapping too much with https://github.com/facebookincubator/create-react-app/issues/1333.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Export React Components dynamically - Stack Overflow
I have a HOCWrapper component that is a HOC, that is implemented like mentioned here. index.js import * as all from './AllMyComponents' let ......
Read more >
JavaScript dynamic import() & export | by Andrea Giammarchi
polyfills based on features detection, importing arbitrary amount of modules before exporting their functionality; Custom Elements that depends ...
Read more >
How to Dynamically Import ECMAScript Modules
The imported module exports components. export const concat = (paramA, paramB) => paramA + paramB;. import { concat } from '.
Read more >
Advanced Features: Dynamic Import - Next.js
Dynamically import JavaScript modules and React Components and split your code into manageable chunks.
Read more >
Exporting and importing dynamic content - Zendesk help
To streamline the translation of your dynamic content, you can easily export the content as CSV (comma separated values) files that...
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