0

To my understanding javascript import statements imports from a string. So building a string and importing should work

let myLib = "foo";
import * as app from `./${myLib}.js`;

this however doesn't work

Uncaught SyntaxError: missing module specifier after 'from' keyword

I have the following directory structure:

main.js
lib/
  myLib0.js
  myLib1.js
  ...

each myLibN.js contains a function named bar and I want to import just one myLibN.js use it inside main.js.

What is the proper way to solve this?

0 Answers0