Y
Y
youngmysteriouslight2018-01-18 22:53:00
Android
youngmysteriouslight, 2018-01-18 22:53:00

What are the modern approaches to organizing a web application with a large code base?

Considering various options for a future project; I ask you to suggest what solutions, approaches, technologies exist at the moment.
Suppose an application is being developed with a large (>> 1Mb) JS code base. There are several entry points to this code. This means that some pages of the site or some web applications of this project will load one set of modules, others - another set. At the same time, each of these sites/pages/web applications can potentially request any module as needed (substantially depends on user actions).
It will not work to make one assembly, because the access time will be unreasonably high. Add to this that we assume that the user may not have a high-speed connection, not visit the site before, and so on.
As I see it, the only solution is to use asynchronous module loading.
On the other hand, programmers should be able to write their (loosely coupled) modules as if all the code was downloaded to the client machine, or as if it were executed on the server.
In other words, we are looking for a tool that would allow us to abstract from the problem of asynchronous loading of the minimum required set of modules described above.
Question number 1. Is RequireJS/AMD sufficient for the task at hand.

My considerations
По описанию, именно ради асинхронной загрузки модулей он и создавался.
Впрочем, require.js содержит один недостаток, который делает его в текущем виде непригодным для решения первоначальной задачи. Если по результатам обсуждения окажется, что RequireJS является тем решением, которое мне нужно, я создам отдельный вопрос про этот недостаток.

Question number 2. Is there any information about someone else's experience: who did the same, what were the difficulties, what were the approaches, solutions, nuances?
Question number 3. There may be a conflict of dependencies of versions of one module for two different dependent modules. Usually in such cases, conflicts are resolved statically, using a version control system and a package manager, so that only one version of the module gets to the client.
Is conflict resolution at run-time, that is, loading two versions of the same module and separating the namespace, a significantly complicating factor, that is, is a fundamentally different tool needed than the one that solves the original task?
Thank you for attention.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
frozmanX, 2019-11-12
@frozmanX

The same. Flutter needs to be added to the tags

K
Konstantin Kitmanov, 2018-01-18
@youngmysteriouslight

requirejs can only be used in amd, that is, with commonjs modules (and in npm the vast majority are), and even more so with es6, nothing will work. In general, it makes no sense to take it now.
webpack + code splitting is the answer to your question.

A
Alexander Litvinenko, 2018-01-20
@edli007

Why is standard webpack bad? he can both make separate files for entry points and allocate repeating modules to a common file, and with the ability to set criteria for how often they should be repeated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question