I have a small app I am converting to use rollup. It uses ES6 modules - when I run rollup -c
, it plains about one of my ES6 modules:
/js/monogram.js (imported by src\main.js)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
/js/monogram.js (guessing 'drawMonogram')
created public\js\bundle.js in 311ms
The module monogram.js
uses:
export default drawMonogram
I am importing it with:
import drawMonogram from '/js/monogram.js';
Both of these worked before rollup
. Is this now not OK?
Should I actually make output.globals
to specify a global name?
Why do I need a global variable? Is the global requirement from ES6 modules (I'd have thought modules would be in a functional scope) or rollup?
I have a small app I am converting to use rollup. It uses ES6 modules - when I run rollup -c
, it plains about one of my ES6 modules:
/js/monogram.js (imported by src\main.js)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
/js/monogram.js (guessing 'drawMonogram')
created public\js\bundle.js in 311ms
The module monogram.js
uses:
export default drawMonogram
I am importing it with:
import drawMonogram from '/js/monogram.js';
Both of these worked before rollup
. Is this now not OK?
Should I actually make output.globals
to specify a global name?
Why do I need a global variable? Is the global requirement from ES6 modules (I'd have thought modules would be in a functional scope) or rollup?
Share Improve this question edited Apr 21, 2021 at 8:49 mikemaccana asked Jul 17, 2018 at 21:37 mikemaccanamikemaccana 123k110 gold badges428 silver badges531 bronze badges1 Answer
Reset to default 13Rollup's error is pletely unrelated to the problem. It's simply not able to import the module at that path. Using ES6 modules in browser,
import drawMonogram from '/js/monogram.js';
Was relative to the web server root. However using rollup
on the developmnt box,
import drawMonogram from '/js/monogram.js';
is considered relative to / on the hard disk. Using a relative import fixed the errror.
import drawMonogram from './monogram.js';