import a file name directly in ES6

274 views Asked by At

It is legit to import a file directly in ES6 according to here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Import an entire module for side effects only, without importing any bindings.

import "my-module";

I do not understand the sentence. So I created a minimal example to try to understand it.

//a.js
function print1()
{
  console.log("export print1 is working");
}

//b.js
import "/import/tags";
print1();

When I ran "b.js", I got an error:

print1 is not defined

Thanks

Derek

0

There are 0 answers