proposal-built-in-modules icon indicating copy to clipboard operation
proposal-built-in-modules copied to clipboard

Possible solution of execution order change

Open Jack-Works opened this issue 5 years ago • 1 comments

It must have a new syntax so it can be statically analyzed.

Here is an example (I know it is conflicting with TypeScript syntax though)

declare module "std:Complex" {
    console.log('Polyfilled!')
    if (!BuiltinModule.has(...)) { await fetch('...').then(fill_module) }
}

If std:Complex is never accessed, the code above never being executed.

Once it is accessed, the code above is being executed immediately to prepare the module.

Jack-Works avatar Sep 24 '20 03:09 Jack-Works

By wrapping all polyfills in the declare statements above, it can resolve the concerns I have mentioned at the meeting, that is, unused partially shimming doesn't cost anything.

This also resolves the execution order problem. No module is more prior that others (the shimming requirement) but it is still polyfillable.

Jack-Works avatar Sep 24 '20 03:09 Jack-Works