Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Any tips on how to use with rollup for es2015 tree-shaking? #237

Closed
RoxKilly opened this issue Oct 8, 2016 · 1 comment
Closed

Any tips on how to use with rollup for es2015 tree-shaking? #237

RoxKilly opened this issue Oct 8, 2016 · 1 comment

Comments

@RoxKilly
Copy link

RoxKilly commented Oct 8, 2016

My Angular 2 app coded in typescript 2 uses this polyfill. I have set module:"es2015" in tsconfig.json to allow for tree-shaking using Rollup.js as recommended by Angular

When I run the app in the browser, I get the error

global is not defined

I have tried using rollup-plugin-commonjs to convert the library to es2015

rollup.config.js

plugins: [
        nodeResolve({jsnext: true, module: true}),
        commonjs({
            include: 'node_modules/intl/**/*',
        })
]

When I run the app in the browser, I get the error:

IntlPolyfill is not defined

On a line like:

IntlPolyfill.__addLocaleData({locale:"en-US",...});

I noticed here that the library is written in es6 so it should be compatible with rollup. Any tips on how to use this library as es6 modules?

@caridy
Copy link
Collaborator

caridy commented Oct 10, 2016

We intentionally don't expose the ES6 source to be used via rollup because this is a polyfill, and bundling polyfills with the rest of your app is not what we recommend.

As for the actually issue described here, this is a dupe of #218, for which we don't have a fix yet, but a workaround is possible.

@caridy caridy closed this as completed Oct 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants