Skip to content

feat: Make 'mode' explicit with config #3183

Open

Description

@mhartington

Prerequisites

Describe the Feature Request

Provide a new entry to stencil.config that would allow for static analysis of @Components styleUrls.

Describe the Use Case

If you're making a component, you could provide different modes that are based on arbitrary values. All the component cares is that the styleUrl object has a key and a value.

For instance, take a component like this:

@Component({
 styleUrls: {
   web: 'component.web.scss',
   native: 'component.native.scss'
 }
})
export class MyComponent {}

While I may know styleUrls can only accept web or native as keys, the compile does not know this. Stencil's compiler could compare against a set of predefined modes that the user could pass in their config.

Describe Preferred Solution

Some solutions could be as simple as an array of strings.

export const config: Config = {
  globalStyle: 'src/styles/global.scss',
  modes: ['md', 'ios', ....]
}

Describe Alternatives

Alternatively, you could provide an object that would specify the mode plus if it's required or not.

export const config: Config = {
  globalStyle: 'src/styles/global.scss',
  modes: [{mode: 'md' }, {mode: 'ios', required: true}]
}

Where all modes are optional unless required is set to true.

Related Code

No response

Additional Information

No response

Activity

  1. added
    Request For Comments
    Feature: Want this? Upvote it!
    and removed on Dec 10, 2021
  2. rwaskiewicz commented on Dec 10, 2021

    @rwaskiewicz
    Member

    Thanks! I think this is an interesting use case that could benefit users. Labeling it for folks to upvote/add comments. Some input/thoughts I'd like from the community:

    • Does having required/optional fields provide value to the typings in your projects? (IE if you had such a config, would you always use every field in it/use if for typo checking?)
    • Would you want to enforce this uniformly across all directories?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Want this? Upvote it!Request For Comments

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions