Description
Motivation
Our current language dependency system has a few problems:
-
It is incompatible with ESM.
The current system relies on load order to manage both require dependencies and optional dependencies. Optional dependencies simply cannot be expressed using ESM's static
importsyntax. -
It has to be enforced by the user.
Nothing stops our users from loading languages in the wrong order. We regularly get issues where people have this problem.
-
It does not support third-party language definitions.
Right now, all dependencies have to be declared in
components.json. This makes it very hard for authors of third-party languages to integrate their languages. They are essentially forced to write languages with zero dependencies.
The first problem is huge because ESM is a goal for v2.0.
Goals
Primary goals:
-
ESM-compatible.
We have to be able to either write or create ESM source files. Source files have to be able to import each other to fulfill their require dependencies. (E.g. the JS language has to be able to import C-like.)
-
Optional dependencies.
The dependency system has to support optional dependencies. They are the reason this issue exists and they are necessary for Prism.
Secondary goals:
- Third-party authors should be able to "hook" into our dependency system.
- Making the Node hack unnecessary.
Non-goals
-
Backwards-compatibility.
-
Modify dependencies.
Modify dependencies are not strictly necessary. Right now, Prism has 13 modify dependencies. 12 of those can be easily converted into optional dependencies. Only 1 modify dependency will be difficult to convert into an optional dependency but I'm sure that we can find a solution for that.
@LeaVerou @Golmote @mAAdhaTTah