Skip to content

feat(core): add userStyle option to ensure highest priority, closes #1110#1695

Open
Mister-Hope wants to merge 1 commit intomainfrom
user-style
Open

feat(core): add userStyle option to ensure highest priority, closes #1110#1695
Mister-Hope wants to merge 1 commit intomainfrom
user-style

Conversation

@Mister-Hope
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings March 20, 2026 01:18
@coveralls
Copy link

Pull Request Test Coverage Report for Build 23324886226

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 75.086%

Totals Coverage Status
Change from base Build 23282024048: -0.05%
Covered Lines: 736
Relevant Lines: 980

💛 - Coveralls

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a userStyle theme option intended to inject a user-provided style file late in the client entry, so it has higher CSS precedence in the final bundle.

Changes:

  • Extend core types (ThemeObject, ThemeInfo, App) with an optional userStyle string.
  • Resolve userStyle through theme inheritance and attach it to the app instance.
  • Inject userStyle as an additional import in the generated @internal/clientConfigs temp module.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/core/src/types/theme.ts Adds userStyle?: string to theme typing and resolved theme info typing.
packages/core/src/types/app/app.ts Adds userStyle?: string onto the App type surface.
packages/core/src/app/setupAppThemeAndPlugins.ts Copies resolved themeInfo.userStyle onto app.userStyle.
packages/core/src/app/resolveThemeInfo.ts Attempts to merge userStyle through theme inheritance.
packages/core/src/app/prepare/prepareClientConfigs.ts Adds an import for app.userStyle in the generated client configs entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 30 to 34
themeObject.templateBuildRenderer ??
parentThemeInfo.templateBuildRenderer,
templateDev: themeObject.templateDev ?? parentThemeInfo.templateDev,
userStyle: themeObject.userStyle ?? parentThemeInfo.userStyle,
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveThemeInfo() never includes userStyle in the base themeInfo object, so themes that do not extend a parent theme will always end up with app.userStyle as undefined even if themeObject.userStyle is set. Include userStyle: themeObject.userStyle in the initial themeInfo (and/or ensure the non-extends branch returns it).

Copilot uses AI. Check for mistakes.
Comment on lines 32 to 34
templateDev: themeObject.templateDev ?? parentThemeInfo.templateDev,
userStyle: themeObject.userStyle ?? parentThemeInfo.userStyle,
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new userStyle resolution logic should be covered by unit tests (there are already tests for resolveThemeInfo). Add cases asserting userStyle is returned for a theme with no parent, and that child themes correctly override / inherit userStyle from parents.

Copilot uses AI. Check for mistakes.
Comment on lines 17 to +20
(filePath, index) => `import * as clientConfig${index} from '${filePath}'`,
)
.join('\n')}
${app.userStyle ? `\nimport '${app.userStyle}'` : ''}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.userStyle is interpolated directly into a JS import string literal. If the path contains backslashes (Windows), quotes, or other escapable characters, it can produce invalid generated code. Prefer using JSON.stringify(app.userStyle) (and ideally the same for clientConfigFiles) when generating import specifiers so they are safely escaped.

Suggested change
(filePath, index) => `import * as clientConfig${index} from '${filePath}'`,
)
.join('\n')}
${app.userStyle ? `\nimport '${app.userStyle}'` : ''}
(filePath, index) => `import * as clientConfig${index} from ${JSON.stringify(filePath)}`,
)
.join('\n')}
${app.userStyle ? `\nimport ${JSON.stringify(app.userStyle)}` : ''}

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +101
/**
* Allow specifying user styles, which will be injected into client at the bottom
*/
userStyle?: string
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userStyle is assigned during app creation (setupAppThemeAndPlugins() is called from createDevApp/createBuildApp before app.init()), so placing it under AppPropertiesInitialized and documenting it as only available after initialization is misleading. Consider moving userStyle to AppPropertiesBase, or adjust the initialization flow/docs so it truly becomes available only after init().

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants