JS Minification during React Build throws off eel.init
See original GitHub issueI’m building an app using React for the Front End after the example of @KyleKing
During development everything works perfectly but upon running npm run build
and even npm run build -- --profile
the script is not able to parse the enclosed JS functions.
Here the code in App.js:
function show_log(msg) {
window.AppComponent.showLog(msg)
}
window.eel.expose(show_log, 'show_log')
Here’s the minified version after running npm run build -- --profile
we.set_host("ws://localhost:8080"), window.eel.expose((function show_log(e) {
window.AppComponent.showLog(e)
}), "show_log");
I don’t know what else to do on the js side but I think from the Python side there are two possible solutions:
- Adapt
eel.init
to accept an array of function names to accept as default functions to be registered (and replace the assert error with a logging statement) - Adapt the regex for finding the js functions → a possible alternative pattern would be:
eel\.expose\(.*[;\)]
to then pass into a more exhaustive isolation script I guess this would be an issue where @samuelhwilliams would need to have a say in.
Please let me know if there are specific things I can do on the JS side to avoid having to adjust the package.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to build a production version of React without minification?
Now, if I run npm run build I get a minified version of everything in the build folder. If I, however, run npm...
Read more >Minifying JavaScript | JetBrains Rider Documentation
Minification or compression means removing all unnecessary characters, such as spaces, new lines, comments, without changing the functionality of the source ...
Read more >The complete best practices for minifying CSS - LogRocket Blog
Minification alters the content of code. It reduces code file size by stripping out unwanted spaces, characters, and formatting, resulting in ...
Read more >uglify-js - npm
UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit. Note: uglify-js supports JavaScript and most language features in ...
Read more >Minifying - SurviveJS
Since webpack 4, the production output gets minified using terser by default. Terser is an ES2015+ compatible JavaScript-minifier. Compared to UglifyJS, the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @KyleKing - this looks good, thanks for picking it up.
I’m just going to merge some initial basic functional tests. Could you maybe add add some test cases to your PR and then I’ll give it a review. Thanks!
Got it! Below is a standalone proof of concept and I’ve created a prototype PR for feedback #365
As an example with a couple of test cases: