Skip to content

Cannot read properties of undefined (reading 'localeCompare') #1112

Description

@nathanredblur

Environment

  • Linaria version:
    "@linaria/babel-preset": "^4.3.0",
    "@linaria/core": "^4.2.2",
    "@linaria/react": "^4.3.0",
    "@linaria/webpack-loader": "^4.1.8",
  • Bundler (+ version): "webpack": "^5.74.0"
  • Node.js version: node 16.15.0
  • OS: m1 mac OS 13.0.1

Description

I get an error on compile a file. Not sure how this happens because it is pointing to a file with no any CSS (in fact I'm just installing and I not have any linaria code anywhere)

ERROR in ./src/legacy/views/car/monthly_calendar_day_popup.js
Module build failed (from ../node_modules/@linaria/webpack-loader/lib/index.js):
TypeError: /Users/xxx/getaround/getaround-web/www/src/legacy/views/car/monthly_calendar_day_popup.js: Cannot read properties of undefined (reading 'localeCompare')

This error refer to this line of code
https://github.com/callstack/linaria/blob/master/packages/utils/src/scopeHelpers.ts#L395
where the node exist but does not have name

a.node?.name.localeCompare(b.node?.name)

this is what the node have:

{
  type: 'StringLiteral',
  value: '',
  trailingComments: [],
  leadingComments: [],
  innerComments: []
}

Reproducible Demo

not sure how to reproduce it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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