Closed albandum closed 1 year ago
I have the problem too
go to node_modules/i18n-js/dist/import/Pluralization.js
and replace the code with the following code:
// import { en } from "make-plural";
export function useMakePlural({ pluralizer, includeZero = true, ordinal = false, }) {
return function (_i18n, count) {
return [
includeZero && count === 0 ? "zero" : "",
pluralizer(count, ordinal),
].filter(Boolean);
};
}
export const defaultPluralizer = useMakePlural({
pluralizer: (n: number | string, ord?: boolean) => "one" | "two" | "few" | "other",
includeZero: true,
});
export class Pluralization {
constructor(i18n) {
this.i18n = i18n;
this.registry = {};
this.register("default", defaultPluralizer);
}
register(locale, pluralizer) {
this.registry[locale] = pluralizer;
}
get(locale) {
return (this.registry[locale] ||
this.registry[this.i18n.locale] ||
this.registry["default"]);
}
}
//# sourceMappingURL=Pluralization.js.map
it silent the error temporarily
Any final solution on this?
make-plural
relies on support for resolving .mjs
extensions, which Metro supports by default but it looks like Expo overrides.
@EvanBacon / @byCedric - .mjs
(and .cjs
) support is implemented through watcher.additionalExts
(here's why), and it seems Expo overrides that to watch env
files - with a fresh create-expo-app
project I see Metro is being passed:
additionalExts: [ 'env.development.local', 'env.local', 'env.development', 'env' ],
This is overriding Metro's default, so that .mjs
and .cjs
files aren't crawled or watched:
https://github.com/facebook/metro/blob/c2d7539dfc10aacb2f99fcc2f268a3b53e867a90/packages/metro-config/src/defaults/defaults.js#L58
Could Expo add to Metro's defaults instead?
Add config.watcher.additionalExts.push('mjs', 'cjs');
to your metro.config.js
, ie:
// metro.config.js - see https://docs.expo.dev/guides/customizing-metro/#customizing
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
config.watcher.additionalExts.push('mjs', 'cjs');
module.exports = config;
Closing as this issue is specific to Expo's configuration overrides (see above) and needs to be fixed there.
Following @robhogan 's tip, I replaced the code of metro-config.js: module.exports = require('@expo/metro-config'); to the code shown above. However I still get the same error. Should I place it in the ts file as well?
Bug
What is the current behavior?
Upgrading to Expo SDK 49 makes i18n-js fail.
Basically the same thing that was mentionned here but the issue is closed
Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.
Yarn v1.22.15 ProductName: macOS ProductVersion: 12.2.1