ModyQyW/vite-plugin-stylelint

nuxt 3 vs vite-plugin-stylelint 4.0.0

Closed this issue ยท 3 comments

amery commented

Describe the bug

for a reason I don't understand vite-plugin-stylelint 4.0.0 crashes nuxt 3 on start while 3.3.3 works fine

ERROR  Cannot start nuxt:  Cannot read properties of undefined (reading 'formatters')
at formatError (/home/amery/projects/xxxx/node_modules/.pnpm/vite@3.2.5_sass@1.56.2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40281:46)
  at Context.error (/home/amery/projects/xxxx/node_modules/.pnpm/vite@3.2.5_sass@1.56.2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40277:19)
  at L (/home/amery/projects/xxxx/node_modules/vite-plugin-stylelint/dist/index.js:2:1208)
  at async Context.buildStart (/home/amery/projects/xxx/node_modules/.pnpm/vite-plugin-stylelint@4.0.0_r2tgf73irdyaz3c772gabqao7i/node_modules/vite-plugin-stylelint/dist/index.js:2:2031)
  at async Promise.all (index 5)
  at async hookParallel (/home/amery/projects/xxxx/node_modules/.pnpm/vite@3.2.5_sass@1.56.2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40168:9)
  at async Object.buildStart (/home/amery/projects/xxxx/node_modules/.pnpm/vite@3.2.5_sass@1.56.2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:40439:13)
  at async /home/amery/projects/xxxx/node_modules/.pnpm/vite@3.2.5_sass@1.56.2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:62181:13
  at async Module.createServer (/home/amery/projects/xxxx/node_modules/.pnpm/vite@3.2.5_sass@1.56.2/node_modules/vite/dist/node/chunks/dep-5605cfa4.js:62206:9)
  at async buildClient (/home/amery/projects/xxxx/node_modules/.pnpm/@nuxt+vite-builder@3.0.0_qj7x6gp3rczsq4mh5nosxx3oaq/node_modules/@nuxt/vite-builder/dist/shared/vite-builder.1c88b3ee.mjs:299:24)

Reproduction

My integration is very simple, nuxt.config.ts looks like this:

import StylelintPlugin from "vite-plugin-stylelint";

const autoFix: boolean = false;

export default defineNuxtConfig({
  [...]

  vite: {
    server: {
      strictPort: true,
    },

    plugins: [
      StylelintPlugin({
        fix: autoFix,
      }),
    ],
  },
});

### System Info

```Shell
$ pnpx envinfo --system --binaries --browsers
.../../../.pnpm-store/v3/tmp/dlx-21225   |   +1 +
.../../../.pnpm-store/v3/tmp/dlx-21225   | Progress: resolved 1, reused 1, downloaded 0, added 1, done

  System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
    Memory: 13.78 GB / 31.02 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.18.1 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.9.0 - ~/projects/xxx/bin/npm

$ pnpm list
Legend: production dependency, optional only, dev only

xxxx@22.12.1+dev /home/amery/projects/xxxx/web/client (PRIVATE)

dependencies:
@xxx/xx-types link:../../src/packages/types
@nuxtjs-alt/proxy 2.1.2
@pinia/nuxt 0.4.6
@popperjs/core 2.11.6
bootstrap link:../../../../github.com/amery/bootstrap-ssr
bootstrap-vue-3 link:../../../../github.com/amery/bootstrap-vue-3-ssr/packages/bootstrap-vue-3
pinia 2.0.28

devDependencies:
@nuxtjs/eslint-config-typescript 12.0.0  nuxt 3.0.0                               stylelint-config-recommended-vue 1.4.0   
eslint 8.29.0                            postcss-html 1.5.0                       stylelint-prettier 2.0.0                 
eslint-config-prettier 8.5.0             prettier 2.8.1                           typescript 4.9.4                         
eslint-plugin-prettier 4.2.1             sass 1.56.2                              vite-plugin-eslint 1.8.1                 
eslint-plugin-ssr-friendly 1.2.0         stylelint 14.16.0                        vite-plugin-stylelint 4.0.0              
eslint-plugin-vue 9.8.0                  stylelint-config-prettier 9.0.4          
npm-run-all 4.1.5                        stylelint-config-recommended-scss 8.0.0  

[22:54:17] [amery@d4902d6312b5(pts/0)client]$ pnpm info vite

vite@4.0.0 | MIT | deps: 5 | versions: 391
Native-ESM powered web dev build tool
https://github.com/vitejs/vite/tree/main/#readme

bin: vite

dist
.tarball: https://registry.npmjs.org/vite/-/vite-4.0.0.tgz
.shasum: b81b88349a06b2faaa53ae14cf96c942548e3454
.integrity: sha512-ynad+4kYs8Jcnn8J7SacS9vAbk7eMy0xWg6E7bAhS1s79TK+D7tVFGXVZ55S7RNLRROU1rxoKlvZ/qjaB41DGA==
.unpackedSize: 3.2 MB

dependencies:
esbuild: ^0.16.3 fsevents: ~2.3.2 postcss: ^8.4.19 resolve: ^1.22.1 rollup: ^3.7.0   

maintainers:
- soda <npm@haoqun.me>
- vitebot <vitejs.twitter@gmail.com>
- yyx990803 <yyx990803@gmail.com>
- patak <matias.capeletto@gmail.com>
- antfu <anthonyfu117@hotmail.com>

dist-tags:
alpha: 4.0.0-alpha.6  beta: 4.0.0-beta.7    latest: 4.0.0         

published yesterday by vitebot <vitejs.twitter@gmail.com>

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Thanks for your report! I am on my weekend so I am a bit late.

It may be caused by import, which is kind of different under esm and commonjs.

Can you please try v4.0.1 and tell me if it is fine?

amery commented

Thanks for your report! I am on my weekend so I am a bit late.

It may be caused by import, which is kind of different under esm and commonjs.

I'm told using unbuild helps a lot with that

Can you please try v4.0.1 and tell me if it is fine?

I can confirm 4.0.1 doesn't blow up my Nuxt ๐ŸŽ‰๐ŸŽ‰

Thank you! @ModyQyW

I'm told using unbuild helps a lot with that

I will give it a try, but later.

I can confirm 4.0.1 doesn't blow up my Nuxt ๐ŸŽ‰๐ŸŽ‰

Glad to see that ๐ŸŽ‰