If I import foundation as
import {} from './node_modules/foundation-sites/dist/foundation.js';
only last _createClass helper definition stays, others gets removed. Problem is that every definition of _createClass helper is in their own iffe scope, so I am getting 'undefined' on _createClass helpers calls.
If I import foundation plugins one by one as
import {} from './node_modules/foundation-sites/dist/plugins/foundation.core.js';
import {} from './node_modules/foundation-sites/dist/plugins/foundation.abide.js';
import {} from './node_modules/foundation-sites/dist/plugins/foundation.orbit.js';
it works as expected, _createClass helpers gets namespacing and they are not removed.
rollup 0.31.0, no plugins
// main.js
var a = 1;
console.log(a);
var a = 1;
console.log(a);
// output.js
'use strict';
console.log(a);
var a = 1;
console.log(a);
This is proving surprisingly finicky to fix – I feel a bit of a refactoring coming on – but how does this general solution sound: in a situation like this, we simply drop the var from all but the first declaration, and treat subsequent ones as assignments instead (this is essentially what happens if you run the code).
var a = 1;
console.log(a);
a = 1;
console.log(a);
At the same time we should throw an error if a duplicate declaration is encountered and either the first or the second isn't a function or var declaration (since it's a syntax error to redeclare a let/const/class).
_Finally_ fixed in 0.35.0
Most helpful comment
_Finally_ fixed in 0.35.0