-
Notifications
You must be signed in to change notification settings - Fork 72
CLOUDP-352308 Publish both non-minified and minified bundles for dev and prod environments #3316
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
Conversation
|
4ac1d84 to
5aba0c7
Compare
|
Size Change: +576 kB (+29.53%) 🚨 Total Size: 2.52 MB
ℹ️ View Unchanged
|
|
super curious why this weird import pops up, added a few more commits to collect troubleshooting data.. |
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 updates the build process to generate both non-minified and minified JavaScript bundles, improving debugging capabilities while still providing optimized production builds. The non-minified bundle becomes the default export, with minified versions available via production-specific package.json exports.
Key Changes:
- Added a new
minifybuild step using Terser to create minified bundles (*-min.js) from non-minified outputs - Updated package.json exports across all packages to provide minified bundles via the
productioncondition - Modified Rollup configuration to remove inline minification and generate non-minified bundles by default
Reviewed Changes
Copilot reviewed 108 out of 109 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| turbo.json | Adds minify task to build pipeline with proper dependencies and outputs |
| tools/build/src/minify.ts | New minification utility using Terser to generate minified bundles with source maps |
| tools/build/src/cli.ts | Adds lg-build minify command with glob pattern options |
| tools/build/config/rollup.config.mjs | Removes Rollup terser plugin, changes to external source maps, adds visualizer plugin |
| tools/build/config/babel.config.js | Removes production-specific module handling |
| tools/build/package.json | Replaces @rollup/plugin-terser with terser dependency |
| packages/*/package.json | Updates exports to include production-specific minified bundle paths |
| chat/*/package.json | Updates exports to include production-specific minified bundle paths |
| charts/*/package.json | Updates exports to include production-specific minified bundle paths |
| package.json | Adds build:minify script to run minification across all packages |
| .github/workflows/release.yml | Adds minification step before npm publishing |
| .github/workflows/pr.yml | Adds artifact upload for built packages |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| configFile: babelConfigPath, | ||
| sourceMaps: 'inline', | ||
| envName: 'production', | ||
| sourceMaps: true, |
Copilot
AI
Nov 18, 2025
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.
The sourceMaps option should be sourceMap (singular) according to Babel's documentation. While sourceMaps may work due to backwards compatibility, using the correct option name ensures forward compatibility.
| sourceMaps: true, | |
| sourceMap: true, |
| "import": "./dist/esm/*.js-min.js", | ||
| "require": "./dist/umd/*.js-min.js" |
Copilot
AI
Nov 18, 2025
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.
The minified file paths have incorrect double extensions *.js-min.js instead of *-min.js. This pattern will not match any generated files since the minify script creates files with the pattern baseName-min.js.
| fs.writeFileSync(minifiedFile, minified.code!); | ||
| fs.writeFileSync(minifiedFileMap, minified.map! as string); |
Copilot
AI
Nov 18, 2025
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.
If minified.code or minified.map is undefined, the non-null assertion will cause a runtime error. Consider adding explicit error handling with a descriptive message before writing files.
| fs.writeFileSync(minifiedFile, minified.code!); | |
| fs.writeFileSync(minifiedFileMap, minified.map! as string); | |
| if (minified.code === undefined) { | |
| throw new Error(`Minification failed: 'code' is undefined for file ${jsFile}`); | |
| } | |
| if (minified.map === undefined) { | |
| throw new Error(`Minification failed: 'map' is undefined for file ${jsFile}`); | |
| } | |
| fs.writeFileSync(minifiedFile, minified.code); | |
| fs.writeFileSync(minifiedFileMap, minified.map as string); |
| "scripts": { | ||
| "prebuild": "ts-node ./scripts/prebuild/index.ts", | ||
| "build": "ts-node ./scripts/build/build.ts", | ||
| "build": "ts-node ./scripts/build/build.ts --verbose", |
Copilot
AI
Nov 18, 2025
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.
[nitpick] The --verbose flag was added to the build script. If this is for debugging purposes, consider whether it should remain in the committed code or if verbosity should be controlled via an environment variable.
| "build": "ts-node ./scripts/build/build.ts --verbose", | |
| "build": "ts-node ./scripts/build/build.ts", |
| options?: BuildTypescriptOptions, | ||
| ) { | ||
| const { verbose } = options ?? { verbose: false }; | ||
| const { verbose, downlevel } = options ?? {}; |
Copilot
AI
Nov 18, 2025
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.
The destructured update option is defined in the interface but not extracted here, meaning it cannot be used in the function body. Either add update to the destructuring or remove it from the interface if unused.
ac86d28 to
0a23318
Compare
17c55d5 to
fdd87e0
Compare
|
Hey folks, I'm going to use this branch to see if I can reproduce the flaky |
3f35a5d to
600d5b4
Compare
bac81ea to
78c5cb7
Compare
78c5cb7 to
a9e439a
Compare
|
Coverage after merging cloudp-352308-publish-both-dev-prod into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
🎫 Ticket
CLOUDP-352308
📝 Summary
This PR updates the build process so we generate both non-minified and minified versions of our bundles. The default export in
package.jsonis now the non-minified bundle, with the minified version provided as a production-specific export.Details
tools/build/src/minify.ts, accessed vialg-build minify, to minify all non-minified JavaScript files located indist.buildscript produces non-minified outputs, while a newbuild:minifyscript invokes theminifytask across all sub-projects (except those under@lg-tools/*) to generate minified bundles.package.jsonexportsto default to the non-minified bundle, adding the minified bundle as a dedicated production export.lg-build tscscript to correctly forward all received arguments.Rationale
🧪 Checklist
pnpm changesetand included documentation of changes