Skip to content

Commit fbaa59d

Browse files
author
Luca Forstner
authored
fix(webpack): Add default fallback to webpack import (#395)
1 parent 1ebe561 commit fbaa59d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

packages/webpack-plugin/src/index.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ function webpackReleaseInjectionPlugin(injectionCode: string): UnpluginOptions {
2525
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2626
// @ts-ignore webpack version compatibility shenanigans
2727
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
28-
const BannerPlugin = compiler?.webpack?.BannerPlugin || webback4or5?.BannerPlugin;
28+
const BannerPlugin =
29+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
30+
// @ts-ignore webpack version compatibility shenanigans
31+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
32+
compiler?.webpack?.BannerPlugin ||
33+
webback4or5?.BannerPlugin ||
34+
webback4or5?.default?.BannerPlugin;
2935
compiler.options.plugins = compiler.options.plugins || [];
3036
compiler.options.plugins.push(
3137
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
@@ -46,7 +52,13 @@ function webpackDebugIdInjectionPlugin(): UnpluginOptions {
4652
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4753
// @ts-ignore webpack version compatibility shenanigans
4854
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
49-
const BannerPlugin = compiler?.webpack?.BannerPlugin || webback4or5?.BannerPlugin;
55+
const BannerPlugin =
56+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
57+
// @ts-ignore webpack version compatibility shenanigans
58+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
59+
compiler?.webpack?.BannerPlugin ||
60+
webback4or5?.BannerPlugin ||
61+
webback4or5?.default?.BannerPlugin;
5062
compiler.options.plugins = compiler.options.plugins || [];
5163
compiler.options.plugins.push(
5264
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
@@ -91,7 +103,13 @@ function webpackModuleMetadataInjectionPlugin(injectionCode: string): UnpluginOp
91103
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
92104
// @ts-ignore webpack version compatibility shenanigans
93105
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
94-
const BannerPlugin = compiler?.webpack?.BannerPlugin || webback4or5?.BannerPlugin;
106+
const BannerPlugin =
107+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
108+
// @ts-ignore webpack version compatibility shenanigans
109+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
110+
compiler?.webpack?.BannerPlugin ||
111+
webback4or5?.BannerPlugin ||
112+
webback4or5?.default?.BannerPlugin;
95113
compiler.options.plugins = compiler.options.plugins || [];
96114
compiler.options.plugins.push(
97115
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call

0 commit comments

Comments
 (0)