-
-
Notifications
You must be signed in to change notification settings - Fork 929
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
Fix handling of plugins that are hybrid CommonJS and ESM packages #7460
Comments
I'll take a look on this. |
Updates on this? |
@henryruhs Can you provide more details on the problem in your plugin? What do you expect? |
|
From my knowledge, the hybrid approach that I picked is valid. Stylelint ignores the ESM module entry point. I'm probably too much of a TypeScript person and remember that "exports" are not supported. Edit: will update to exports. |
@JounQin I reopen the issue... this is loading the common.js version again.
There is a problem on your side... I give up on sorting this out and now will export ESM only for my plugin. |
Thanks for your investigation, I'm taking a look. |
@JounQin You can used my failed approach: https://www.npmjs.com/package/@isnotdefined/stylelint-plugin/v/4.0.0-fix.1 |
@henryruhs OK The {
"exports": {
"require": "./index.cjs",
"import": "./index.js"
}
} After fixing the |
There is no need for the ./ as the files are in the root. The code of |
No, The issue here is, |
I disagree... the problem is not resolving the path - it's selecting the wrong package. |
Did you see my comments?
|
Don't use packages by this guy, he created thousands of them and there is no chance he can maintain all of them. |
@henryruhs Just to be sure, |
@ybiquitous That only resolves on the plugin's side with pure ESM only support, hybrid package will still warn about the deprecation message. |
5.0.0 did not actually resolve it, just limited it to ESM to make it work. |
Can you provide a reproducible demo/code with |
There is this tiny Angular playground that I just updated via my smartphone. It uses my stylelint config which loads the stylelint plugin. |
Notice, |
Thanks. I can now reproduce the deprecation warning with the patched --- node_modules/@isnotdefined/stylelint-plugin/package.json.orig 2024-02-21 13:20:26
+++ node_modules/@isnotdefined/stylelint-plugin/package.json 2024-02-21 13:19:57
@@ -62,7 +62,7 @@
},
"exports":
{
- "require": "index.cjs",
- "import": "index.js"
+ "require": "./index.cjs",
+ "import": "./index.js"
}
}
{
"dependencies": {
"@isnotdefined/stylelint-plugin": "4.0.0-fix.1",
"stylelint": "16.2.1"
}
}
{
"plugins": ["@isnotdefined/stylelint-plugin"],
"rules": {"@isnotdefined/no-disable": true}
} Run: $ echo 'a{}' | npx stylelint
CommonJS plugins are deprecated ("/Users/masafumi.koba/tmp/foo/node_modules/@isnotdefined/stylelint-plugin/index.cjs"). See https://stylelint.io/migration-guide/to-16 So, I understand the problem that $ node -pe "require('resolve-from').silent(process.cwd(), '@isnotdefined/stylelint-plugin')"
/Users/masafumi.koba/tmp/foo/node_modules/@isnotdefined/stylelint-plugin/index.cjs |
Yes, that's what I said at #7460 (comment) |
FYI: this happens with the
Using |
What minimal example or steps are needed to reproduce the bug?
The stylelint plugin that I build with rollup outputs a
index.cjs
andindex.mjs
file.In
package.json
file:Package structure
What did you expect to happen?
Stylelint 15 takes the
cjs
file and Stylelint 16 themjs
fileWhat actually happened?
Related issue: isnotdefinedcom/stylelint-plugin#14
The text was updated successfully, but these errors were encountered: