tc39 / proposal-built-in-modules

BSD 2-Clause "Simplified" License
892 stars 25 forks source link

Why is the BuiltinModule definition a global and not a builtin module? #65

Open guybedford opened 3 years ago

guybedford commented 3 years ago

It would help to hear some of the motiviations for the global, and why these could not be adequately replaced with treating the BuiltinModule object as a builtin module itself.

It seems to me like this would be a great opportunity for the builtin system to bootstrap itself.

ljharb commented 3 years ago

How would a Script synchronously get access to builtin modules that way?

guybedford commented 3 years ago

So the expectation is that scripts should be able to access builtin modules? And this makes the global constraint? Makes sense to me.

Perhaps we could reconsider the framing here then - and say that BuiltinModule is BOTH a global and a builtin module? (and ideally the last global!)

guybedford commented 3 years ago

I really don't like the global though at all I must admit. It seems counter intuitive to introduce a global to get rid of needing to introduce new globals.