-
Notifications
You must be signed in to change notification settings - Fork 115
fix(cli): warn when object-form manualChunks is detected #1046
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
48f0959
fix(cli): warn when object-form manualChunks is detected
kazupon 585ea99
fix(cli): change migration step
kazupon 53b9dcc
fix(cli): resolveConfig with silently
kazupon 908b16b
fix(cli): use runner configLoader to suppress Rolldown warnings in mi…
kazupon 181b34c
chore: update pnpm-lock.yaml for upstream vite dependency changes
kazupon 7b43b16
chore: update pnpm-lock.yaml for upstream rolldown dependency changes
kazupon 8187280
chore: update pnpm-lock.yaml to match pinned upstream versions
kazupon b5ed31e
fix(cli): check workspace packages for manualChunks compatibility
kazupon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
|
|
||
| import { checkManualChunksCompat } from '../compat.js'; | ||
| import { createMigrationReport } from '../report.js'; | ||
|
|
||
| describe('checkManualChunksCompat', () => { | ||
| it('should warn when manualChunks is an object', () => { | ||
| const report = createMigrationReport(); | ||
| checkManualChunksCompat({ manualChunks: { react: ['react', 'react-dom'] } }, report); | ||
| expect(report.warnings).toHaveLength(1); | ||
| expect(report.warnings[0]).toContain('Object-form'); | ||
| expect(report.warnings[0]).toContain('codeSplitting'); | ||
| }); | ||
|
|
||
| it('should not warn when manualChunks is a function', () => { | ||
| const report = createMigrationReport(); | ||
| checkManualChunksCompat({ manualChunks: () => undefined }, report); | ||
| expect(report.warnings).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should not warn when manualChunks is not set', () => { | ||
| const report = createMigrationReport(); | ||
| checkManualChunksCompat({}, report); | ||
| expect(report.warnings).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should not warn when output is undefined', () => { | ||
| const report = createMigrationReport(); | ||
| checkManualChunksCompat(undefined, report); | ||
| expect(report.warnings).toHaveLength(0); | ||
| }); | ||
|
|
||
| it('should handle array of outputs', () => { | ||
| const report = createMigrationReport(); | ||
| checkManualChunksCompat( | ||
| [{ manualChunks: () => undefined }, { manualChunks: { vendor: ['lodash'] } }], | ||
| report, | ||
| ); | ||
| expect(report.warnings).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('should only add one warning for multiple object-form outputs', () => { | ||
| const report = createMigrationReport(); | ||
| checkManualChunksCompat( | ||
| [{ manualChunks: { react: ['react'] } }, { manualChunks: { lodash: ['lodash'] } }], | ||
| report, | ||
| ); | ||
| expect(report.warnings).toHaveLength(1); | ||
| }); | ||
| }); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { addMigrationWarning, type MigrationReport } from './report.js'; | ||
|
|
||
| /** | ||
| * Check for Rolldown-incompatible manualChunks config patterns. | ||
| */ | ||
| export function checkManualChunksCompat(output: unknown, report: MigrationReport): void { | ||
| const outputs = Array.isArray(output) ? output : output ? [output] : []; | ||
| for (const out of outputs) { | ||
| if (out.manualChunks != null && typeof out.manualChunks !== 'function') { | ||
| addMigrationWarning( | ||
| report, | ||
| 'Object-form `build.rollupOptions.output.manualChunks` is not supported by Rolldown. ' + | ||
| 'Convert it to function form or use `build.rolldownOptions.output.codeSplitting`. ' + | ||
| 'See: https://rolldown.rs/options/output#manualchunks and https://rolldown.rs/in-depth/manual-code-splitting', | ||
| ); | ||
| break; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.