Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require/import behaviour is broken as of ^2.5 #5494

Closed
NathanChannon opened this issue May 2, 2020 · 10 comments
Closed

require/import behaviour is broken as of ^2.5 #5494

NathanChannon opened this issue May 2, 2020 · 10 comments

Comments

@NathanChannon
Copy link

Describe the bug
As of v2.5 the require behavior is broken, and functions fail to import.

Please see issue: #5484

To Reproduce
#5484 (comment)

Additional context
For those of us using packages where moment is a dependency, and they've referenced higher versions than exist, this will always break if you're doing a docker build as the package-lock.json's going to be overwritten even if checked in anyway, i.e.

"chart.js": {
      "version": "2.9.3",
      "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-2.9.3.tgz",
      "requires": {
        "chartjs-color": "^2.1.0",
        "moment": "^2.10.2"
      }
    },

And also:

"moment-timezone": {
      "version": "0.5.28",
      "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.28.tgz",
      "requires": {
        "moment": ">= 2.9.0"
      }
    },

I think this means you can't override their version settings (or my attempts have failed anyway) and it might mean some file system maniuplation which I really don't want to do.

I appreciate the problem may be amplified for container builds as other uses will revert to 2.4 but because of dependency versioning some people may be blocked.

Yarn's resolution feature would be a workaround but it's not a possibility to switch over without introducing a further 3 headaches (for me anyway)

@prooli22
Copy link

prooli22 commented May 2, 2020

Version ^2.25 maybe ? I'm experiencing the same issue. With the error : moment is not a function

@J1445
Copy link

J1445 commented May 2, 2020

Version ^2.25 maybe ? I'm experiencing the same issue. With the error : moment is not a function

It is fixed in 2.25.1

@lykhvar
Copy link

lykhvar commented May 2, 2020

Seems to be related to: #5489, #5472

@prooli22
Copy link

prooli22 commented May 2, 2020

I just updated to 2.25.1 and the error is still there, so I rolled back to 2.24.0 for now

@maksimgm
Copy link

maksimgm commented May 2, 2020

@prooli22 I ran into the same problem and rolled back to version 2.24.0 as well. It appears to me that the change is as follows:

Before version 2.25, moment was a function

After version 2.24, moment was an object with a default object which contains the version number. So the following error occurred: moment is not a function

@buffcode
Copy link

buffcode commented May 4, 2020

Upgrading to 2.25.2 with moment-timezone and bundling via Webpack brought me moment/moment-timezone#449 (moment is the import and only moment.default has the version field).

@marwahaha
Copy link
Member

Is this still an issue with 2.25.3 ?

@prooli22
Copy link

@marwahaha seems to be working fine with 2.25.3

@marwahaha
Copy link
Member

Please re-open if you still have issues.

@ca0v
Copy link

ca0v commented Oct 4, 2021

I'm having to introduce a moment adaptor to get round typings incompatibilities (or stupid user error):

import * as Moment from "Moment";

// https://github.com/moment/moment-timezone/issues/449
export const moment = (<any>Moment).default as typeof Moment;

I'm using Moment 2.29.1, Typescript 4.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants