rspack: [Bug Report]: Rspack incompatibile with csp-webpack-plugin

System Info

System: OS: macOS 13.3 CPU: (10) arm64 Apple M1 Max Memory: 1.38 GB / 64.00 GB Shell: 5.2.15 - /opt/homebrew/bin/bash Binaries: Node: 18.15.0 - ~/.volta/tools/image/node/18.15.0/bin/node Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn npm: 9.5.0 - ~/.volta/tools/image/node/18.15.0/bin/npm Browsers: Chrome: 111.0.5563.146 Edge: 112.0.1722.34 Firefox: 111.0.1 Safari: 16.4 npmPackages: @rspack/cli: ^0.1.6 => 0.1.6

Details

Rspack seems to be incompatible with the @melloware/csp-webpack-plugin package.

It appears to fail on this line:

compiler.hooks.beforeCompile.tapPromise(thisPluginName, async () => {
TypeError: Cannot read properties of undefined (reading 'tapPromise')
    at SubresourceIntegrityPlugin.apply (/Users/robinclowers/src/console/node_modules/webpack-subresource-integrity/index.ts:365:34)
    at CspHtmlWebpackPlugin.apply (/Users/robinclowers/src/console/node_modules/@melloware/csp-webpack-plugin/plugin.js:397:40)
    at createCompiler (/Users/robinclowers/src/console/node_modules/@rspack/core/src/rspack.ts:75:12)
    at create (/Users/robinclowers/src/console/node_modules/@rspack/core/src/rspack.ts:141:20)
    at rspack (/Users/robinclowers/src/console/node_modules/@rspack/core/src/rspack.ts:165:31)
    at RspackCLI.createCompiler (/Users/robinclowers/src/console/node_modules/@rspack/cli/src/rspack-cli.ts:49:26)
    at async Object.handler (/Users/robinclowers/src/console/node_modules/@rspack/cli/src/commands/build.ts:94:22)

Reproduce link

No response

Reproduce Steps

  1. Create an rspack project
  2. Install the csp-webpack-pugin package: npm i -D @melloware/csp-webpack-plugin
  3. Add a minimal CSP:
  plugins: [
    new CspWebpackPlugin(
      {
        "base-uri": ["'self'"],
        "child-src": ["'none'"],
        "upgrade-insecure-requests": "",
      },
    ),
  ],
  1. Try to compile: npm run build

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 25 (11 by maintainers)

Most upvoted comments

Sub resource integrity. Quite a big one for enterprises with complex compliance requirements.

A simple workaround might by trying to change the hook from tapPromise to tapAsync.

I believe some tappable types are still WIP, even tho hook might exist the tap method may not yet.