I'm using webpack to create an electron app so I must use a different target for "preload", "main" and "render" entry points and that's why I have to build 3 different bundles. The problem is that if, lets say, I import an enum from a module used in "main" into "preload" it doesn't just imports the enum but it also imports the whole module when compiling for development and compiling for production is just a bit better since it imports whatever that module imported. Ex:
//main.ts
import * as fs from "fs";
export enum Foo{
Bar
}
//preload.ts
import { Foo } from "./main";
var va = Foo.Bar;
//(compiled for production) preload.ts -> preload.js
const fs = require(fs)
...
As you can see its importing "fs" in preload.js even tough it doesn't use it and just because I'm importing an enum, I haven't tested but I'm sure that this doesn't happen between different entry points with webpack and tree-shaking but only between bundles
So I would like to ask if anyone happens to know a way to only import the needed code, not necessarily related to webpack
Thanks