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

babel not transpiling outside of src directory. #224

Closed
raythree opened this issue Aug 5, 2016 · 8 comments
Closed

babel not transpiling outside of src directory. #224

raythree opened this issue Aug 5, 2016 · 8 comments

Comments

@raythree
Copy link
Contributor

raythree commented Aug 5, 2016

Node version: 6.2.2
npm version: 3.9.5
Operating system: EI Capitan
Command line used: npm run build

I've used slingshot on a few new projects and it works great. I'm trying to convert a few existing projects that were using browserify and gulp. I think I have everything in place however it is structured a little differently because of the way I was handling code common to multiple app:

common
  … (some common components and utilities shared by all apps
app1
  src/ …
app2
  src/...

So, app1 for example, has some places where it imports code as:

import SomeComponent from '../../../common/compnents/SomeComponent';

And after doing an "npm run build" for app1, it seems that all components imported from the common folder outside of app1/src are not getting transpired by babel. When previously using gulp/browserify, even though I really just wanted to import the source files from common, I've found that each of the common components needed to have it's own package.json (and npm install run) because of the way node resolves imports. I think this may be related... I tried copying the .babelrc to each of the common directories, but that didn't help.

Any idea?
Thanks!

@coryhouse
Copy link
Owner

I know this doesn't directly answer your question, but why not package shared code as an npm package?

@raythree
Copy link
Contributor Author

raythree commented Aug 5, 2016

Actually since each of the common folders needs their own package.json/deps just to import them, I may as well put a "build" in their package.json that runs babel src -> lib (just the way you do when publishing an npm package)

@raythree
Copy link
Contributor Author

raythree commented Aug 5, 2016

Ah, you answered as I was typing... yeah, this is a private repo, so we'd have to use private npm, but same idea. Thanks!

@raythree
Copy link
Contributor Author

raythree commented Aug 5, 2016

I am still curious though why they didn't get transpired, as they were linked in through the entry point.

@coryhouse
Copy link
Owner

coryhouse commented Aug 5, 2016

I believe it's this line from the dev and prod webpack configs: https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.prod.js#L68

Try taking that out and see if you're all set.

That said, I can't recall why that's there at all. I believe it's just a performance optimization to assure webpack doesn't try to transpile anything outside of src, but really, the app's entry point dictates what gets transpiled so I suspect we can just remove that snippet.

@raythree
Copy link
Contributor Author

raythree commented Aug 5, 2016

Thanks, that seems to have done it. I replace the include with exclude:/node_modules/. Each of the common components needed the .babelrc and all was processed.

@coryhouse
Copy link
Owner

Excellent!

coryhouse added a commit that referenced this issue Aug 5, 2016
…les instead of including /src path. This resolves issue #224.
@coryhouse
Copy link
Owner

Just committed this change. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants