Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Library is exposed as a CommonJS module.
What is the expected behavior?
Library is exposed as ES6 module.
Why do I want this behavior?
I only want to ship the raven-js library in the first few days after releasing a new feature. After that, I want to get rid of the 20KB raven-js library in order to improve the performance of my app.
In order to remove the 20KB raven-js library, I want to to use the webpack "es6-tree-shaking/uglify-js-dead-code-removal" feature.
import { Raven, RavenVue } from './es6/raven';
if (FLAGS.SENTRY_ENABLE) {
Raven.config(CONFIG.SENTRY_DSN).addPlugin(RavenVue, Vue).install();
}
This is only possible when using ES6 modules.
Any plans on converting to es modules? Would you accept a PR?
Thanks for you feedback!
I might add one improvement to the proposed solution:
If the source code is using es6 imports and exports it is possible to use the module
key in the package.json
to reference the es6 main entry point of the package { "module": "src/raven.js" }
. See: https://github.com/rollup/rollup/wiki/pkg.module
That way, the main
key can still reference a bundled, CommonJS compatible version of the package { "main": "dist/raven.js" }
but people who are using tools like webpack or rollup can import them the usual way import Raven from 'raven-js'
which is automatically resolved to the ES6 version of the file.
It's definitely something that I want to do soon.
However, it'd require us to most likely migrate to webpack/rollup and make sure that bundle we provide still doesn't exceed our 10kb budget.
I cannot say when it'll be shipped though, as there are some other things that I'm working on right now as well.
@kamilogorek I always wanted to do a build setup with rollup.js. So I took some time and changed the build from Browserify to Rollup with Babel: #1152
This is the first step needed in order to convert the source to ES modules.
Would be cool if you could review this PR. :octocat:
Most helpful comment
It's definitely something that I want to do soon.
However, it'd require us to most likely migrate to webpack/rollup and make sure that bundle we provide still doesn't exceed our 10kb budget.
I cannot say when it'll be shipped though, as there are some other things that I'm working on right now as well.