Parcel bundle remote/local moduel in HTML

31 Views Asked by At

Given a HTML page as follows

<!doctype html>
<html lang="en">
  <head>
  </head>
  <body>
    <script type="module">
      import "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js";
    </script>
  </body>
</html>

How can I make Parcel bundle the script in a remote URL?

Alternatively, using NodeJS dependency manager, such as npm, the module can be downloaded locally, which changes the import URL as follows

<!doctype html>
<html lang="en">
  <head>
  </head>
  <body>
    <script type="module">
      import "../node_modules/jquery/dist/jquery.min.js";
    </script>
  </body>
</html>

Using a local webserver (not the one builtin in Parcel), the HTML file opens without any issue. Still I was unable to make Parcel bundle the file, even when using bare specifiers, and I think that when using the bare specifiers, the HTML will not load in the browser when Parcel is not use.

I am interested in a path/URL which will be resolved correctly without and with Parcel.

0

There are 0 best solutions below