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

Add Rollup.js tree-shaking and terser minification #197

Closed
wants to merge 2 commits into from

Conversation

opichals
Copy link
Contributor

@opichals opichals commented Nov 7, 2018

The functionality is off by default so is should not affect users unless they turn on ROLLUP or set (MODULE_)MINIFICATION_LEVEL to TERSER in the IDE settings.

Uses the rollup+terser 907kB browser bundle built into espruino/EspruinoTools#80

@opichals opichals force-pushed the add-rollup branch 2 times, most recently from 9d81e6a to 832754c Compare November 8, 2018 00:23
@opichals opichals force-pushed the add-rollup branch 6 times, most recently from 670269b to b94986a Compare November 25, 2018 22:08
@gfwilliams
Copy link
Member

Hmm - just realised I hadn't merged this, and it turns out the chrome app doesn't work with it at all:

espruino-rollup.browser.js:1 Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource: 'wasm-eval'"

It doesn't like the use of new Function (or eval) in the code inside espruino-rollup.browser.js

Did you have it working somehow, or did you only try out the browser-only version?

Since you obviously know a bunch more about rollup than I do - do you know of a way to stop it using new Function inside the rollup bundle that it produces?

@opichals
Copy link
Contributor Author

opichals commented Apr 28, 2019

@gfwilliams It is terser code that contains new Function() which cannot be easily replaced.

The issue can be worked around via sandboxing (https://developer.chrome.com/apps/sandboxingEval). It involves an isolated sandbox.html iframe containing the rollup/terser new Function() code and a bidirectional window.postMessage()-based messaging channel to be able to reach the other sides of the frame.

I have modified the code to comply and tested as Chrome App as well as the browser-only version.

@gfwilliams
Copy link
Member

Closing based on #242

@gfwilliams gfwilliams closed this Aug 5, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants