cursor icon indicating copy to clipboard operation
cursor copied to clipboard

Package Exports Resolution Issue with CSS Imports

Open DmitrySharabin opened this issue 10 months ago • 0 comments

Description

Cursor IDE doesn't properly resolve package exports for CSS imports, particularly when working with locally linked packages. When trying to import a CSS file using the package's defined exports path, the IDE suggests creating a new file instead of resolving to the correct location.

Steps to Reproduce

  1. Create two projects in the same parent directory:

    workspace/
    ├── my-project/        # Main project
    └── my-ui-lib/         # Local package
    
  2. Set up the local package my-ui-lib with the following structure:

    my-ui-lib/
    ├── package.json
    ├── dist/
    │   └── styles/
    │       └── theme.css
    
  3. In my-ui-lib/package.json, define exports:

    {
      "name": "my-ui-lib",
      "exports": {
        "./styles/*": "./dist/styles/*.css"
      }
    }
    
  4. In your main project's (my-project/package.json):

    {
      "dependencies": {
        "my-ui-lib": "file:../my-ui-lib"
      }
    }
    
  5. Create a CSS file in your main project:

    @import "my-ui-lib/styles/theme.css";
    
  6. Try to command-click (or ctrl-click) the import path

Current Behavior

The IDE suggests creating a new file at my-ui-lib/styles/theme.css instead of resolving to the actual file location at my-ui-lib/dist/styles/theme.css.

Expected Behavior

The IDE should resolve the import to my-ui-lib/dist/styles/theme.css based on the package exports mapping in the package.json.

Environment

  • OS: darwin 24.4.0
  • Cursor Version: 0.49.4

Additional Context

  • Both projects must be in the same parent directory for the local package linking to work
  • The file exists at the correct location (node_modules/my-ui-lib/dist/styles/theme.css)
  • The package exports mapping is correctly defined in the package.json
  • This appears to be specific to CSS imports and locally linked packages

DmitrySharabin avatar Apr 23 '25 10:04 DmitrySharabin