I am having an issue with importing a module into a TypeScript file and then bundling it using Rollup.js.
After running tsc
without any errors, I encountered an error message when I tried to run:
$ rollup -c rollup.config.js
Illegal reassignment to import 'mapboxgl'
Error: Illegal reassignment to import 'mapboxgl'
...
Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
The problem seems to arise when this line is present:
(mapboxgl as any).accessToken = this.accessToken;
.
Here is how my rollup.config.js
file is configured:
export default {
moduleName: "mapbox.core",
entry: 'src/js/index.js',
format: 'umd',
dest: 'core/core.umd.js',
sourceMap: true,
globals: {
'mapbox-gl': 'mapboxgl'
}
};