Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
How to tree-shake dependencies between bundles in webpack?

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!