Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unnecessary code duplications in the bundle file #3487

Closed
mohammad-reza-tajik opened this issue Nov 13, 2023 · 1 comment
Closed

unnecessary code duplications in the bundle file #3487

mohammad-reza-tajik opened this issue Nov 13, 2023 · 1 comment

Comments

@mohammad-reza-tajik
Copy link

mohammad-reza-tajik commented Nov 13, 2023

I'm currently working on a backend project and I'm using nodejs and express and esbuild to bundle my code. here's my build script :

"build": "esbuild src/server.ts --bundle --platform=node --outfile=dist/bundle.js --format=esm --packages=external",

the problem is that in the bundle file i see things like :

import express3 from "express";
import express from "express";
import express2 from "express";

this is really strange to me because I expected to see only one express import in the whole bundle file but it turns out there's one for each usage in different files. for example in my server.ts:

import express from "express";
const app = express();

or in my routers :

import express from "express";
const router = express.Router();

is there a problem with the build script or it's esbuild normal behavior ? because I think removing duplicate codes is one of the main thing a module bundler is supposed to do.
(even adding --minify doesn't fix the issue)

@evanw
Copy link
Owner

evanw commented Nov 15, 2023

Closing as a duplicate of #475.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants