feat(packages/sui-compiler-config): preserve webpack magic comments in TS compilation#1976
Open
feat(packages/sui-compiler-config): preserve webpack magic comments in TS compilation#1976
Conversation
andresz1
reviewed
Mar 27, 2026
|
|
||
| return { | ||
| minify: true, | ||
| minify, |
Member
There was a problem hiding this comment.
Can we set this false only if ts is enabled and the flag is set to true otherwise it will affect all applications (at least for now)
7be0b3b to
5e32707
Compare
kikoruiz
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SWC's
minify: truewas hardcoded ingetSWCConfig, causing it to run minificationinside webpack's
swc-loaderbefore webpack processes magic comments like/* webpackChunkName: "..." */. This strips the comments, resulting in unnamed chunksand broken CSS loading in SSR.
Changes
Two small, focused changes:
sui-compiler-config/src/index.js— Removed the hardcodedminify: truefromgetSWCConfig()and added a newpreserveCommentsoption. Whentrue, it outputsminify: { format: { comments: 'all' } }to instruct SWC to keep all comments (including webpack magic comments).sui-bundler/shared/module-rules-compiler.js— The TypeScript SWC rule now passespreserveComments: trueso that webpack magic comments survive the loader phase.Before / After
Context
Fotocasa wants to implement TypeScript in their project and the removal of magic comments causes that chunking does not work properly for CSS, producing flickering in dev and broken production bundles.
Impact analysis
minify: truehas been removed. This is safe because production minification is handled independently by TerserPlugin/esbuild in a later webpack phase (sui-bundler/shared/minify-js.js).sui-bundlerpassespreserveComments: true. Other callers (sui-js-compiler,sui-test) are unaffected — they get the same behaviour as before minus the redundant SWC-level minification.