Moment-timezone: the published version is incompatible w/ moment 2.19.0's module format

Created on 10 Oct 2017  路  3Comments  路  Source: moment/moment-timezone

When importing as an ES module, the umd wrapper fails to account for the possible 'default' export name of moment.js (2.19 added the 'module' property to the package.json, and webpack follows it instead of main.)

Most helpful comment

on moment-timezone.js#L14:

module.exports = factory(require('moment')); // Node

should add an interop function call between factory() and the return of require()

something like:

function interop (x) {
    return x && x.default || x;
}

module.exports = factory(interop(require('moment'))); // Node

All 3 comments

on moment-timezone.js#L14:

module.exports = factory(require('moment')); // Node

should add an interop function call between factory() and the return of require()

something like:

function interop (x) {
    return x && x.default || x;
}

module.exports = factory(interop(require('moment'))); // Node

This was fixed automatically with the change in 2.19.1. See also #541

Just clarifying... it does work now... however:

rollup and webpack (with mainFields set to look at esnext:main along with module, and main) will still hit this issue. If moment.js adds the module field back we will hit this problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garryyao picture garryyao  路  4Comments

jishaal picture jishaal  路  6Comments

nodesocket picture nodesocket  路  4Comments

casper5822 picture casper5822  路  5Comments

Liero picture Liero  路  4Comments