block by Rich-Harris 4079c7cf46f4aa26c3e8df259b611294

Bare imports in manifest

Full Screen

A hastily-written strawman for how bare imports could be resolved in browsers — see this convo.

index.html

<!doctype html>
<html>
<head>
  <link rel='manifest' href='/manifest.json'>
  <script type='module' src='./main.js'></script>
</head>
<body></body>
</html>

main.js

import _ from 'lodash'; // -> /vendor/lodash/index.js
import { linearScale } from 'd3-scale';  // -> /vendor/d3/d3-scale/index.js
import moment from 'moment'; // -> https://unpkg.com/moment -> https://unpkg.com/moment@2.18.1/moment.js

manifest.json

{
  "name": "my-app",
  "description": "a simple app",
  "modules": {
   "lodash": "/vendor/lodash/index.js",
   "d3-*": "/vendor/d3/d3-$1/index.js",
   "*": "https://unpkg.com/$1"
  }
}