Skip to main content
added 545 characters in body
Source Link
T.J. Crowder
  • 1.1m
  • 201
  • 2k
  • 2k

You're correct that you need type="module" on your script tag:

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 

You also need a ./ prefix on your module specifier:

import * as hi from "./hi2.js"; // ------------------^^ 

This is to leave the door open for a specifier with no path at all to have special meaning at some stage as things evolve. From the WHAT-WG spec:

This restriction (that a relative URL specifier must start with /, ./, or ../ – T.J.) is in place so that in the future we can allow custom module loaders to give special meaning to "bare" import specifiers, like import "jquery" or import "web/crypto". For now any such imports will fail, instead of being treated as relative URLs.

When I make those two changes to your files, with Chrome 62 with no experimental flags set, I get the alert.

You're correct that you need type="module" on your script tag:

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 

You also need a ./ prefix on your module specifier:

import * as hi from "./hi2.js"; // ------------------^^ 

This is to leave the door open for a specifier with no path at all to have special meaning at some stage as things evolve. From the WHAT-WG spec:

This restriction is in place so that in the future we can allow custom module loaders to give special meaning to "bare" import specifiers, like import "jquery" or import "web/crypto". For now any such imports will fail, instead of being treated as relative URLs.

When I make those two changes to your files, with Chrome 62 with no experimental flags set, I get the alert.

You're correct that you need type="module" on your script tag:

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 

You also need a ./ prefix on your module specifier:

import * as hi from "./hi2.js"; // ------------------^^ 

This is to leave the door open for a specifier with no path at all to have special meaning at some stage as things evolve. From the WHAT-WG spec:

This restriction (that a relative URL specifier must start with /, ./, or ../ – T.J.) is in place so that in the future we can allow custom module loaders to give special meaning to "bare" import specifiers, like import "jquery" or import "web/crypto". For now any such imports will fail, instead of being treated as relative URLs.

When I make those two changes to your files, with Chrome 62 with no experimental flags set, I get the alert.

added 545 characters in body
Source Link
T.J. Crowder
  • 1.1m
  • 201
  • 2k
  • 2k

YouYou're correct that you need to use type="module" on your script tag (as you'd seen elsewhere) and a ./ prefix on your module specifier. So:

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 

AndYou also need a ./ prefix on your module specifier:

import * as hi from "./hi2.js"; // ------------------^^ 

This is to leave the door open for a specifier with no path at all to have special meaning at some stage as things evolve. From the WHAT-WG spec:

This restriction is in place so that in the future we can allow custom module loaders to give special meaning to "bare" import specifiers, like import "jquery" or import "web/crypto". For now any such imports will fail, instead of being treated as relative URLs.

When I do thatmake those two changes to your files, with Chrome 62 with no experimental flags set, I get the alert.

You need to use type="module" on your script tag (as you'd seen elsewhere) and a ./ prefix on your module specifier. So

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 

And

import * as hi from "./hi2.js"; // ------------------^^ 

When I do that, with Chrome 62 with no experimental flags set, I get the alert.

You're correct that you need type="module" on your script tag:

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 

You also need a ./ prefix on your module specifier:

import * as hi from "./hi2.js"; // ------------------^^ 

This is to leave the door open for a specifier with no path at all to have special meaning at some stage as things evolve. From the WHAT-WG spec:

This restriction is in place so that in the future we can allow custom module loaders to give special meaning to "bare" import specifiers, like import "jquery" or import "web/crypto". For now any such imports will fail, instead of being treated as relative URLs.

When I make those two changes to your files, with Chrome 62 with no experimental flags set, I get the alert.

added 19 characters in body
Source Link
T.J. Crowder
  • 1.1m
  • 201
  • 2k
  • 2k

You need to use ./type="module" prefixes on your module sourcesscript tag (andas you'd seen elsewhere) and a type="module"./) prefix on your module specifier. So

<script src="./hisrc="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 
  

And

import * as hi from "./hi2.js"; // ------------------^^ 

When I do that, with Chrome 62 with no experimental flags set, I get the alert.

You need to use ./ prefixes on your module sources (and type="module"). So

<script src="./hi.js" type="module"></script> 
 

And

import * as hi from "./hi2.js"; 

When I do that, with Chrome 62 with no experimental flags set, I get the alert.

You need to use type="module" on your script tag (as you'd seen elsewhere) and a ./ prefix on your module specifier. So

<script src="hi.js" type="module"></script> <!-- ---------------^^^^^^^^^^^^^ --> 
 

And

import * as hi from "./hi2.js"; // ------------------^^ 

When I do that, with Chrome 62 with no experimental flags set, I get the alert.

Source Link
T.J. Crowder
  • 1.1m
  • 201
  • 2k
  • 2k
Loading