-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
concurrently imports the entire date-fns library without tree-shaking but use only 1 function #329
Comments
The two files you mention are importing a single export from date-fns: Line 3 in 74412ba
What is the problem exactly...? |
The problem is that in the final bundle, the entire date-fns library is there , making the bundle much larger than it should be. Indeed it seems that raised the lines should only import a single function, but that's not the case. Maybe this could work with the suggested syntax in their documentation :
Or maybe the issue comes from erro in tree-shaking within the date-fns library itself ? |
@guillaumeprevost can you provide a sample repo? |
# Analyzing the bundle of simple 'concurrently' import with esbuild
tmpdir=$(mktemp -d)
pushd "$tmpdir" >/dev/null
npm install concurrently esbuild >/dev/null
echo "import concurrently from 'concurrently'; concurrently(['echo test']);" | \
npx esbuild --bundle --platform=node --analyze --outfile=/dev/null 2> >(grep date-fns)
popd >/dev/null
rm -r "$tmpdir"
It seems to me that only the required files are bundled... Am I wrong? Besides that, the suggested import syntax doesn't work:
|
Closing this as I don't see any room for improvement here on our side. Please open a new issue with a reproduction if this is still a problem. |
Hi, yes that's fair enough.. I did not have any free time to work on a minimal reproduction of this issue. |
I've been investigating why node_modules is so heavy on some of my projects. Many libraries could be the cause but concurrently is on top of it. The main reason is that concurrently uses rxjs and date-fns as dependency. Those packages weight more than 10mo each. This could be problematic, especially in a CI environment... There might be improvement from concurrently to be "lighter". |
Yeah, this is actually another reason why I came up with #366 👍 |
I have found this issue while investigating why my project still had the entire date-fns library bundled even if I was carefully importing and using only a few functions.
date-fns provides a syntax that will allow bundlers like Webpack to do some "tree-shaking" and only import the needed modules rather than the full library, optimizing greatly the total bundle size.
It seems like concurrently doesn't use this syntax, which causes to import the full date-fns library instead of only the single function used in logging (
formatDate
in logger.ts and log-timings.ts).How found this :
I had opened an issue about this originally on the date-fns repo because I thought it came from there.
After some discussions around the issue, someone mentioned here that it could come from another dependency importing all of date-fns by not using tree-shaking syntax. The recommendation was to use
npm why date-fns
to spot which other dependency may use date-fns.When running that command, it only listed my own references to date-fns (using the syntax allowing tree-shaking) and the
concurrently
library.The text was updated successfully, but these errors were encountered: