luxon
luxon copied to clipboard
Minified es6/luxon.min.js throws 'not a function or not iterable' for valid fromISO()
Describe the bug
- Consume https://moment.github.io/luxon/es6/luxon.min.js somewhere
- Run
DateTime.fromISO('2019-01-01T05:00:00.000') - Observe error:
TypeError: n is not a function or its return value is not iterable
Note that this runs perfectly fine with the non-minified es6 version.
To Reproduce Please share a minimal code example that triggers the problem:
import { DateTime } from 'https://moment.github.io/luxon/es6/luxon.min.js';
console.log(DateTime.fromISO('2019-01-01T05:00:00.000'));
Actual vs Expected behavior
- Ensure behaviour is consistent between minified and non-minified version.
- Ensure no error is thrown on valid fromISO formats (although in this case caused by the minifier).
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser: Chrome 103
- Luxon version: latest
- Your timezone: Europe/Zurich
Additional context Add any other context about the problem here.
Yeah, must be something up with the minifier
In case you did want to switch back to Terser, I noticed a typo at: https://github.com/moment/luxon/blob/4fe7be9d5afa7afdf36b4bb9ad116d160c0881f5/tasks/build.js#L55
topLevel -> toplevel
https://terser.org/docs/api-reference#mangle-options
Hi @icambron, can I take up this issue?
It might be worth investing whether microbundle is a viable option.
If we do go down the route of adding yet another place where the version string lives, let's be sure to update the release script to check that this additional location is the same as the others. There is already tooling to check that the version in the code matches the one in package.json.