Numeral-js: Numeral can't be imported as an ES2015 modules

Created on 9 Nov 2017  路  1Comment  路  Source: adamwdraper/Numeral-js

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).)

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonathanbergson picture jonathanbergson  路  6Comments

meafmira picture meafmira  路  8Comments

tab00 picture tab00  路  8Comments

kinguru picture kinguru  路  6Comments

rogerfar picture rogerfar  路  8Comments