Can't import absolute URLs, e.g. from CDN
See original GitHub issue🐛 bug report
import('https://...cdn_path.../module.min.js')
fails with:
Only absolute URLs are supported Failed to install https
The code works just fine without Parcel when I open index.html
in Chrome.
What am I doing wrong? Failing to load CDN libraries seems like a blatant omission.
🎛 Configuration (.babelrc, package.json, cli command)
Zero config.
🤔 Expected Behavior
Server launches.
😯 Current Behavior
$ npx parcel index.html
Server running at http://localhost:1234
npm ERR! Only absolute URLs are supported
npm ERR! A complete log of this run can be found in:
npm ERR! /home/dandv/.npm/_logs/2018-12-04T20_24_06_209Z-debug.log
🚨 /home/dandv/prg/importcdn/index.js:1:7: Failed to install https:.
> 1 | import('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js').then(lodash => {
| ^
2 | console.log(_.VERSION);
3 | });
4 |
🔦 Context
I’m trying to load from CDN a bunch of libraries I don’t want to host myself.
💻 Code Sample
index.html:
<html>
<body>
<script src="index.js"></script>
</body>
</html>
index.js:
import('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.min.js').then(lodash => {
console.log(_.VERSION);
});
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 1.10.3 |
Node | 11.3.0 |
npm/Yarn | 6.4.1 |
Operating System | Ubuntu Linux 16.04 |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Absolute vs relative URLs - Stack Overflow
If by absolute URLs you mean URLs including scheme (e.g. HTTP / HTTPS) and the hostname (e.g. yourdomain.example ) don't ever do that...
Read more >Dependency resolution - Parcel
In CSS, @import and url() may be used. Typically, these dependencies do not specify a full absolute path, but rather a shorter specifier...
Read more >Advanced Features: Absolute Imports and Module Path Aliases
Configure module path aliases that allow you to remap certain import paths.
Read more >Absolute vs Relative Path - Which Should You Be Using?
Learn more about the differences that exist between an absolute and relative path. This article explains which method you should use and ...
Read more >Everything You Need to Know About JavaScript Import Maps
It should be noted that the mappings in an import map do not affect URLs in places like the src attribute of a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is there an example of the import() syntax for v2?
Thanks for the fix for JS!
I still see the issue with importing CSS:
Browser console: