Skip to content

Support rspack only projects #939

Description

@samssouza

Hello, on rspack only projects when we use the plugin @sentry/webpack-plugin we get the following error during build:

Error: Cannot find module 'webpack'
  at /node_modules/@sentry/webpack-plugin/dist/cjs/index.js

Suggestion

// src/index.ts

Fall back to @rspack/core if webpack is not found or something similar.

let webpack4or5: any = {};

try {
  webpack4or5 = require("webpack");
} catch {
  try {
    webpack4or5 = require("@rspack/core");
  } catch {}
}

const BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPlugin;
const DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;

And mark both as optional peer dependencies

"peerDependenciesMeta": {
  "webpack": { "optional": true },
  "@rspack/core": { "optional": true }
}

Would that be possible?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions