3

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.

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Thx for the answer. Will that work with a plan javascript library that does not export anything?
It would be great if it exports something otherwise it won't work, unless it writes to the window object?
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?
In this 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.
If you add this to your answer, I'll mark it as the correct answer. I think this is a reasonable approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.