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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point main back to es5 version #259

Closed
wants to merge 1 commit into from

Conversation

mattlewis92
Copy link
Contributor

Version 2.3.x now points to ES6 sources which is a breaking change, as when we upgraded rrule in our app it broke IE11 support as it doesn't support ES6 classes. Also removed the module field because the es6 source isn't transpiled to es2015 modules / it's standard for the module field to point to ES5 transpiled code + es2015 modules. Let me know if you need any more info and thanks for all the work you're doing on this package! 馃憤

Copy link
Collaborator

@davidgoli davidgoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ideal point of reference would be another widely-used library, luxon does the following:

  "main": "build/node/luxon.js",
  "module": "src/luxon.js",
  "browser": "build/cjs-browser/luxon.js",

where "main" points to node-compiled es5, "module" points to es6, and "browser" points to commonjs es5. We should conform to that and continue pointing to es6 in at least "module" as it's much more ergonomic for eg. use in Node environments or environments using transpilation (for instance, tree-shaking is possible with es6 imports and debug sourcemaps are that much closer to the original source code).

@mattlewis92
Copy link
Contributor Author

Following that spec would still be a breaking change though - my use case is I'm using this package in an angular app with the CLI over which I have no control over how it resolves dependencies. It would always choose the module entry point over the browser field and still break in older browsers. I believe luxon points module to the es2015 source as it requires modern browser apis that simply aren't available in older browsers anyway.

@davidgoli
Copy link
Collaborator

@mattlewis92 I would support this change if it only changed main to point to es5. module was not supported before 2.3.x and is thus an addition. If your Angular CLI chooses module when it cannot interpret es modules, then that seems like a bug in Angular CLI. How does that sound?

@mattlewis92
Copy link
Contributor Author

The angular CLI can interpret ES modules (as they can compiled away by webpack), but any other es2015 syntax e.g. class, const etc is left alone, hence adding the module entry point pointing to full es2015 source code is a breaking change. Also the es2015 modules are actually getting transpiled to commonjs anyway: https://unpkg.com/rrule@2.3.5/dist/es6/index.js

For more info about the module field see here:
https://github.com/rollup/rollup/wiki/pkg.module
webpack/webpack#1979 (comment)

@davidgoli
Copy link
Collaborator

@mattlewis92 ok, thanks for the sleuthing! sounds like we need to reconfigure the transpilation to output ES modules but not other ES6 features, then we can point the es2015 key at the es6 output and otherwise point to es5. How about that?

@mattlewis92
Copy link
Contributor Author

Sure, here you go: #260

@mattlewis92 mattlewis92 deleted the patch-1 branch August 14, 2018 21:53
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

Successfully merging this pull request may close these issues.

None yet

2 participants