-
Notifications
You must be signed in to change notification settings - Fork 975
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSC: Work around an issue in Rollup (#9153)
Rollup would print warnings about "use client" and then also about not being able to use source maps to show the location of that error. This is a known issue with Rollup: rollup/rollup#4699 The recommended way to handle the functionality is with the "banner" Rollup plugin, which we already did. The also recommend just filtering out the warning, which is what this PR does
- Loading branch information
Showing
7 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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,22 @@ | ||
import type { LoggingFunction, RollupLog } from 'rollup' | ||
|
||
// Upstream issue: https://github.com/rollup/rollup/issues/4699 | ||
export function onWarn(warning: RollupLog, defaultHandler: LoggingFunction) { | ||
const fileName = warning.loc?.file | ||
|
||
if ( | ||
warning.code === 'MODULE_LEVEL_DIRECTIVE' && | ||
/"use (client|server)"/.test(warning.message) | ||
) { | ||
return | ||
} else if ( | ||
warning.code === 'SOURCEMAP_ERROR' && | ||
(fileName?.endsWith('.tsx') || fileName?.endsWith('.ts')) && | ||
warning.loc?.column === 0 && | ||
warning.loc?.line === 1 | ||
) { | ||
return | ||
} | ||
|
||
defaultHandler(warning) | ||
} |
This file contains 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 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 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 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