I'm testing a library that is exported as a module (by Webpack) with something like
// myLib.js
const a = 1;
export { a as myVal };
My script for the page is
// index.js
import { myVal } from 'my-lib'
console.log (myVal)
In webpack.config.js I have externals: { myLib: 'myLib' }. In my index.html, I would have
...
<script type="module" src="https://unpkg.com/myLib"></script>
<script type="module" src="index.js"></script>
...
This leads to run time error of Uncaught TypeError: Failed to resolve module specifier "myLib". Relative references must start with either "/", "./", or "../".
This is because despite the library has been loaded onto the page, it is not referenced by the name myLib.
What's the proper way to set up Webpack so that when I import 'myLib' in index.js, it knows I mean import from 'http://unpkg.com/myLib'?