vue-datetime
vue-datetime copied to clipboard
Webpack warning: Optional 'weekstart' can't resolve
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?
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?
same issue here, thanks
No fix for this yet??
I had the same problem. Fixed installing weekstart.
npm i weekstart
Hope this helps.