-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Module isn't auto loaded from CDN URL at runtime. Is it meant to be? #62
Comments
Hi, TLDR The longer version This is essentially how the plugin works -
You can read more about externals in the official webpack documentation. Even if the asset manifest contains the CDN url, webpack itself doesn't do anything with it. What is then left to do is to add the CDN url ourselves. In your current <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Foobar</title>
</head>
<body>
<h1>Foobar</h1>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.js"></script>
<script src="build/app.js"></script>
</body>
</html> Now your application would work as expected. But we end up repeating the URL in two places which is less than ideal. There are two paths we can take from here. Use
|
Is this a bug report?
Yes, if the intended behaviour of this plugin is to facilitate loading external modules from CDN URL's automatically at runtime. Is it?
Environment
[email protected]
[email protected]
Steps to Reproduce
Create a simple hello world app which consumes an external module
Configure plugin to load an external module from CDN using a custom resolver
Build & run
webpack --mode=development
Expected Behavior
The external library (lodash) would be automatically loaded from the configured CDN url at runtime as "_"
Actual Behavior
The external library was not loaded automatically which resulted in a runtime error:
Uncaught ReferenceError: _ is not defined
Note that the CDN URL is referenced in the manifest JSON but not in the compiled js bundle and we see the following line in the console output for the build:
✔️ 'lodash' will be served by https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.1.0/lodash.js
Reproducible Demo
Fiddle of the compilation result
Source Repo
Thanks in advance
The text was updated successfully, but these errors were encountered: