-
Notifications
You must be signed in to change notification settings - Fork 509
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
CSP that blocks unsafe eval errors on regenerator-runtime #954
Comments
Thanks for the detailed issue @rbrewington . CSPs are important to support, so would like to make sure everything works, but not sure we have much control over issues in an upstream dependency, and much less so a polyfill.
We're on the latest version of Per TSDX's v0.14.0 Release Notes, if you don't need to support older browsers, you can add a |
So https://github.com/yext/answers/pull/1062 suggests you might be able to downgrade to fix it. You can do that with a Per some other issues/PRs like indico/react-overridable#3, it seems like you can also workaround this by disabling strict mode, which you can do by customizing your Rollup config in Seems like there are multiple workarounds available and this issue is upstream, so I'm not sure there's much more that can be done here in TSDX |
Thank you for the advice. Unfortunately I have to support IE11 and pinning the regenerator runtime also sounds like a potential security concern. I had tried the rollup config approach, but had the path to the strict option wrong. I'll try that. Hopefully the regenerator team can find a way to fix this. For anyone else experiencing this, I'm following this open issue to see if they do: facebook/regenerator#378 ETA: If anyone knows how to disable 'use strict' in CRA please let me know. |
Well in that case you'd need
Upvoted Going to close the issue as it's upstream in a required polyfill, not something TSDX can control, and workarounds have been given for the things TSDX can control. |
I'm hitting this same issue and not really sure how to resolve it. My app is built with CRA, and consumes multiple libraries built with TSDX. I can force a resolution in my CRA app to use |
I think this is where I'm getting stuck: Is there a way to disable the auto injection of the |
To begin, there's a workaround available now for this in facebook/regenerator#378 (comment) . It has to occur before the import, which is auto-inserted by
That's extremely outdated but you can force each of the libraries to use that version too and then build using that.
@AndrewCraswell Yes, that's a known issue. Per #795 (review) , I had to bundle it in for two reasons
I'd like to fix 2. in the future by having TSDX itself check for polyfills in your deps when they are needed in your code, but there's a lot of legwork to get there (potentially a Babel plugin or upstream PR required for detection purposes, then some non-trivial work in TSDX too, and lots of testing, since it'd be a huge user-facing change).
I'm not sure what you're referring to there as it's an old issue about a Babel plugin that isn't used or needed anymore. Per the resolving comment, #795 resolved it.
Please read the above comment: #954 (comment) .
This is a bit off-topic, but that is a preference, and one that I don't think is optimal. Many folks in the community also prefer the opposite extreme, explicitly bundling polyfills in all cases. A bundler like Webpack may be able to detect duplicates with a dedupe plugin as well. I'd prefer the middle -- which I believe is optimal -- that we all actually specify our bundle deps and have NPM resolve them the same so that we avoid any duplication unless necessary due to version restrictions, as we do with all other deps. TSDX is in a position to help lots of libraries dedupe polyfills this way. This does not put any onus on users to manually install polyfills, which can also be significantly error prone (e.g. versions of polyfill are important) and can also lead to duplication (as not every library does that etc).
That's my first time hearing that one, that would create a lot of inconsistencies so I wouldn't recommend that. |
Current Behavior
I've created a library which compiles and works fine. I can import it in my app and everything runs locally.
When I deploy the app to a production environment, the app cannot load and gives an Uncaught EvalError
The app had no CSP issues prior to introducing tsdx (previously my library was bootstrapped by create-react-library)
Expected behavior
I can run an app with a library dependency bootstrapped by tsdx in an environment using a CSP
Suggested solution(s)
I'm not really sure how to fix it, but it seems like regenerator-runtime is running in strict mode but it's not supposed to be?
It looks like this might have been changed in later versions of regenerator-runtime, so maybe updating it would work?
here's the block from regenerator-runtime that the CSP gets tripped up on
(specifically the line in the catch block):
Additional context
Here are some related(?) issues that were all I could really find when searching this
facebook/regenerator#336
babel/babel#12106
indico/react-overridable#2
mozilla/pdf.js#11036
Your environment
The text was updated successfully, but these errors were encountered: