slackhq / csp-html-webpack-plugin

A plugin which, when combined with HTMLWebpackPlugin, adds CSP tags to the HTML output.
MIT License
164 stars 39 forks source link

Yarn 2 support #83

Closed wegry closed 3 years ago

wegry commented 3 years ago

Description

Does this plugin not support yarn 2? With 5.1.0:

ERROR in   TypeError: val.includes is not a function

  - plugin.js:297
    [csp-html-webpack-plugin-npm-5.1.0-40d465e733-0e41f2e490.zip]/[csp-html-web    pack-plugin]/plugin.js:297:17

  - Array.map

  - plugin.js:290 CspHtmlWebpackPlugin.buildPolicy
    [csp-html-webpack-plugin-npm-5.1.0-40d465e733-0e41f2e490.zip]/[csp-html-web    pack-plugin]/plugin.js:290:8

  - plugin.js:334 CspHtmlWebpackPlugin.processCsp
    [csp-html-webpack-plugin-npm-5.1.0-40d465e733-0e41f2e490.zip]/[csp-html-web    pack-plugin]/plugin.js:334:30

  - new Promise

  - index.js:348
    [html-webpack-plugin-npm-5.0.0-beta.1-fd77fa0afb-d71b4e4a7b.zip]/[html-webp    ack-plugin]/index.js:348:72

webpack 5.17.0 compiled with 2 errors in 4589 ms

I'll try cooking up a minimal repro later.

What type of issue is this? (place an x in one of the [ ])

Requirements (place an x in each of the [ ])


Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackhq/csp-html-webpack-plugin version:

node version:

OS version(s):

Steps to reproduce:

1. 2. 3.

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

wegry commented 3 years ago

I made a mistake with arrays being passed into the policy portion.

wegry commented 3 years ago

This error looks like it's caused by

new CspHtmlWebpackPlugin({
  nonceEnabled: {
    'script-src': true,
    'style-src': true
  },
})

instead of having

new CspHtmlWebpackPlugin({}, {
  nonceEnabled: {
    'script-src': true,
    'style-src': true
  },
})