Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

some issue using this in angular #29

Open
capaneus opened this issue May 29, 2018 · 5 comments
Open

some issue using this in angular #29

capaneus opened this issue May 29, 2018 · 5 comments

Comments

@capaneus
Copy link

capaneus commented May 29, 2018

hi,
when I try to use is in angular, it gives me warning:

WARNING in ./node_modules/moment-holiday/build/moment-holiday-us.min.js
10:53-60 Critical dependency: require function is used in a way in which dependencies cannot be statically e
xtracted
WARNING in ./node_modules/moment-holiday/build/moment-holiday-us.min.js
6:3284-3296 Critical dependency: the request of a dependency is an expression

and when it's loaded in browser:

Uncaught TypeError: Cannot read property 'fn' of undefined

I'm new to js and typescript, so couldn't figure out a way to fix it. so if anyone could take a look would be awesome.

what I did in code is to test some functions:

import * as holidays from 'moment-holiday';

this.locales = holidays.load('united_kingdome');

Thanks!

@Silthus
Copy link

Silthus commented Jun 4, 2018

Did you find a solution for this? I am having the same problem.

@lwensveen
Copy link

See this PR:

#31

You can use my fork like this:

    "moment-holiday": "https://github.com/lwensveen/moment-holiday.git#require",

@MartinLoeper
Copy link

Hi there, we at @nesto-software are currently open sourcing a new moment-holiday library which further improves this great approach by kodie. There is only a small number of supported countries yet. However if you want to check it out: https://github.com/nesto-software/moment-holiday/

For the frontend, there is an usage example.

@madthad91
Copy link

madthad91 commented Dec 5, 2018

Not super pretty, but this works in an angular cli project as such:

  1. add the following to the scripts array of your angular-cli.json file:

     "./node_modules/moment/min/moment.min.js",
     "./node_modules/moment-holiday/build/moment-holiday-us.min.js"
    
  2. In the file where you want to import moment-holiday, instead just add declare var moment: any; at the top of that file. Don't import moment or moment-holiday. Then use this library as normal: moment().holidaysBetween(<some_moment_object>)

EDIT: The reason why this is not too too bad, is that npmjs.com has runkit integration and you can test your code there: https://npm.runkit.com/moment-holiday

get it running, and just transfer the code to your main project

@codeunifier
Copy link

Still an issue - any update on this would be much appreciated.

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

No branches or pull requests

6 participants