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 moment without locales nor hacks #4155

Closed
aldo-roman opened this issue Sep 1, 2017 · 17 comments
Closed

require moment without locales nor hacks #4155

aldo-roman opened this issue Sep 1, 2017 · 17 comments

Comments

@aldo-roman
Copy link

aldo-roman commented Sep 1, 2017

Description of the Issue and Steps to Reproduce:
I am using moment in a webpack build.

It looks like require('moment') is the equivalent of using moment-with-locales.min.js from CDN (judging mainly by the size increase in my bundle).

Is there a way to require moment with only the default english locale? (i.e. the equivalen of moment.min.js from CDN).

I guess my question is related to #2373 #2416

PLEASE do not suggest removing locales with the Webpack Ignore plugin (or similar hack) BECAUSE I CAN NOT.

We are using Angular CLI which does not support modifyng the pipeline.

We need to make all locales opt-in

Environment:
Angular CLI, Node 8

@TheLarkInn
Copy link

@aldo-roman:

Hi Sean from webpack

  • It is not a suggestion to do so. It is the only way to do so if you are going to consume momentjs with webpack in it's current module format.

  • If you want another solution, then submit a PR rewriting moment js from AMD to ESM module format. Or perhaps even contribute a design specification for rearchitecture. The point is that what you've submitted is not actionable.

Moment has no control over whether or not you have the ability to configure webpack. So I'd strongly encourage that if you really love moment and want to use it, that you chip in to push it forward <3.

@TheLarkInn
Copy link

Moment team: I fully endorse closing this issue.

@maggiepint
Copy link
Member

Well, that covers it then.

@mattjohnsonpint
Copy link
Contributor

Thanks @TheLarkInn. Also, WRT:

We are using Angular CLI which does not support modifyng the pipeline.

I don't know much about this, but that sounds like something to take up with the Angular CLI project. I doubt using the WebPack Ignore plugin to ignore Moment's locales is the only reason one would want to "modify the pipeline".

@aldo-roman
Copy link
Author

aldo-roman commented Sep 1, 2017 via email

@TheLarkInn
Copy link

I wouldn't go as far to say this library is abandoned. Especially considering the prompt replies you've seen.

Potentially I could convince you to submit an issue for discussion of moving to es modules (if doesn't already exist).🙇🙇

@ovangle
Copy link
Contributor

ovangle commented Sep 3, 2017

@TheLarkInn
I attempted to make some changes which would make moment more modular recently recently. The issue tracker on this project is still active, but I couldn't actually motivate anyone to review the changes so I gave up and moved on.

There are open issues regarding modularisation -- I opened them myself and as far as I know none of them have been closed.

@aldo-roman
You should treat people who are maintaining libraries like this with more respect. They're volunteering their time to do this and they don't owe you anything. When you're writing an issue, you should ask for changes, don't demand them.

@maggiepint
Copy link
Member

@ovangle - where did your module branch go? I can find a TS change branch you closed. I have nothing concretely scheduled in my life today, so if we want to get some modules moving, it can probably be done.

@maggiepint
Copy link
Member

Also, if people are wondering, @mj1856 and I have basically redirected our open source time to getting a decent standard library for Date in JavaScript. See tc39/temporal-proposal, and https://github.com/maggiepint/temporal-shim . Since this involves days of travel to get to TC39 committee meetings for me, I'm not able to also spend a bunch of time running down moment issues. Hopefully though, the end result is better for everyone.

I would welcome conscientious help on the shim and spec.

@ovangle
Copy link
Contributor

ovangle commented Sep 4, 2017

The TS change branch is the one I was referring to -- it doesn't actually include the module changes (because it made sense to merge 2.x before starting on that work, rather than having to do it twice), but the ts changes are mainly related to declaring areas of functionality which form the basis of the split.

The main thing I was eager to get merged was the transpilation changes I did, they cut down the amount of time it takes to run unit tests significantly, which would have been good during the merge.

I'm not all that enthusiastic about resuming working on it though. My personal projects don't actually use moment anymore and I've got a PR to switch dependencies at work that's almost ready for merge. If I continued working on it, I'd be investing a lot of my time into a dependency that I don't actually use.

@ovangle
Copy link
Contributor

ovangle commented Sep 4, 2017

ps. I'm sorry for disappearing without saying anything, but I was unsure of what I should have actually said. As I noted, you are all volunteering your time and I didn't want to rush you, but I also couldn't justify the time it was taking to get even small uncontroversial changes merged (let alone the more ambitious changes I was going to make) when there are already projects available which satisfy all my needs from a date library without the bundling problems that moment has.

@maggiepint
Copy link
Member

@ovangle - we're not upset. This has been a major sticking point for all of us. Unfortunately, Moment gets into this critical mass place where everything you do, no matter what it is, even if it should seem like an obvious 'fix', upsets someone. It makes us more change resistant than we should be. Not to beat a dead horse, but that's why the temporal proposal. Might as well fix it for good, forever right?

@elie222
Copy link

elie222 commented Sep 9, 2017

I also just ran into this issue. We're using moment with Meteor. And only in English. Is there an easy way to remove locales?

@taykcrane
Copy link

@aldo-roman I fixed this issue by just downgrading moment from 2.19.0 to 2.17.1.

@felipefialho
Copy link

Some here, I use angular-cli and I need to load just moment + locale/pt-br

@dmitry-kostin
Copy link

can't believe this is still not resolved, problem described more than 1.5 years ago on different repos & issues

@gtsopour
Copy link

Is it possible that I am excluding all the moment dependency?

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

10 participants