macrome-js / macrome

The in-tree build system
MIT License
7 stars 1 forks source link

Feature: module resolution #35

Closed conartist6 closed 2 years ago

conartist6 commented 2 years ago

I think it makes sense for the build system to lock down ambiguous module resolution as part of its build. That is to say, when used with it's official plugins it would transform something like require('./foo') to require('./foo.js'). This fits generally with our goal of making the generated code contain as little "magic" as possible so that it is always as clear as possible how a product actually works. It also will prevent code from breaking when the preferred module resolution order differs between environments.

conartist6 commented 2 years ago

Now that I think about this there would be some major hurdles to building it. To have a watch mode that's trustworthy we'd have to re-perform resolution in many cases:

This is likely to be a prohibitive level of complexity, particularly given that the language itself has chosen to solve this problem by standardizing on a module system which requires unambiguous import sources. Only Typescript is currently still in the mud and uses only an ambiguous import syntax.