Skip to content

Passing empty string to any property creates "void 0" style when build-time optimizations are enabled #293

Description

@khmakoto

When build-time optimizations are enabled (both babel and webpack plugins), passing an empty string as the value of a CSS property generates a void 0 style that can cause errors when inserted into the stylesheet in certain environments.

For example, the code:

import { makeStyles } from '@griffel/react';

export const useStyles = makeStyles({
  test: {
    color: '',
  },
});

Produces output:

import { __styles } from '@griffel/react';
export const useStyles = /*#__PURE__*/__styles({
  "test": {
    "sj55zd": "fsj55zd"
  }
}, {
  "d": [void 0]
});
//# sourceMappingURL=useTestStyles.js.map

This is the error being thrown for a similar style in an app:

image

A possible solution would be to ignore rules like this, similar to how we ignore undefined values being passed to a property.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions