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

Handling of shared JS dependencies for a react-app #601

Closed
wolffiex opened this issue Sep 7, 2016 · 3 comments
Closed

Handling of shared JS dependencies for a react-app #601

wolffiex opened this issue Sep 7, 2016 · 3 comments

Comments

@wolffiex
Copy link

wolffiex commented Sep 7, 2016

I am looking for guidance for the best way to include shared JavaScript code in a react-app without going through npm. Currently my project is set up like this:

./my-project
  /shared
  /server
  /react-app

I made symlinks between the shared directory and the src files for each of the server and the react_app. The symlink works fine with babel --watch for the server but not with create-react-app

@gaearon
Copy link
Contributor

gaearon commented Sep 7, 2016

What problem do you see? As long as the files outside src are ES5/CommonJS it should work fine. Which they should be anyway if you use them from Node because you need to precompile them for Node. So running babel --watch on your server folder and importing resulting files from CRA should work. Importing sources won't work but this seems good because CRA Babel plugins might differ from your server Babel settings and you likely don't want the code to behave differently.

@gaearon
Copy link
Contributor

gaearon commented Sep 7, 2016

To be clear, the only limitation in CRA is that only files physically inside src will get transpiled. However you can import files from anywhere (like ../shared/build/...) as long as they are already ES5 and CommonJS. And they should be since we don't know your Node Babel settings and we don't expose ours.

@gaearon
Copy link
Contributor

gaearon commented Sep 24, 2016

Going to close since it’s not quite clear what is being asked.

@gaearon gaearon closed this as completed Sep 24, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants