Skip to content

feat(compiler): add config.modes to validate mode-keyed styleUrls/styles#6790

Merged
johnjenkins merged 1 commit into
v5from
v5-modes-validation
Jul 22, 2026
Merged

feat(compiler): add config.modes to validate mode-keyed styleUrls/styles#6790
johnjenkins merged 1 commit into
v5from
v5-modes-validation

Conversation

@johnjenkins

@johnjenkins johnjenkins commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

What is the current behavior?

GitHub Issue Number: #3183

What is the new behavior?

Closes #3183

Adds an opt-in modes entry to stencil.config.ts. When set, the compiler validates that mode keys used in @Component({ styleUrls / styles }) match a declared allowlist, catching typos at build time instead of silently producing a style that never applies at runtime. Entries can also be marked required, enforcing that every component using mode-keyed styles supplies that mode.

Usage

// stencil.config.ts
export const config: Config = {
  modes: ['ios', { mode: 'md', required: true }],
};

// ✅ valid
@Component({
  tag: 'my-button',
  styleUrls: { ios: 'my-button.ios.css', md: 'my-button.md.css' },
})
export class MyButton {}

// ❌ compile error: Invalid mode "tyop" in "styleUrls". Valid modes are: ios, md.
@Component({
  tag: 'my-button',
  styleUrls: { ios: 'my-button.ios.css', tyop: 'my-button.tyop.css' },
})
export class MyButton {}

// ❌ compile error: Missing required mode: md.
@Component({
  tag: 'my-button',
  styleUrls: { ios: 'my-button.ios.css' },
})
export class MyButton {}

Documentation

Does this introduce a breaking change?

  • Yes
  • No

Testing

Other information

@johnjenkins
johnjenkins requested a review from a team as a code owner July 22, 2026 20:51
@johnjenkins
johnjenkins merged commit d383f49 into v5 Jul 22, 2026
29 checks passed
@johnjenkins johnjenkins changed the title feat(compiler): v5 config modes validation feat(compiler): add config.modes to validate mode-keyed styleUrls/styles Jul 22, 2026
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.

1 participant