You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
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.
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:
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
The text was updated successfully, but these errors were encountered: