webpack - 如何避免警告 `Module parse failed: Unexpected token` 来自 date-fns/locale
问题描述
我date-fns
在我的反应应用程序中使用。使用 Webpack(4) 和 babel(7) 构建应用程序时,会出现以下警告。
WARNING in ./node_modules/date-fns/locale/en/index.d.ts 1:8
Module parse failed: Unexpected token (1:8)
You may need an appropriate loader to handle this file type.
> declare module 'date-fns/locale/en' { }
|
@ ./node_modules/date-fns/locale sync ^\.\/.*$ ./en/index.d.ts
以下是我使用的代码块date-fns/locale
。
import fmt from 'date-fns/format';
export const format = (date, formatStr) =>
fmt(date, formatStr, {
locale: require(`date-fns/locale/en`),
});
如何避免这个警告?
解决方案
推荐阅读
- python - 折线图
- excel - 如何将公式分配给匿名形状?
- unit-testing - 如何找出函数在 Jest 中通过测试的原因?
- python - 给定一个字符串列表,如果任何值等于列表中的值,我想将字典的值添加到新字典中
- google-cloud-platform - 在 BigQuery 中导出表格时,我可以控制共享文件的大小和/或数量吗?
- javascript - 如果单击取消按钮,如何使 Javascript“确认()”取消对新页面的请求?
- java - 如何在 json-binding (java ee 8) 中编写将空值转换为“”的反序列化器?
- node.js - 在 Heroku 上部署应用程序时如何修复 H20 错误?
- asp.net - 如何使用 devexpress 在弹出窗口中获取清单的选定值
- apache-kafka - Kafka 服务器 - 在 JAAS 中找不到“KafkaServer”