windicss-intellisense icon indicating copy to clipboard operation
windicss-intellisense copied to clipboard

Error loading config with `Auto Rename Tag` installed

Open DaPotatoMan opened this issue 3 years ago • 20 comments

Problem: extension cant load the config file and thus doesn't work at all. If I use version 0.11.7 this error doesn't occur. Only happens if I upgrade.

Extension version: 0.15.1 Extension initial output:

⚠ WARN: SyntaxError: Unexpected token � in JSON at position 0
Windi CSS Intellisense is now active!
Output after I modify the config file (windi.config.ts)
⚠ WARN: SyntaxError: Unexpected token � in JSON at position 0
Windi CSS Intellisense is now active!
⚠ WARN: TypeError: Cannot read property 'visitors' of undefined
⚠ WARN: SyntaxError: Unexpected token � in JSON at position 0
⚠ WARN: Error: undefined: Must export a default export when using ES6 modules. 
 e:\Projects\Collaborations\vocal-web-app\windi.config.ts:0:0
Config file: (windi.config.ts)
import { defineConfig } from 'windicss/helpers';
export default defineConfig({
   darkMode: false,
   theme: {
      fontFamily: {
         sans: ['Inter', 'Roboto', 'sans-serif']
      },
      extend: {
         colors: {
            accent: '#6366f1'
         },
         textColor: {
            default: '#202020',
            'default-light': '#454545',
            inverse: '#fff'
         },
         backgroundColor: {
            default: '#f8f6f5',
            'default-elevated': '#fff',
            inverse: '#000'
         }
      }
   },
});

DaPotatoMan avatar May 19 '21 06:05 DaPotatoMan

I can't reproduce it. Using your attached config file, gives no errors for me.

alexanderniebuhr avatar May 19 '21 08:05 alexanderniebuhr

I can reproduce it on my eggsy/website repository. My config is below, I don't think there are any problems with it because it works, I just don't get autocompletion and all (I get class sorting though).

import { defineConfig } from "windicss/helpers"
import defaultTheme from "windicss/defaultTheme"

import lineClamp from "windicss/plugin/line-clamp"

export default defineConfig({
  darkMode: "class",
  theme: {
    fontFamily: {
      sans: ["Inter", ...defaultTheme.fontFamily.sans],
    },
  },
  plugins: [lineClamp],
})

Here are the errors I get when I save this exact same config file.

image

My extension's version is 0.16.2.

eggsy avatar May 19 '21 14:05 eggsy

@eggsy I use latest VS Code Insider. I just copied the config in windi.config.ts. And it works for me. Can you please open an simple html project folder and paste the windi.config.ts file in there. I want to make sure it is happening there too.

alexanderniebuhr avatar May 19 '21 14:05 alexanderniebuhr

@eggsy I use latest VS Code Insider. I just copied the config in windi.config.ts. And it works for me. Can you please open an simple html project folder and paste the windi.config.ts file in there. I want to make sure it is happening there too.

Yep, it's still the same, I tried upgrading my dependencies, upgrading typescript and re-installing the VSC Extension, nothing seems to work.

image

eggsy avatar May 19 '21 15:05 eggsy

/cc @voorjaar can you reproduce it? I can not reproduce it

alexanderniebuhr avatar May 19 '21 15:05 alexanderniebuhr

Extension works (autocomplete, etc.) if I remove the config file.

DaPotatoMan avatar May 19 '21 16:05 DaPotatoMan

Hmm yeah. So somehow there is a bug, don't know the cause yet

alexanderniebuhr avatar May 19 '21 16:05 alexanderniebuhr

/cc @voorjaar can you reproduce it? I can not reproduce it

I can't either, not sure what happened here.

voorjaar avatar May 19 '21 17:05 voorjaar

Huh? This is weird but it just started working. I don't know if it started working after the last release but I think I've tried it, didn't work. Somehow it works now. I didn't change anything in the config, I also didn't do anything to fix it. I just tried to clone and console.log the JSON.parse then saw there were no errors 😅. It's working now!

image

eggsy avatar May 19 '21 18:05 eggsy

Let's keep an eye on this for a while

alexanderniebuhr avatar May 19 '21 19:05 alexanderniebuhr

I think I may have found the cause (for me at least). It was the extension Auto Rename Tag by Jun Han. I found lines in prettier output that said it couldn't load and parse a JSON in that extension's folder. I disabled it and the WindiCSS extension started to work. @eggsy do you also use this extension (Auto Rename Tag)?

DaPotatoMan avatar May 20 '21 03:05 DaPotatoMan

Huh? This is weird but it just started working. I don't know if it started working after the last release but I think I've tried it, didn't work. Somehow it works now. I didn't change anything in the config, I also didn't do anything to fix it. I just tried to clone and console.log the JSON.parse then saw there were no errors 😅. It's working now!

image

It's weird, I didn't fix this either...

voorjaar avatar May 20 '21 05:05 voorjaar

Can confirm, once I deactivated the Auto Rename Tag by Jun Han it worked for me again.

bux avatar May 20 '21 05:05 bux

https://github.com/windicss/windicss-intellisense/issues/113 has also an issue with Auto Rename Tag.. I am not sure what's going on. But it seems that Extension does change the behavior of our extension a lot ..

alexanderniebuhr avatar May 20 '21 05:05 alexanderniebuhr

it not works for me when i add a windi.config.ts file at root dir of my project, it works when i remove the windi.config.ts file.

vscode version: 1.56.2 Extension version: 0.17.1

// windi.config.ts
import { defineConfig } from 'windicss/helpers'

export default defineConfig({
  darkMode: 'class', // or 'media'
})

amythos avatar May 24 '21 07:05 amythos

@amythos If you have the extension Auto Rename Tag by Jun Han installed, disable it.

DaPotatoMan avatar May 24 '21 08:05 DaPotatoMan

@DaPotatoMan i don't have the Auto Rename Tag extension

amythos avatar May 24 '21 10:05 amythos

I can confirm that the intellisense stops working when I enabled auto rename tag

king-11 avatar May 24 '21 16:05 king-11

@DaPotatoMan i don't have the Auto Rename Tag extension

can you provide reproduction steps in an separate issue please

alexanderniebuhr avatar May 24 '21 16:05 alexanderniebuhr

/cc @windicss/windicss tagging this as need guidance & upstream since it seems that the 3rd party extension Auto Rename Tag, hooks into something. I truly have no idea how to fix this, or what caused this issue, as far as I can tell, we use native VS Code API, the way it is documented.

alexanderniebuhr avatar May 24 '21 16:05 alexanderniebuhr