Brython does not play well with Webpack
See original GitHub issueOnce installed with npm
, doing:
require('brython');
in a JavaScript project fails with TypeError: Cannot read property 'name' of undefined
. The line of code responsible for this error is:
$B.isNode=(typeof process !=='undefined')&&(process.release.name==='node')
A (outrageously ugly) workaround for that is to do the following before requiring brython:
process.release = { name: 'This is not Node' };
I feel like this project would benefit from working with Webpack, in order to be included in bigger projects.
Also, I understand brython
sets a global variable instead of exporting the main function from the JS package.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8 (6 by maintainers)
Top Results From Across the Web
It is recommended to add the loader of the webpack · Issue #779
The thing would be to load a js module from webpack modules cache and automatically wrap it as a Brython module object ,...
Read more >Brython – A Python 3 implementation for client-side web ...
It's definitely better than raw objects because it doesn't mix up data and methods ... Both work well with JS libraries, Brython in...
Read more >An Introductory Guide to Brython - Stack Abuse
In this introduction to Brython, we'll take a look at what it is, how to install it, and how to initialize a Brython...
Read more >How to Use Brython: A Guide to Writing Python for the Front End
Brython stands for 'Browser Python' and is Python's implementation of JavaScript. · To work with Brython, you don't need to know JavaScript.
Read more >Frequently asked questions - Brython documentation
Frequently asked questions. Q : what does "Brython" mean ? A : Browser Python. It's also the Welsh word for "brittonic-speaking Celt".
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
If you haven’t yet, you can take a look at the page about how Brython works; it gives an idea of the project structure. Development is made on “individual” scripts in directory
www/src
;brython.js
is generated from these scripts by the Python programscripts/make_dist.py
.For testing, I usually replace
brython.js
in the test page by all the individual scripts; you can copy and paste the list from a page such as sort_table.html.Tell me if I can help in any way, but to be honest I don’t want to learn yet another tool in the Javascript ecosystem. It’s already a lot of work to maintain Brython…
is there any progress in this front? nowadays it is necessary to actually be webpack compatible, it helps to split, pack, minimize and load on demand parts of the stdlib on demand and to play well with the rest of the JS ecosystem.