Rollup wants me to create global variables. How can I use 'export default'?
Rollup's error is completely 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';
mikemaccana
I help verify websites for EV HTTPS at CertSimple and have made a bunch of tech products in the past 20 years as a product manager, CTO, lead developer, systems engineer, and technical architect - see https://mikemaccana.com
Updated on July 11, 2022Comments
-
mikemaccana almost 2 years
I have a small app I am converting to use rollup. It uses ES6 modules - when I run
rollup -c
, it complains 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?