2

Is it possible to have a variable file name in the import syntax.

for example:

import * as myModule from "my-module";

to be something like this:

var module="my-module";
import * as myModule from module;

Or there is other approach for this? If not can you specify a base(root) dir from where to load the modules? Thanks

Doua Beri
  • 10,612
  • 18
  • 89
  • 138

1 Answers1

0

For the baseroot I am just using a simple workaround with a symlink:

Link your src/ to the node_module/src

And use it:

import A from 'src/some/where/A

There are also other possible ways of doing it, but I am ok, with it, its really simple and it works ;)

Check out this How to make the require in node.js to be always relative to the root folder of the project?

Community
  • 1
  • 1
webdeb
  • 12,993
  • 5
  • 28
  • 44