Moment: require moment without locales nor hacks

Created on 1 Sep 2017  ·  17Comments  ·  Source: moment/moment

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

Most helpful comment

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

All 17 comments

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

Moment team: I fully endorse closing this issue.

Well, that covers it then.

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

Well, I suspected this was about the answer I would get, but there was nothing to lose with trying.

At least there could be a plan on refactoring momentjs to es6 modules. Sad to see this library is abandoned. Not submitting a PR at the time.

On Sep 1, 2017, at 1:09 PM, Matt Johnson notifications@github.com wrote:

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


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

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

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

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

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.

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.

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.

@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?

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?

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

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

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

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

Was this page helpful?
0 / 5 - 0 ratings