question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Brython does not play well with Webpack

See original GitHub issue

Once 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:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
PierreQuentelcommented, Jan 29, 2020

Anyway, fixing this issue might not be too difficult for now without going through this Webpack refactor, should I change this file: https://github.com/brython-dev/brython/blob/master/www/src/brython.js#L11 ? I feel like it is somewhat generated (from Python?).

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 program scripts/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…

1reaction
vrescobarcommented, Sep 7, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found