我已经从3升级到Webpack 4。 从那时起,我收到很多关于未从某些文件导出的导入的警告。
./packages/utils/logging/index.ts
Attempted import error: ‘Options' is not exported from './loggers/log'.
@ ./packages/utils/index.ts
@ ./src/App.tsx
@ multi whatwg-fetch @babel/polyfill ./src/App.tsx
我将ts-loader
与ForkTsCheckerWebpackPlugin
一起使用。
我已经检查了警告中的出口,它们看起来不错。该代码确实有效,但是我仍然收到那些警告。
tsconfig.json
供参考:
{
"compilerOptions": {
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"baseUrl": ".",
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["packages/**/*"],
"exclude": [
"node_modules",
"build",
"scripts",
"webpack",
"**/__tests__/*"
]
}
Webpack配置:
...
module: {
rules: [
{
test: /\.(ts|tsx|d.ts)$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
},
{
test: /\.(js|jsx|mjs)$/,
include: [paths.packagesSrc, ...paths.modulesToTranspile],
exclude: /node_modules/,
use: {
loader: 'babel-loader?cacheDirectory=true',
options: {
configFile: paths.configFiles.babel,
},
},
},
...
]
},
plugins: [
...
new ForkTsCheckerWebpackPlugin({
async: options.asyncTypeChecking,
checkSyntacticErrors: true,
tsconfig: paths.appTsConfig,
watch: paths.packagesSrc,
}),
...
],
...