1

I have a function that uses some constants that are exported in seperate file.

If I import the constants inside the function it is not working :

export function findLocalizedLabelForValueDomainCode(...) {
    import LOCALE from  './constants';
   // doing staff 
}

however if I replace :

import LOCALE from  './constants';

by

let cst = require( './constants');

it works... have you an idea why I cant use the import syntax in this case ?

FYI : My project is using ES6

Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87

1 Answers1

0

Dynamic importing is currently in stage 2 proposal but you can use it with babel plugin -> https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import/

Maciej Wojsław
  • 403
  • 2
  • 10