Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES5 build breaks violates CSP for unsafe-eval #192

Open
maxmorlocke opened this issue Aug 4, 2021 · 5 comments
Open

ES5 build breaks violates CSP for unsafe-eval #192

maxmorlocke opened this issue Aug 4, 2021 · 5 comments

Comments

@maxmorlocke
Copy link

The current ES5-friendly build distributed through NPM breaks content security policies due to the reliance on regeneratorRuntime to replace async/await functions. This breaks chrome extensions, even those that follow the suggestions to set checkProtocolTask et al to null. Would it be possible to include two builds in the dist - one for modern browsers (e.g. es6+) and one for legacy browsers (e.g. es5)? This was the solution used by pdf.js:

mozilla/pdf.js#11036

image
image

this of course sources from the es5 build:

https://unpkg.com/browse/analytics@0.7.11/dist/analytics.js
image

@DavidWells
Copy link
Owner

Hey there!

Thanks for the report on this.

I've been trying to refactor all the package builds to use microbundle but running into some quirks with how it handles default exports 😅

There is a es6 module packaged in https://unpkg.com/browse/analytics@0.7.11/lib/ will that work for your application?

@DavidWells
Copy link
Owner

Looks like this is an ongoing issue for the regenerator polyfill facebook/regenerator#378

@maxmorlocke
Copy link
Author

It looks like everything in lib is still being transpiled to include the regeneratorRuntime, so I'm still getting errors:

grep -c regenerator node_modules/@analytics/core/lib/*.js
node_modules/@analytics/core/lib/analytics.browser.cjs.js:27
node_modules/@analytics/core/lib/analytics.browser.es.js:27
node_modules/@analytics/core/lib/analytics.cjs.js:27
node_modules/@analytics/core/lib/analytics.es.js:27

Am I missing something?

@olivierbeaulieu
Copy link
Contributor

olivierbeaulieu commented Jan 27, 2022

I'm also experiencing this issue - and it doesn't seem like any of the proposed solutions are working - I'm using the latest analytics.browser.es.js.

@DavidWells
Copy link
Owner

Just updated all of the build deps.

Can ya'll try again with latest analytics@0.7.23

I'm hoping this fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants