I am trying to import a module into typescript file and then link to Rollup.js.
But I get an error message that does not allow to complete the collapse.
Import:
import * as mapboxgl from 'mapbox-gl'; (mapboxgl as any).accessToken = this.accessToken; this.map = new mapbox.Map({...});
When I run tsc , there are no error messages, but then when I run:
$ rollup -c rollup.config.js Illegal reassignment to import 'mapboxgl' Error: Illegal reassignment to import 'mapboxgl' at error (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\utils\error.js:2:14) at disallowIllegalReassignment (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\shared\disallowIllegalReassignment.js:9:4) at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\AssignmentExpression.js:12:3) at C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:34 at Node.eachChild (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:21:5) at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:8) at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\BlockStatement.js:8:9) at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\FunctionExpression.js:7:13) at C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:34 at Node.eachChild (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:21:5) Type rollup --help for help, or visit https://github.com/rollup/rollup/wiki
I narrowed that the error only occurs when (mapboxgl as any).accessToken = this.accessToken; .
My rollup.config.js looks like this:
export default { moduleName: "mapbox.core", entry: 'src/js/index.js', format: 'umd', dest: 'core/core.umd.js', sourceMap: true, globals: { 'mapbox-gl': 'mapboxgl' } };
source share