Closed ShGKme closed 7 months ago
A fix on @nextcloud/moment
side could be better, cc @susnux if you have any ideas.
How would you fix it? The problem is that we otherwise need to import every local in @nextcloud/moment
manually.
How would you fix it? The problem is that we otherwise need to import every local in
@nextcloud/moment
manually.
I dunno, that is why I mentioned you =D
I didn't dig much into what happens in @nextcloud/moment
and what/why was changed during the migration to Vite. The source issue is in the moment
itself. That require
is not correct in the moment
's source, and it is so a classic issue that Webpack docs show the fix as an example of the IgnorePlugin
usage. So we can fix it on the Webpack config side, but the fix on @nextcloud/moment
seems less breaking.
Probably, import.glob
in Vite + manual locales registration may work.
Anyway, I'm fine with merging this PR to fix the problem as well.
Probably,
import.glob
in Vite + manual locales registration may work.
This does only work with local imports not with modules :no_mouth:
Fixes compatibility between
@nextcloud/webpack-vue-config
and@nextcloud/moment@1.3.0
(since migration to Vite).@nextcloud/moment
usesmoment/min/moment-with-locales.js
, which works only in Node.js and is not compatible with Webpack bundling. It has an unused functionlocalLocale
that requires locales by invalid relative path./locale
. Though it is not used, Webpack tries to resolve it withrequire.context
and fails.Example of issue in Talk, same in Text and other apps:
See also:
@nextcloud/moment
: https://github.com/nextcloud-libraries/nextcloud-moment/blob/c73f43f7e7713a92bad98251aad22b3cd57a757e/lib/index.ts#L1moment/min/moment-with-locales.js
: https://github.com/moment/moment/blob/develop/min/moment-with-locales.js#L2159