Quantcast
Viewing latest article 22
Browse Latest Browse All 54

Answer by totymedli for webpack imported module is not a constructor

tl;dr

Make sure that you import properly through index files.

Explanation

For me, this error was caused by importing through index files. I had multiple directories with their index.ts files that exported all the files inside the directory. These index files were accumulated/reexported by a main index.ts file so everything can be imported through it.

src/├── index.ts├── module1/│├── index.ts│├── file1.ts│└── file2.ts└── module2/├── index.ts├── file3.ts└── file4.ts

In file4.ts I had an import like this:

import { file1Class, file2Class, file3Class } from "src";

I had to split it into two separate imports:

import { file1Class, file2Class } from "src/module1";import { file3Class } from "src/module2";

Viewing latest article 22
Browse Latest Browse All 54

Trending Articles