Closed 8Observer8 closed 1 year ago
This only works:
import MyClass from "./my-class";
new MyClass();
if you add the ".js" extension:
import MyClass from "./my-class.js";
new MyClass();
For me, this is the solution.
I'm going to close this because as you noted, browser module resolution will never infer a file's extension. This is a convenience introduced by bundlers where the set of possible files satisfying a prefix can be discovered on the filesystem. On the web, the browser won't make a sequence of requests to attempt to 'find' a file matching the prefix in the specifier.
Failed to load my own files as ES6-modules: https://plnkr.co/edit/bjAl7TXmY9CzzQl5
External module works fine:
main.js
But my module doesn't work:
Failed to load resource: the server responded with a status of 404
my-class.js
main.js