javascript - 为什么我的 babel-polyfill 解析 node_modules 目录中的 ts 文件?
问题描述
我运行 a npm run dev
,控制台打印下面的警告,这是我的基本 webpack 配置,我在条目中使用了“babel-polyfill”,并node_modules
在我的 babel-loader 配置中排除了目录:
module.exports = {
entry: {
index: ['babel-polyfill', entry]
},
output: {
path: dist
},
resolve: {
extensions: ['.web.js', '.js', '.jsx', '.less', '.scss', '.css', '.json', '.png', '.jpg', '.jpeg'],
alias: {
'@': src,
'@utils': path.resolve(src, 'utils'),
'@common': path.resolve(src, 'common'),
}
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: src,
use: {
loader: 'babel-loader?cacheDirectory'
}
}, {
test: /\.(eot|woff|svg|ttf|woff2|gif|appcache)(\?|$)/,
exclude: /^node_modules$/,
loader: 'url-loader?name=fonts/[name].[ext]',
include: src
}, {
test: /\.(png|jpg)$/,
// exclude: /^node_modules$/,
loader: 'url-loader?limit=8192&name=images/[hash:8].[name].[ext]'
// include: [SRC_PATH]
}, { test: /\.(svg)$/i,
loader: 'svg-sprite-loader',
include: [
require.resolve('antd').replace(/warn\.js$/, '')
// path.resolve(__dirname, 'images/'),
]}
]
},
optimization: {
runtimeChunk: {
name: 'runtime'
},
splitChunks: {
chunks: 'all',
minSize: 30000,
maxSize: 200000,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 4,
automaticNameDelimiter: '_',
cacheGroups: {
libs_antd: {
name: 'libs_antd',
test: path.resolve(root, 'node_modules', 'antd'),
chunks: 'async',
priority: -8,
reuseExistingChunk: true
},
verdors: {
name: 'verdors',
test: path.resolve(root, 'node_modules'),
chunks: 'initial',
priority: -10
},
node_commons: {
name: 'node_commons',
test: path.resolve(root, 'node_modules'),
chunks: 'async',
minChunks: 2,
priority: -10,
reuseExistingChunk: true
}
}
},
usedExports: true
},
plugins
};
和警告信息:
WARNING in ./node_modules/_antd@3.23.4@antd/lib/locale/hu_HU.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
> declare const _default: {
| locale: string;
| Pagination: any;
@ ./node_modules/antd/lib/locale lazy ^\.\/.*$ namespace object ./hu_HU.d.ts
@ ./src/app/component/index.js
@ ./src/app/model/container.js
@ ./src/app/index.js
@ ./src/router.js
@ ./src/entry.js
@ multi babel-polyfill ./src/entry
我认为不应该解析 node_modules 中的代码,我不知道为什么会出现警告?有任何想法吗?谢谢。
解决方案
推荐阅读
- r - dplyr中select()的contains()和matches()之间的区别
- django - Django任何已安装的应用程序都找不到静态文件
- c++ - 有符号 32 位元素的 AVX __m256i 整数除法
- botframework - 基于 .net 的机器人的“az bot publish”命令中正确的源代码目录位置是什么
- python - Python 测试 - 这是一种安全的方式来编写我的测试以避免在每个测试函数中重复冗长的字典吗
- jquery - 如何将带有 jQuery 选项卡的多个表添加到单个页面?
- vuetify.js - Vuetify / Mouseover 不适用于 v-system-nav
- c++ - 使用 Score-P / Vampirtrace 的自动检测不适用于 gcc/g++
- java - 在我的项目中使用多个 sdk 版本
- c# - EndpointDispatcher 错误处的 WCF ContractFilter 不匹配