Feature request
What is the expected behavior?
Webpack currently supports the concept of externals but it only allows the forms: root, commonjs, commonjs2, and amd.
This is a problem if my source code depends on a third-party library that is hosted on a CDN (in ES module format).
For example, the following does not currently work with webpack:
import {externalLibrary} from 'https://cdn.com/externalLibrary.mjs';
// Do something with `externalLibrary`.
externalLibrary.init();
What is the motivation or use case for adding/changing the behavior?
Now that most browsers natively support loading modules via import statements in module scripts, it should be possible to leverage this feature while still bundling with webpack.
Webpack already has the notion of external dependencies, it should be possible to do the same with external module dependencies.
How should this be implemented in your opinion?
External imports could be placed at the top of each chunk, and their exported variables could be renamed as necessary to ensure no collisions with existing chunk code.
Are you willing to work on this yourself?
I'm willing to help, but cannot commit to full implementation. I looked into whether it would be possible to implement this via a plugin, and it didn't seem like it's currently possible.
Feature request
What is the expected behavior?
Webpack currently supports the concept of externals but it only allows the forms:
root,commonjs,commonjs2, andamd.This is a problem if my source code depends on a third-party library that is hosted on a CDN (in ES module format).
For example, the following does not currently work with webpack:
What is the motivation or use case for adding/changing the behavior?
Now that most browsers natively support loading modules via
importstatements in module scripts, it should be possible to leverage this feature while still bundling with webpack.Webpack already has the notion of external dependencies, it should be possible to do the same with external module dependencies.
How should this be implemented in your opinion?
External imports could be placed at the top of each chunk, and their exported variables could be renamed as necessary to ensure no collisions with existing chunk code.
Are you willing to work on this yourself?
I'm willing to help, but cannot commit to full implementation. I looked into whether it would be possible to implement this via a plugin, and it didn't seem like it's currently possible.