import失败,提示export 'default' (imported as 'impl') was not found in '../proto/proto.min'
Closed this issue · 1 comments
imndx commented
原因是proto.min.js
和base64.min.js
不需要通过babel
转换,需要在babel
的配置文件中将这两个文件忽略。
.babelrc
参考配置如下:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"ignore": [
"**/base64.min.js",
"**/proto.min.js",
"**/engine.min.js"
]
}
imndx commented
如果是create-react-app
创建的react
应用的话,默认没有开放配置,可以这么:
- 执行
yarn eject
或者npm run eject
会在项目目录下生成config
目录,该目录包含默认配置 - 修改
config/webpack.config.js
,在babel
相关配置部分,加上上面的ignore
配置,如下:
// Process application JS with Babel.
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
customize: require.resolve(
'babel-preset-react-app/webpack-overrides'
),
presets: [
[
require.resolve('babel-preset-react-app'),
{
runtime: hasJsxRuntime ? 'automatic' : 'classic',
},
],
],
plugins: [
isEnvDevelopment &&
shouldUseReactRefresh &&
require.resolve('react-refresh/babel'),
].filter(Boolean),
// 下面 ignore 配置是新添加
// ================================================================================
ignore: [
"**/base64.min.js",
"**/proto.min.js",
"**/engine.min.js"
],
// 上面 ignore 配置是新添加的
// ===============================================================================
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
// See #6846 for context on why cacheCompression is disabled
cacheCompression: false,
compact: isEnvProduction,
},
},