Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest [email protected] doesn't work well with meow@10 (from latest stylelint v15.10.1) #260

Open
2 tasks done
tryforceful opened this issue Jul 14, 2023 · 8 comments · May be fixed by #294
Open
2 tasks done

latest [email protected] doesn't work well with meow@10 (from latest stylelint v15.10.1) #260

tryforceful opened this issue Jul 14, 2023 · 8 comments · May be fixed by #294

Comments

@tryforceful
Copy link

Describe the bug

The latest Stylelint v15.10.1 now uses meow@^10, updating to that version to remove a recently announced semver vulnerability from the dependency tree.

However, using meow@10 with the latest vite-plugin-checker generates errors for me when trying to build with Vite:

TypeError [Error]: The `importMeta` option is required. Its value must be `import.meta`.
    at meow (/poc--20230714-meow-vite-plugin-checker/node_modules/.pnpm/[email protected]/node_modules/meow/index.js:111:9)
    at translateOptions (/poc--20230714-meow-vite-plugin-checker/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/options.js:5:18)
    at Object.configureServer (/poc--20230714-meow-vite-plugin-checker/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/main.js:34:39)
    at MessagePort.<anonymous> (/poc--20230714-meow-vite-plugin-checker/node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/vite-plugin-checker/dist/esm/worker.js:57:26)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:323:10)
    at [kOnMessage] (node:internal/worker:334:37)
    at MessagePort.<anonymous> (node:internal/worker:229:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

It seems likely to me that the reason is because the breaking changes to meow@10 are that the package is fully ESM now:
https://github.com/sindresorhus/meow/releases/tag/v10.0.0

Using meow@9 doesn't generate this error for me.

Reproduction

See minimal repro at this repo: https://github.com/tryforceful/poc--20230714-meow-vite-plugin-checker

Try to build that package with pnpm i; pnpm dev and it will generate the above error.

If you comment out these lines in the vite.config.js which enable vite-plugin-checker:

    // Comment me out to disable the error
    checker({
      stylelint: {
        lintCommand: 'stylelint ./src/style.css',
      },
    })

the error also goes away, showing that vite-plugin-checker is having difficulty using the implicit dependency meow@10 from stylelint.

Note that running stylelint alone in this repo also works fine.

Expected behavior

I expect no error when running pnpm dev while using the latest vite-plugin-checker and stylelint (v15.10.1)

System Info

System:
    OS: macOS 12.6.3
    CPU: (10) arm64 Apple M1 Pro
    Memory: 245.20 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.2.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.6.6 - /usr/local/bin/npm
    pnpm: 8.6.7 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 15.6.1
  npmPackages:
    vite-plugin-checker: 0.6.1 => 0.6.1

Additional context

See #255 where upgrading meow is also being requested

Validations

  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@tryforceful
Copy link
Author

This has been slowly getting 👍🏼s and it's been a month, any update?

@tryforceful
Copy link
Author

😬😬😬

@Reloaded2
Copy link

Any updates here? Thanks

@jeron-diovis
Copy link

jeron-diovis commented Nov 8, 2023

For those who's waiting for this fix, for time being you can bypass this with explicit deps overriding.

With yarn:

"resolutions": {
  "meow": "^9.0.0"
}

With npm it's overrides.

@strawberry-choco
Copy link

Any updates? Stylelint 16 is using meow ^13.0.0. Pinning meow to version 9 is not a permanent solution.

@Miofly
Copy link

Miofly commented May 15, 2024

same issue,how to resolve

@luck-hao
Copy link

same issue,how to resolve?

@DonnyVerduijn
Copy link

You can patch vite-plugin-checker, in order to make it compatible with newer versions of meow:

diff --git a/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/options.js b/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/options.js
index 1fa4fb8..4788fcb 100644
--- a/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/options.js
+++ b/node_modules/vite-plugin-checker/dist/esm/checkers/stylelint/options.js
@@ -5,6 +5,7 @@ const translateOptions = async (command) => {
   const result = meow({
     autoHelp: false,
     autoVersion: false,
+    importMeta: import.meta,
     help: `
     Usage: stylelint [input] [options]
     Input: Files(s), glob(s), or nothing to use stdin.
@@ -90,7 +91,7 @@ const translateOptions = async (command) => {
 	`,
     flags: {
       allowEmptyInput: {
-        alias: "aei",
+        shortFlag: "aei",
         type: "boolean"
       },
       cache: {
@@ -118,60 +119,60 @@ const translateOptions = async (command) => {
         type: "string"
       },
       disableDefaultIgnores: {
-        alias: "di",
+        shortFlag: "di",
         type: "boolean"
       },
       fix: {
         type: "boolean"
       },
       formatter: {
-        alias: "f",
+        shortFlag: "f",
         default: "string",
         type: "string"
       },
       help: {
-        alias: "h",
+        shortFlag: "h",
         type: "boolean"
       },
       ignoreDisables: {
-        alias: "id",
+        shortFlag: "id",
         type: "boolean"
       },
       ignorePath: {
-        alias: "i",
+        shortFlag: "i",
         type: "string",
         isMultiple: true
       },
       ignorePattern: {
-        alias: "ip",
+        shortFlag: "ip",
         type: "string",
         isMultiple: true
       },
       maxWarnings: {
-        alias: "mw",
+        shortFlag: "mw",
         type: "number"
       },
       outputFile: {
-        alias: "o",
+        shortFlag: "o",
         type: "string"
       },
       printConfig: {
         type: "boolean"
       },
       quiet: {
-        alias: "q",
+        shortFlag: "q",
         type: "boolean"
       },
       reportDescriptionlessDisables: {
-        alias: "rdd",
+        shortFlag: "rdd",
         type: "boolean"
       },
       reportInvalidScopeDisables: {
-        alias: "risd",
+        shortFlag: "risd",
         type: "boolean"
       },
       reportNeedlessDisables: {
-        alias: "rd",
+        shortFlag: "rd",
         type: "boolean"
       },
       stdin: {
@@ -181,11 +182,11 @@ const translateOptions = async (command) => {
         type: "string"
       },
       version: {
-        alias: "v",
+        shortFlag: "v",
         type: "boolean"
       },
       globbyOptions: {
-        alias: "go",
+        shortFlag: "go",
         type: "string"
       }
     },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants