FATAL BannerPlugin is not a constructor
at Object.webpack (node_modules/@sentry/webpack-plugin/dist/esm/index.mjs:20:7)
at Object.apply (node_modules/unplugin/dist/index.mjs:1381:20)
at webpack (node_modules/webpack/lib/webpack.js:51:13)
at node_modules/@nuxt/webpack/dist/webpack.js:1821:24
at Array.map (<anonymous>)
at WebpackBundler.build (node_modules/@nuxt/webpack/dist/webpack.js:1820:37)
at async Builder.build (node_modules/@nuxt/builder/dist/builder.js:249:5)
at async Object.run (node_modules/@nuxt/cli/dist/cli-build.js:99:7)
at async NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:356:7)
I think that's not unusual and the package should account for the import being potentially wrapped in default object since webpack is a CJS module and the behavior of how the exports will be transformed is not entirely well defined (when imported from ESM context at least).
webback4or5: {
debug: { ProfilingPlugin: [Getter] },
default:
{ [Function: webpack]
version: '4.46.0',
WebpackOptionsDefaulter: [class WebpackOptionsDefaulter extends OptionsDefaulter],
WebpackOptionsApply: [class WebpackOptionsApply extends OptionsApply],
Compiler: [class Compiler extends Tapable],
MultiCompiler: [class MultiCompiler extends Tapable],
NodeEnvironmentPlugin: [class NodeEnvironmentPlugin],
validate: [Function: bound validateSchema],
validateSchema: [Function: validateSchema],
WebpackOptionsValidationError: [class WebpackOptionsValidationError extends WebpackError],
AutomaticPrefetchPlugin: [Getter],
BannerPlugin: [Getter],
CachePlugin: [Getter],
ContextExclusionPlugin: [Getter],
ContextReplacementPlugin: [Getter],
DefinePlugin: [Getter],
Dependency: [Getter],
DllPlugin: [Getter],
DllReferencePlugin: [Getter],
EnvironmentPlugin: [Getter],
EvalDevToolModulePlugin: [Getter],
EvalSourceMapDevToolPlugin: [Getter],
ExtendedAPIPlugin: [Getter],
ExternalsPlugin: [Getter],
HashedModuleIdsPlugin: [Getter],
HotModuleReplacementPlugin: [Getter],
IgnorePlugin: [Getter],
LibraryTemplatePlugin: [Getter],
LoaderOptionsPlugin: [Getter],
LoaderTargetPlugin: [Getter],
MemoryOutputFileSystem: [Getter],
Module: [Getter],
ModuleFilenameHelpers: [Getter],
NamedChunksPlugin: [Getter],
NamedModulesPlugin: [Getter],
NoEmitOnErrorsPlugin: [Getter],
NormalModuleReplacementPlugin: [Getter],
PrefetchPlugin: [Getter],
ProgressPlugin: [Getter],
ProvidePlugin: [Getter],
SetVarMainTemplatePlugin: [Getter],
SingleEntryPlugin: [Getter],
SourceMapDevToolPlugin: [Getter],
Stats: [Getter],
Template: [Getter],
UmdMainTemplatePlugin: [Getter],
WatchIgnorePlugin: [Getter],
dependencies: [Object],
optimize: [Object],
web: [Object],
webworker: [Object],
node: [Object],
debug: [Object],
util: [Object] },
dependencies: { DependencyReference: [Getter] },
node: { NodeTemplatePlugin: [Getter], ReadFileCompileWasmTemplatePlugin: [Getter] },
optimize:
{ AggressiveMergingPlugin: [Getter],
AggressiveSplittingPlugin: [Getter],
ChunkModuleIdRangePlugin: [Getter],
LimitChunkCountPlugin: [Getter],
MinChunkSizePlugin: [Getter],
ModuleConcatenationPlugin: [Getter],
OccurrenceOrderPlugin: [Getter],
OccurrenceModuleOrderPlugin: [Getter],
OccurrenceChunkOrderPlugin: [Getter],
RuntimeChunkPlugin: [Getter],
SideEffectsFlagPlugin: [Getter],
SplitChunksPlugin: [Getter],
UglifyJsPlugin: [Getter],
CommonsChunkPlugin: [Getter] },
util: { createHash: [Getter] },
version: '4.46.0',
web: { FetchCompileWasmTemplatePlugin: [Getter], JsonpTemplatePlugin: [Getter] },
webworker: { WebWorkerTemplatePlugin: [Getter] }
}
I've tried to implement support for
@sentry/webpack-plugin@2in the Nuxt module but run into an issue where this code crashes:sentry-javascript-bundler-plugins/packages/webpack-plugin/src/index.ts
Lines 21 to 40 in 1ebe561
with:
It appears to be because of the
import * as webback4or5 from "webpack"line where the relevantBannerPluginimport appears to be within thewebback4or5.defaultobject.I think that's not unusual and the package should account for the import being potentially wrapped in
defaultobject sincewebpackis a CJS module and the behavior of how the exports will be transformed is not entirely well defined (when imported from ESM context at least).The import
webback4or5has a structure like this here: