ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

UI: Proposal to replace esm with babel-register

Open thibsy opened this issue 3 years ago • 0 comments

Hi folks,

I stumbled upon an issue when using mocha.js for clientside unit tests, where the esm module-bundler does not support the latest language features anymore, e.g. null-coalescing or optional-chaining):

trunk/src/UI/templates/js/Input/Field/src/Markdown/markdown.factory.js:40
        return this.instances[input_id] ?? null;
                                         ^

SyntaxError: Invalid or unexpected token
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)

This is due to esm no longer being maintained (last official release in 2019). Therefore, I suggest with this PR to replace this package with @babel/register. I'm honest, I didn't quite dig into this stuff with babel, and introduced another package called @babel/preset-env. This allows to import the latest configuration for babel that supports ES2015+.

This is just a proposal, and I know introducing new dependencies isn't nice, but IMO we have to replace esm anyways in order to comply with the latest Javascript standards. So how do we proceed here?

Kind regards!

thibsy avatar Oct 12 '22 15:10 thibsy