0

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

derek
  • 9,358
  • 11
  • 53
  • 94
  • you need add keyword `export` before `print1` in `a.js`, so that it would be exposed/exported outside, which then your can import as a module. `import { print1} from "/a.js"` – dreamweiver Dec 26 '16 at 05:44
  • @OriDrori Agreed. I will close the topic. – derek Dec 26 '16 at 05:46

0 Answers0