Hello! I'm attempting to import numeral.js with an ES2015 (ES6) import statement and I'm running into trouble. In this particular use case, I'm not transpiling the import to cjs/amd/etc; the import is being handled by the browser.
index.html
<script type="module" src="app.js"></script>
app.js
import numeral from './numeral.js';
Result in Chrome: Uncaught SyntaxError: The requested module does not provide an export named 'default'
Result in Firefox: SyntaxError: import not found: default
ES6 modules can't be added to a UMD block (unfortunate, but also by design), so I'm working on a PR that creates a separate file, numeral.es6.js, which will be generated by grunt build, and has all the same code as numeral.js but without the IIFE/UMD wrapper, and with export default numeral at the end.
(<script type="module"> is supported in Chrome, Safari, and Edge and is behind a flag in Firefox and Opera (hopefully going mainline soon).)
The new file, numeral.es6.js looks like this: https://github.com/mwcz/Numeral-js/blob/enable-es2015-import/numeral.es6.js
Most helpful comment
The new file,
numeral.es6.jslooks like this: https://github.com/mwcz/Numeral-js/blob/enable-es2015-import/numeral.es6.js