bjyoungblood / es6-error

Easily-extendable error for use with ES6 classes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jsnext:main usage

bjyoungblood opened this issue · comments

See #22 (and #23) for background.

I'm not currently using Rollup myself, so I'm not 100% sure how jsnext:main is supposed to work.

For a single-file module, it seems like the ES module syntax won't really provide any benefit (no need for tree-shaking as there is no tree to shake). If we just removed jsnext:main, would Rollup work properly?

Alternatively, it sounds like we could create a second build that does not use the add-module-exports Babel plugin and point jsnext:main to that.

Since this module is so simple, it is true that users of Rollup could use the commonjs plugin to resolve the exported class.

I think that there is still some value in providing jsnext:main - as it gains traction I think we'll start to see more tooling (and hopefully runtime support) for ES6 modules. It's also a nice convenience not to have to shim rollup configurations, even if the module is not too hard to shim.

If you're willing to run a secondary build & distribute an additional index.jsnext.js then I'd be happy to tackle getting the build set up.

This was easier to achieve than I expected. See the PR for more info.

Published v4.0.0

Does this actually contain any breaking changes? I might be missing something, but it doesn't look like it.

Well, it really depends on how you're using the library.

If your build process is dependent on the format of the jsnext:main files, this change could break your build since the file can no longer be parsed by Node.

On the other hand, if you're not making use of the jsnext:main functionality at all, this shouldn't have any visible effect on your project.

@delta62 Thanks for the explanation. I'm just using main, so should be all good.