Trying to use ImmutableJS with Rollup as an es6 import. I have the Rollup plugin for CommonJS, which I've used for other CommonJS modules, no problem. However, when I try to incorporate ImmutableJS into a project, it doesn't get imported. I would expect to do something like this:
However, when I build, I get the following error in the terminal:
node_modules/immutable/dist/immutable.js (10:3) The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
[10:04:04] 'build' errored after 2.93 s
[10:04:04] Error: 'List' is not exported by node_modules/immutable/dist/immutable.js
By the way, I had previously scoured the internet for other CommonJS issues with Rollup and tried various configurations, including ones that have previously worked for me. But non of these seem to work for ImmutableJS.
Note: I discovered that you do provide an ES6 compatible version if I download the source code and build locally. Then I can copy that into my project and import it as a normal es6 module:
import {List} from './utils/immutable.es'
Why isn't this included in the default install? It would be practical, I would think, to enable ImmutableJS to be installed and imported like a normal es6 module with Rollup without having to build it and then copying the es6 version manually. That just feels like Stone Age.
From @rbiggs on Fri, 10 Nov 2017 18:16:48 GMT
What happened
Trying to use ImmutableJS with Rollup as an es6 import. I have the Rollup plugin for CommonJS, which I've used for other CommonJS modules, no problem. However, when I try to incorporate ImmutableJS into a project, it doesn't get imported. I would expect to do something like this:
Then in my
app.js
file, import it like so:I have Rollup configured like this:
However, when I build, I get the following error in the terminal:
By the way, I had previously scoured the internet for other CommonJS issues with Rollup and tried various configurations, including ones that have previously worked for me. But non of these seem to work for ImmutableJS.
Note: I discovered that you do provide an ES6 compatible version if I download the source code and build locally. Then I can copy that into my project and import it as a normal es6 module:
Why isn't this included in the default install? It would be practical, I would think, to enable ImmutableJS to be installed and imported like a normal es6 module with Rollup without having to build it and then copying the es6 version manually. That just feels like Stone Age.
Copied from original issue: https://github.com/immutable-js/immutable-js/issues/1440