-
Notifications
You must be signed in to change notification settings - Fork 876
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
Find a work around to address RequireJS AMD related problems in production #2632
Comments
Investigation into this problem concludes that there is a significant problem in There is a significant issue with the module architecture. Only one file, Line 5244 in 80da1d2
The above call imports all files defined in MYDEFINES Line 170 in 80da1d2
The problem with this is that the code effectively becomes a monolith — the behavior is as if the code of each file has been appended one after the other into one large file. Even if we let go of actual modularization and use the development tools in the browser, a problem still persists. Require JS is based on Asynchronous Module Definition (AMD); files/modules are loaded asynchronously. Now, JavaScript isn't loaded; the files are parsed into ESTree-spec Abstract Syntax Trees and nodes are loaded asynchronously. The order is subject to the availability of the entire file. Suppose, there are two files that need to be loaded one after the other in order, but, say the latter file is smaller in size and is downloaded before the prior, the browser will attempt to load the nodes of the file which is available first. If there are top-level references of some constructs of the prior file in the latter, the loader crashes. Again, if both files are available, the browser need not necessarily load all nodes of the prior file before those of the latter. The order can be practically arbitrary owing to several factors, and so, if some reference is encountered before the definition, the loader crashes. Now, fixing all of these effectively by reorganization is a gargantuan task. Ideally, each module should import its dependencies but, it is extremely cumbersome here. There could be circular dependencies too. Probably, there's no easy solution to the global import. But, we could perhaps trade-off some load speed for reliability. As of January 2021, there is sufficient support of There's more to it though. The development history of Music Blocks dates back some years to quite a simpler application from which it was forked. Over time it has been bloated and unfortunately no build step was involved down the line. This means that the application is very bulky. All files are hosted on the server as they appear in this repository, which is not a fair practice in modern times. I think bundling is inevitable. I am assigning myself to this sub-project. I'll be configuring |
@meganindya |
Not require.js. I suppose the new |
if you are refereing to ES6 export and import feature of browsers, one thing we should not forget is that, in this case the js files has to be served using a server !
|
@meganindya also i am not aware of the term GOD , it would great if you would elaborate about it ? |
They're objects that do a little too much of work. They're a common anti pattern. We unfortunately have a few of those. Logo, Blocks, Turtles are our god objects. They store too much state information and handle a lot of manipulation. Even objects of Painter and Singer are heavy in state information. Plus we have global constants and utility functions distributed all around. All these add up. |
Perhaps, my words were cryptic and inconsistent. I've reworded the description. I've assigned myself to this. Follow the progress Webpack bundling and building. |
@meganindya I am sorry about the reply , I just wrote it down and almost forgot to comment. It makes sense and I can get to know more as I go along. |
@meganindya I would be very happy to help you out. |
Please use the project link shared above to follow my plans. Since this application will be archived soon. I want to get things sorted in the minimum effort, even if that isn't the best approach in the coding sense. All the progress will be merged from sub-feature branches onto the feature branch I don't want to go too deep into refactoring. The application relies on some of globals — anti-pattern 'GOD' objects, utility and glue functions, and constants. Ideally, I would want a total hierarchical module architecture, but I suppose that'll be a lot of effort, which is perhaps not worth applying. I am considering settling on the globals but in a more reliable manner. Most (almost all) of the global objects are initialized in My rough plans are as:
I suppose there will be multiple bundles. Perhaps, Add a notifying comment here if you pick something to work on. After discussions, when you begin working, create a sub-feature branch forked from the |
Hi @meganindya, I would like to help with this. Where should I start? |
Hello @meganindya @daksh4469 I would also like to work on this issue. Mind if we could share the work together as I think big changes have to be made for this. |
I can't really commit to this right now. I'm busy planning for MB 2.0. Please suggest exhaustive progression steps for this by adding a comment here. My plans listed above are rough ideas. It can surely deviate from that. |
Hey ,is this issue still supposed to be worked on? |
Hey, @ChiragJS Is there something up for grabs in this issue? |
Here below is a screenshot of the production release at musicblocks.sugarlabs.org. The application crashed at loading. However, it loaded on refresh, albeit with a few errors and warnings again. I have had this issue several times before, on multiple devices especially mobile ones. This is a bad thing!
Most of the stuff here looks like an issue with the asynchronous loading via
RequireJS
, which actually would mostly happen when loading from a remote server, so these things aren't often reproduced during local development. #2629 is therefore a priority.#2614, #2615, #2618 address the problem. Crash errors are the priority.
The text was updated successfully, but these errors were encountered: