Tooling: Brainstorming ideas that can lead to efficient loader-oriented designs #203
Description
Having both ecmascript-modules and @jkrems hackable loader has opened up tremendous scope for experimentation.
Note: This thread does not make claims for or against existing tooling, some of which have stood the test of time, evolved, and are fixtures of the ecosystem. The intent is simply to consider different perspectives being explored in experimental efforts.
As far as things go, the broad range of tooling that applies to loaders basically iterates over productions in each source, irrespective of the specifics of implementation or operations.
Most tools are designed to be used for much more complex applications than merely loading. To that effect, they often avoid the use of new language features that would prevent them from working on older platforms. They can also avoid new features which may have been prematurely associated with inefficiencies in early stages. Some are also built with infrastructures or features that are not ideal or not optimized specifically for loading, like using workers, verbose error checking (ie as a language service)... etc.
I would like to dedicate this thread to brainstorming experimental or just different ideas to implement related patterns for loader-first designs.
Brainstorming: A safe place to discuss ideas and provide constructive feedback
How to contribute
Please avoid emoting that can be confusing (especially if it can construed as passively aggressive)
😄 | Indication |
---|---|
👍 | To indicate a "Yes" response |
👎 | To indicate a "No" response |
🎉 | To indicate a "Aha" moment |
Read the Digest
The following is a set of ideas or conclusions curated from the discussions:
Syntax Detection (CJS vs ESM)
-
Safely using RegExp — @SMotaal
-
Fallback for ESM without
import
andexport
— @targos -
Dual parsing a module was deemed inefficient — @MylesBorins
Syntax Identification (CJS vs ESM)
-
Mime type meta data via something like webpackage — @jkrems
- may rely on
package.json
— @GeoffreyBooth - may borrow from the idea of service-worker scopes — @SMotaal
- may rely on
-
Magic bytes — @jkrems
Wrapping CJS in an ESM module system
- Sometimes CJS is not "use strict" — @benjamingr
- requires evaluating wrapper in non-strict — @SMotaal
- can use multiple SourceTexts — @bmeck