wheresrhys/fetch-mock

regenerator global Function call throws CSP unsafe-eval error

Closed this issue · 2 comments

rs178 commented

Description : regenerator global Function call throws CSP unsafe-eval error

Steps to reproduce:

  1. file fetch-mock/es5/client-bundle.js has the following attached code
  2. client-bundle.js has global Function call which throws the unsafe-eval CSP error
  3. The above issue is fixed in facebook/regenerator#450
  4. Need fetch-mock update to use the above latest regenerator fix to solve the issue
            try {
              regeneratorRuntime = runtime;
            } catch (accidentalStrictMode) {
              // This module should not be running in strict mode, so the above
              // assignment should always work unless something is misconfigured. Just
              // in case runtime.js accidentally runs in strict mode, we can escape
              // strict mode using a global Function call. This could conceivably fail
              // if a Content Security Policy forbids using Function, but in that case
              // the proper solution is to fix the accidental strict mode problem. If
              // you've misconfigured your bundler to force strict mode and applied a
              // CSP to forbid Function, and you're not willing to fix either of those
              // problems, please detail your unique predicament in a GitHub issue.
              Function("r", "regeneratorRuntime = r")(runtime);
            }

I'm facing this same issue

I have now rebuilt using more up to date build tools and hopefully this issue is now gone