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

getmac fails on webpack as webpack doesn't support editions #43

Closed
eric-burel opened this issue Jan 10, 2019 · 6 comments
Closed

getmac fails on webpack as webpack doesn't support editions #43

eric-burel opened this issue Jan 10, 2019 · 6 comments

Comments

@eric-burel
Copy link

Hi, this package does not seem to be compatible with Webpack (server-side) due to the use of bevry/editions.

I quickfixed this by creating: https://github.com/lbke/getmac-webpack (simply a copy of the relevant source files).

To precise my use case, my Node server needs to be deployed on-premise, but I don't want to send the source as-is to the clients, so I rely on Webpack to build/minify the code the most I can.

I understand that you may not want/have time to fix this as editions seems to be a basis for multiple packages and my use case is not common, I just wanted to provide a quick alternative for Webpack user.

@balupton
Copy link
Member

balupton commented Jan 10, 2019

Ideally we would have webpack and rollup plugins for the editions format, so that any package that has the editions format, people can then elect via a list of preferred tags which edition should be used instead. This would automatically support all editioned packages, and allow consumer bundles to have the most optimum code possible.

So users of typescript could elect the preferred tags like ["typescript", "esnext", "es2015", "es5", "javascript"]. So that the plugin would check all packages for the editions package.json field, if it exists, then it will cycle through the editions, and look for a typescript one, if not found, it will cycle through them again and look for a esnext one, and so on, if none are found error to the user with their options which will be the tags and description for each edition.

I have no experience writing webpack or rollup plugins, but from my evaluation that should be possible. So I am not the right person to do it. And as Bevry earns no money and I earn no money from programming I have no funds to hire anyone else to do it.

Considering the amount of installs the editions autoloader gets, a few million a month, it would be good to see his happen though.

@balupton
Copy link
Member

balupton commented Jan 10, 2019

However, it seems your package is just a copy of one of the compiled editions. You could modify your source to point to the specific edition entry point, or use a bundler package alias that aliases getmac to getmac/preferrededition/theentry.js, to work around this issue. This is a benefit of the editions and projectz combo, it makes clear the editions and their entry points in the readme.

@balupton
Copy link
Member

So as an alternative to a webpack/rollup/parcel/whatever/bundler plugin, we could update projectz to provide the webpack/rollup/whatever instructions on how to alias the package to the specific edition.

@balupton
Copy link
Member

For the use case, of bundle to one file with zero other transformations, zeit's ncc package from my testing works fine with editioned packages. Not sure how it does the magic, but it seems to work quite well.

Not sure if it works with getmac though.

@eric-burel
Copy link
Author

Hi, thanks for your detailed answers. For the record, I am smarter this evening than this morning, as I now understand how to handle webpack server side. Basically I should not have bundled the node_modules in the first place, as explained here: https://jlongster.com/Backend-Apps-with-Webpack--Part-I.

Thanks again for your reactivity. I am not much familiar with writing npm packages and editions, but I hope you'll find support for this. I'll close this issue as there are satisfying workarounds.

@balupton
Copy link
Member

balupton commented May 8, 2019

To be clear, the issue is not ours. The issue is with whatever bundler is being used. The bundler must add support for the editions format. Details here: bevry/editions#24

@balupton balupton closed this as completed May 8, 2019
@balupton balupton changed the title Compatibility with Webpack - Server Side getmac fails on webpack as webpack doesn't support editions May 8, 2019
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