4

I'm trying this in my ES6 javascript module:

import externalutil from 'https://externalutil.com/js/externalutil.js';

but it fails with this transpile error:

Module not found: 'https://externalutil.com/js/externalutil.js' 

The file externalutil.js is an old-fashioned javascript library that does not export anything.

Any help will be appreciated.

Nikola Schou
  • 2,386
  • 3
  • 23
  • 47

1 Answers1

5

You cannot import URL's (as of yet). You should download the file, put it somewhere locally and reference it locally as well.

However in your case, I'd just use a <script /> tag to include it in your html and just access the window object. Converting it would be more hassle than it would be beneficial.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Joseph Callaars
  • 1,770
  • 1
  • 19
  • 28
  • Thx for the answer. Will that work with a plan javascript library that does not export anything? – Nikola Schou Oct 06 '16 at 10:01
  • It would be great if it exports something otherwise it won't work, unless it writes to the `window` object? – Joseph Callaars Oct 06 '16 at 10:03
  • It does indeed write to the windows-object in the last line of the file. How can this be integrated with my ES6 application? I realize that I can load the script from the index.html root page using a normal script tag and then access window.externalutil. Are there better ways? – Nikola Schou Oct 06 '16 at 10:09
  • In this case, I'd just use a `` tag to include it in your html and just access the `window` object. Converting it would be more hassle than it would be beneficial. – Joseph Callaars Oct 06 '16 at 10:10
  • If you add this to your answer, I'll mark it as the correct answer. I think this is a reasonable approach. – Nikola Schou Oct 06 '16 at 10:12