-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: switch to vite & tsdown for bundling #3588
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the build system from Gulp-based transpilation to modern build tools (tsdown for library builds and Vite for browser bundles). The migration changes output file extensions from .js to .mjs (ESM) and .cjs (CommonJS) to align with standard module conventions.
- Replaces Gulp build system with tsdown for library compilation and Vite for browser builds
- Updates package.json exports to use
.mjsand.cjsextensions for better module format distinction - Adds build configuration files and entry generation tooling
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vite.browser.config.ts | Configures Vite to build browser IIFE bundle with sourcemaps |
| tsdown.config.ts | Defines tsdown build configurations for ESM and CommonJS outputs with unbundled structure |
| tools/run-generate-entries.mjs | New script to generate entry files before building |
| pnpm-workspace.yaml | Specifies built dependencies for pnpm workspace |
| package.json | Updates build scripts, exports paths, and adds tsdown/vite dependencies with pnpm package manager |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for starting this initiative!
|
|
Hi Jos, yes we are on the same page here.
so if you are happy I will proceed and remove webpack and gulp altogether.
I didn't want to break anything, so went with more compatible version first, which is understandably bit bigger. The good thing this can be easily configured from
This is tsdown default, behavior and in line with latest node conventions, but for sake of minimising api changes we can configure it to produce js files. As for major version change, let's try to get this in current version with backward support and then once we complete TS migration we will include all the breaking changes there. For now the compatibility is priority, then in next major we can take advantage of this new bundler to do proper optimisation
I had a look at that as well. You are right it can be done in a separate PR.
Do you mean pnpm? yes, will update with npm version. For some reason, i thought this library was using pnpm. |
here is the main config we use (similar for cjs) We can change target (see here) and other parameters to make good defaults. I currently set it |
|
Sounds good, thanks! Let's take one step at a time and try to keep things backward compatible :) Yeah sorry I meant pnpm. |
|
bundling & test harness are really @josdejong's province, not anything I particularly know about, so I will leave those topics to you two to make sure that the resulting library works as well and is not too much bigger anyway and is just as thoroughly tested. On file names, I would definitely prefer not to have to rename all of the source files we work with directly, but don't much care about file names of auto-generated files. Finally on the idea of migrating all of mathjs's internal code to typescript: a long series of proof of concept efforts have made me, and I think Jos, skeptical of that as the best strategy for handling mathjs' very flexible runtime handling of arguments of different types. I think our goal ultimately is to have the implementations of individual operations be in TypeScript, and of course the resulting bundle have an airtight automatically-generated .d.ts file, but we expect that some portions of the internal engine will remain JavaScript as the turn out to be extremely difficult to coax TypeScript into typing properly. |
Summary
This PR introduces a modernized build setup by switching to Vite and tsdown, as discussed in #2742.
The change significantly improves developer experience and build performance, while paving the way for better TypeScript tooling and future consolidation.
Highlights
Next Steps