Skip to content

esbuild-style-plugin can cause type issues for sass #7430

Description

@mattrunyon

Problem

The dependency esbuild-style-plugin installs @types/sass: ^1.43.1. This currently resolves to 1.45.0 which is a deprecation version that doesn't actually include any type files. In our project, this was causing typescript errors because it is trying to load the types from @types/sass globally since we didn't change a default tsconfig option.

The error message we received

error TS2688: Cannot find type definition file for 'sass'.
   The file is in the program because:
     Entry point for implicit type library 'sass'

Someone opened a PR to remove the types dependency, but it seems esbuild-style-plugin is abandoned. g45t345rt/esbuild-style-plugin#28

Potential Solution

I think moving esbuild-style-plugin to a dev dependency will prevent others from running into this. I'm not sure why it would need to be a regular dependency as there are other esbuild plugins as dev dependencies already in plotly.js.

Workaround/Fix for users

For anybody looking for a fix that doesn't need an update from plotly, we needed to add "types": ["node", "jest"] to compilerOptions in our tsconfig.json. This prevents the default behavior of looking at every @types module for global declarations which was causing the type error. In our case we only reference process and the Jest globals. You might need to add additional types depending on your project.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions