DrSensor / nusa

incremental runtime that bring both simplicity and power into webdev (buildless, cross-language, data-driven)
MIT License
4 stars 0 forks source link

`<script type=hoistmap>` #54

Open DrSensor opened 1 year ago

DrSensor commented 1 year ago

Name is inspired from rollup hoistTransitiveImports + importmap

The purpose is to avoid waterfall when linked modules are not bundled. As a result that unbundled module still contain import statement which cause binding to be delayed, waiting for all network request from import statement to finish.

There's 2 way to register hoistmap:

  1. Inline (preferred)
  2. Remotely via src="" attribute

hoistmap format always be in json and must be inside <render-scope>

{
  "worker:imports": [],
  "shared:worker:imports": [],
  "imports": [
    "./a.js",
    ["./b.json", { "type": "json" }],
    ["./c.js", { "worker": true }],
    ["./d.js", { "worker": "shared" }]
  ],
  "fetchs": []
}

Most of the time hoistmap are not needed when the service provider support Smart Early Hints

DrSensor commented 1 year ago

food for though: instead of hoistmap, for internal module, cache and use data+object url