diff --git a/.flowconfig b/.flowconfig index f13aba810a..0a37806b90 100644 --- a/.flowconfig +++ b/.flowconfig @@ -22,7 +22,6 @@ sharedmemory.heap_size=3221225472 module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=app -module.ignore_non_literal_requires=true module.name_mapper='^\(.*\)\.md$' -> 'empty/object' module.name_mapper='^shared\/\(.*\)$' -> '/shared/\1' diff --git a/app/components/LocaleTime.js b/app/components/LocaleTime.js index de0c1e18db..6996bd5806 100644 --- a/app/components/LocaleTime.js +++ b/app/components/LocaleTime.js @@ -4,20 +4,17 @@ import * as React from "react"; import Tooltip from "components/Tooltip"; import useUserLocale from "hooks/useUserLocale"; -const getLocale = (locale: string) => - require(`date-fns/locale/${locale}/index.js`); - const locales = { - en_US: "en-US", - de_DE: "de", - es_ES: "es", - fr_FR: "fr", - it_IT: "it", - ko_KR: "ko", - pt_BR: "pt-BR", - pt_PT: "pt", - zh_CN: "zh-CN", - ru_RU: "ru", + en_US: require(`date-fns/locale/en-US`), + de_DE: require(`date-fns/locale/de`), + es_ES: require(`date-fns/locale/es`), + fr_FR: require(`date-fns/locale/fr`), + it_IT: require(`date-fns/locale/it`), + ko_KR: require(`date-fns/locale/ko`), + pt_BR: require(`date-fns/locale/pt-BR`), + pt_PT: require(`date-fns/locale/pt`), + zh_CN: require(`date-fns/locale/zh-CN`), + ru_RU: require(`date-fns/locale/ru`), }; let callbacks = []; @@ -36,12 +33,6 @@ function eachMinute(fn) { }; } -function customFormatDistanceToNow(date: number, options = {}) { - return formatDistanceToNow(date, { - ...options, - }); -} - type Props = { dateTime: string, children?: React.Node, @@ -73,13 +64,11 @@ function LocaleTime({ }; }, []); - let content = customFormatDistanceToNow(Date.parse(dateTime), { + let content = formatDistanceToNow(Date.parse(dateTime), { addSuffix, - locale: userLocale ? getLocale(locales[userLocale]) : undefined, + locale: userLocale ? locales[userLocale] : undefined, }); - console.log(content); - if (shorten) { content = content .replace("about", "") diff --git a/webpack.config.js b/webpack.config.js index 565fb216da..e29237c094 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,19 +7,6 @@ const pkg = require("rich-markdown-editor/package.json"); const WebpackPwaManifest = require("webpack-pwa-manifest"); const WorkboxPlugin = require("workbox-webpack-plugin"); -const supportedLocales = [ - "en-US", - "de", - "es", - "fr", - "it", - "zh-CN", - "ko", - "pt-BR", - "pt", - "ru", -]; - require('dotenv').config({ silent: true }); module.exports = { @@ -100,9 +87,6 @@ module.exports = { maximumFileSizeToCacheInBytes: 15 * 1024 * 1024, // For large bundles }), new RelativeCiAgentWebpackPlugin(), - new webpack.ContextReplacementPlugin( - /date\-fns[\/\\]/, - new RegExp(`[/\\\\\](${supportedLocales.join('|')})[/\\\\\]index\.js$`)) ], stats: { assets: false,