-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Errors when updating. Webpack related #792
Comments
Any reproduction repo, please? |
It happens when using
That is, with a variable. Example:
then change main.js to
|
Due to this bug: iamkun/dayjs#792
Any update on this? I got this error too when dynamically importing locales. |
@munkhorgil Any reproduction repo, please? |
https://github.com/erxes/erxes in widget we use the dayjs |
thanks, @munkhorgil, nice project. However, it is hard for me to debug this issue in this huge repo. Can you please provide an issue reproduction repo containing this issue only, if you have time. Cheers |
Thanks, in order to reproduce you don’t need to install the whole project.
|
@developdeez @mariusa @iamkun I think the key point is And @munkhorgil , I didn't find |
Had this issue minutes ago and my current workaround (based on my needs) is to dynamically import each lang, based on the specified locale. type Locale = 'en-US' | 'fr-FR';
export const importDayJSLang = (locale: Locale) => {
const lang = locale.split('-')[0];
if (locale === 'en-US')
return import(`dayjs/locale/en`).then(() => {
dayjs.locale(lang);
return lang;
});
else if (locale === 'fr-FR')
return import(`dayjs/locale/fr`).then(() => {
dayjs.locale(lang);
return lang;
});
else return Promise.resolve(lang);
}; A refactoring is of course possible, but I pasted it as it to give an idea. |
@JounQin solves the problem. Thank you. |
From iamkun/dayjs#792 (comment) Looks like webpack is trying to package everything, so we need to explicitly tell it that we want just the JS files.
Thanks |
I haven't had this error until I updated. What loader do I use with dayjs now?
WARNING in ./node_modules/dayjs/locale/types.d.ts 1:8
Module parse failed: Unexpected token (1:8)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
The text was updated successfully, but these errors were encountered: