Skip to content

tailwindcss-language-server crashes on projects using #/* Node.js package imports #1596

Description

@youyoumu

What version of Tailwind CSS IntelliSense are you using?

"@tailwindcss/language-server": "^0.14.29",

What version of Tailwind CSS are you using?

"tailwindcss": "^4.3.0",

What package manager are you using?

pnpm

What operating system are you using?

Linux, NixOS

Tailwind CSS Stylesheet (v4) or config file (v3)

main.css

@layer theme, base, components, utilities.daisyui.component;
@import "tailwindcss";
@import "./daisyui.css";
@import "./theme.css";
@import "./base.css";
@import "./components.css";
@import "./utilities.css";
@import "./tailwind-property.css";
@import "./dictionary.css";
@import "./configurable.css";
@source "..";
/*...*/

daisyui.css

@plugin "./daisyui-shim.ts" {
  root: "#kiku-root";
  themes: all;
  include:
    properties, reset, rootcolor, rootscrollgutter, rootscrolllock, svg, scrollbar, button, input,
    label, fieldset, select, alert, badge, toast, collapse, status, toggle, list, loading, range,
    tooltip, divider, modal, indicator, tab;
}
/*...*/

daisyui-shim.ts

import type { PluginAPI } from "tailwindcss/plugin";
import daisyui from "daisyui";
import { daisyUIThemes, type DaisyUITheme } from "#/src/lib/theme";
type CssInJs = Parameters<PluginAPI["addBase"]>[0];
//...

package.json

{
  "name": "@repo/note",
  "version": "1.10.2",
  "private": true,
  "type": "module",
  "imports": {
    "#/*": "./*"
  }
}

Describe your issue

The language server crashes with

{
      "jsonrpc": "2.0",
      "method": "window/logMessage",
      "params": {
        "type": 1,
        "message": "Unable to load plugin: ./daisyui-shim.ts Error: Request should not start with \"#/\"\n    at PAe (/home/yym/repos/kiku/node_modules/.pnpm/@tailwindcss+language-server@0.14.29/node_modules/@tailwindcss/language-server/bin/tailwindcss-language-serve

The LSP bundles enhanced-resolve@^5.16.1. The function assertImportsFieldRequest in lib/util/entrypoints.js rejects import specifiers starting with #/,

function PAe(e) {
  if (e.charCodeAt(0) !== xAe) throw new Error('Request should start with "#"');
  if (e.length === 1) throw new Error("Request should have at least 2 characters");
  if (e.charCodeAt(1) === Rd) throw new Error('Request should not start with "#/"');
  if (e.charCodeAt(e.length - 1) === Rd) throw new Error("Only requesting file allowed");
  return e.slice(1);
} 

Node.js allow subpath import since nodejs/node#60864.
And enhanced-resolve allow them as valid subpath import patterns since webpack/enhanced-resolve#468, released in v5.18.4 .

Suggested fix

Bump the bundled enhanced-resolve from ^5.16.1 to ^5.18.4 (or later)

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