forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[storybook] Ignore TS-related HMR warnings (elastic#103605)
* [storybook] Ignore TS-related HMR warnings * Fix casing * Remove warnings filter Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
639918e
commit 743e3e6
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
// derived from https://github.com/TypeStrong/ts-loader/issues/653#issuecomment-390889335 | ||
// | ||
// This plugin suppresses the irritating TS-related warnings in Storybook HMR. | ||
|
||
import { Compiler, Stats } from 'webpack'; | ||
// @ts-expect-error | ||
import ModuleDependencyWarning from 'webpack/lib/ModuleDependencyWarning'; | ||
|
||
export class IgnoreNotFoundExportPlugin { | ||
apply(compiler: Compiler) { | ||
const messageRegExp = /export '.*'( \(reexported as '.*'\))? was not found in/; | ||
|
||
function doneHook(stats: Stats) { | ||
stats.compilation.warnings = stats.compilation.warnings.filter(function (warn) { | ||
if (warn instanceof ModuleDependencyWarning && messageRegExp.test(warn.message)) { | ||
return false; | ||
} | ||
return true; | ||
}); | ||
} | ||
|
||
if (compiler.hooks) { | ||
compiler.hooks.done.tap('IgnoreNotFoundExportPlugin', doneHook); | ||
} else { | ||
compiler.plugin('done', doneHook); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters