Skip to content

Commit 57a1c7a

Browse files
authored
Suppress false positive webpack warnings during bundle:dev build (#1612)
* Suppress false positive CJS-ESM interop warnings about default exports * add suppression of 'No serializer registered for XXXX' warnings
1 parent 615c83c commit 57a1c7a

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

packages/configs/base-webpack-config/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ exports.merge = function merge(additionalConfig) {
140140
optimizationBailout: true,
141141
modules: false,
142142
},
143+
ignoreWarnings: [
144+
// Suppress false-positive CJS→ESM interop warnings for compiled
145+
// packages that use `exports.default` with `__esModule: true`.
146+
// Webpack's static analyzer only sees `__esModule` as an export
147+
// but the default import still resolves correctly at runtime.
148+
/\(possible exports: __esModule\)/,
149+
],
143150
},
144151
].concat(
145152
typeof additionalConfig === 'function'

packages/configs/site-webpack-config/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ var alias = {
55
site: process.cwd() + '/webapp',
66
};
77

8+
/**
9+
* Suppresses "No serializer registered for ProvidedDependency" cache warnings.
10+
* These arise because ify-loader processes node_modules files that also receive
11+
* a ProvidedDependency injection from ProvidePlugin (for process/browser).
12+
* Webpack's filesystem cache can't serialize ProvidedDependency in that context,
13+
* but the build and runtime behaviour are unaffected - only the cache entry for
14+
* those modules is skipped.
15+
*/
16+
class SuppressProvidedDependencyCacheWarnings {
17+
apply(compiler) {
18+
compiler.hooks.infrastructureLog.tap(
19+
'SuppressProvidedDependencyCacheWarnings',
20+
(origin, type, args) => {
21+
if (
22+
origin === 'webpack.cache.PackFileCacheStrategy' &&
23+
type === 'warn' &&
24+
args.length > 0 &&
25+
String(args[0]).includes('ProvidedDependency')
26+
) {
27+
return true; // returning true suppresses this log entry
28+
}
29+
}
30+
);
31+
}
32+
}
33+
834
module.exports = function configure(additionalConfig) {
935
return baseConfig.merge([
1036
{
@@ -42,6 +68,7 @@ module.exports = function configure(additionalConfig) {
4268
new baseConfig.webpack.ProvidePlugin({
4369
process: 'process/browser',
4470
}),
71+
new SuppressProvidedDependencyCacheWarnings(),
4572
],
4673

4774
// Map external libraries Wdk exposes so we can do things like:

0 commit comments

Comments
 (0)