-
Notifications
You must be signed in to change notification settings - Fork 6
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-register causing build issues #64
Comments
We "fixed" it for ourselves by adding something like this to the webpack config: alias['json-truncate'] = path.resolve(
__dirname,
'node_modules/json-truncate/dist/json-truncate.js'
); But it would be nice if we could avoid doing it. :) |
Actually, adding the following was even better / more generic: 'json-truncate': 'json-truncate/dist/json-truncate.js' Thanks for this lib btw 👌 |
@ZeeCoder do you have some recommendations on what might work for your scenario? Maybe a PR that I could reference to see what you had in mind? |
I would just remove everything in index apart from pulling in the dist/ build. Essentially that's why I added the extra resolution field to avoid that require statement altogether. |
@ZeeCoder Its there for local testing.I believe it to be only a dev dependency so shouldn't be used. Since you are using the browser CDN, I think we would need to either checkin the dist file (which I'm not a fan of), we write this library with browser compatibility in mind (I "may" be a fan of this, not sure...) or you load it with a babel-register client-side somehow to interpret some of the es2015 syntax. I only have light opinions at the moment but would be interested in what you could come up with. You are using this library outside of its original intent so since you are pioneering here I'd be interested in what your thoughts are. |
I'm not using a CDN at all, sorry for the misunderstanding 😅 I'm using webpack to compile to the browser. So when I do that, naturally the index.js gets pulled in, with the "dev dependency", which is babel-register, and all that gets bundled in. Your lib I think is already quite browser-compatible, if node_modules are compiled as well. I would simply recommend adding a watch mode for the project for development, so then the index.js file could be simplified to simply require the dist file. |
@ZeeCoder I think that |
It works differently when you bundle things with webpack instead of running this through Node. webpack won't ignore that require, but instead try to bundle it with the rest of the code, as it's not smart enough to know it won't execute. |
@mrsteele okay so I did some further digging in what you might be using babel here for. Anything above Node v6 results in an identical build where Babel doesn't do anything, apart from changing the es6 default export to module.exports. To me it seems like having babel at all is unnecessary, especially considering that it only complicates development. (Hence why there's babel-register to make it easier, instead of adding a watch mode.) So my new recommendation is then to drop Babel, and simply use Pros:
Cons:
Keen on your thoughts @mrsteele ! 🙌 (I'm more than happy to produce an MR if you'd like. 👌 ) |
@ZeeCoder Yeah go ahead with the PR, i'd be interested to see this finalized! |
@mrsteele just pushed some further updates to the PR. |
We've been using this lib on the web, and realised that when the index.js goes through webpack, it builds in babel-register.
we haven't noticed this until it also started failing the build due to a mismatch in core-js, which is a dependency of babel-register.
I guess my question is what your reasons are for publishing the library this way, when you already have the built dist/ in there?
The text was updated successfully, but these errors were encountered: