vue-datetime icon indicating copy to clipboard operation
vue-datetime copied to clipboard

Webpack warning: Optional 'weekstart' can't resolve

Open cd opened this issue 6 years ago • 4 comments

Versions

  • vue: 2.5.17
  • vue-datetime: 1.0.0-beta.8
  • luxon: 1.8.1

Description:

I installed (via npm) vue-datetime and luxon without weekstart, because I don't need it. Unfortunately, when I build my vue project with webpack (using vue-cli), it throws a warning:

WARNING  Compiled with 1 warnings                                                                                                                    
warning  in ./node_modules/vue-datetime/dist/vue-datetime.js
Module not found: Error: Can't resolve 'weekstart' in ...

I think the weekStart function in vue-datetime.js will cause the warning, because it tries to require weekstart in line 153:

try {
  weekstart = require('weekstart');
} catch (e) {
  weekstart = window.weekstart;
}

How can I get rid of the warning? Maybe it is a webpack issue, but maybe this can be solved in a better way?

cd avatar Nov 27 '18 10:11 cd

This is because the weekStart method is called 6 times when the component is created, and one of this weekstart get an empty object value. To solve this problem I do this in my fork

try {
  weekstart = require('weekstart/package.json').version ? require('weekstart') : null
} catch (e) {
  weekstart = window.weekstart
}

I don't know if that solution is the best one. What do you think Mario?

adnumaro avatar Jan 13 '19 18:01 adnumaro

same issue here, thanks

j574144 avatar Jun 02 '19 03:06 j574144

No fix for this yet??

JJBocanegra avatar Aug 08 '19 07:08 JJBocanegra

I had the same problem. Fixed installing weekstart.

npm i weekstart

Hope this helps.

victormarques-docway avatar Sep 09 '19 13:09 victormarques-docway