Fix false positive CJS deprecation warning for dual-package plugins#7532
Fix false positive CJS deprecation warning for dual-package plugins#7532ybiquitous merged 14 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 8911631 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@JounQin |
|
Also, I'm not sure why this PR could resolve #7460... |
|
I only enable This PR is not finally finished yet. |
Hum, this solution is not so good because the building becomes complex. 😕 |
|
@ybiquitous I'd like to skip building that |
|
Based on their names, |
@Mouvedia I don't think that helps for our situation.
If we don't want pure ESM dependency and don't want to keep |
|
I feel like it's better to unify stylelint/lib/utils/dynamicImport.mjs Line 11 in c49f9b5 |
|
Indeed, it seems we don't need (A failing case would be global plugins, should we support it for compatibility? |
Yes. I feel we can refactor |
|
It may be a quite big refactoring, though. |
|
@ybiquitous I have several solutions:
4 and 5 could be a huge task and may cause breaking change itself, and we're very likely to drop commonjs support in the next major version, I don't know is it worth. I personally want to try option 2. WDYT? |
|
@ybiquitous Any news? |
|
@JounQin Honestly, I don't want to use two build tools (rollup and esbuild) at the same time because of the dependency management and more complex build flow, which will no longer be necessary in the next major version. |
|
@ybiquitous I don't quite follow, so do you mean that issue should be marked as known issue? Then in next major release we'll migrate to pure ESM. And this PR doesn't add |
|
We have already used rollup. In addition, PR #7535 tries adding esbuild. I doubt if the way is a suitable solution for this problem.
I think non-breaking because |
So, this PR is simplest one to fix that issue.
Line 37 in c49f9b5 All utils are exported as public API. |
Not correct. The public API is exposed as |
|
So what is your preferred way to fix that issue considering the contribution cost? Notice: https://github.com/search?q=repo%3Astylelint%2Fstylelint%20getModulePath&type=code |
|
I prefer a way not to increase dependencies and not to bring a more complex build flow as much as possible. They often would produce maintenance problems. |
|
Did you mean you don't want And I don't quite understand, Whatever, I need to get what's the exact direction you want to move forward? |
|
Although To minimize potential side effects, I think we can fix the following code block, which loads a plugin function from a string: stylelint/lib/augmentConfig.mjs Lines 320 to 329 in c49f9b5 At the same time, we have to remove the following code: stylelint/lib/augmentConfig.mjs Lines 150 to 158 in c49f9b5 I imagine the updated code would be like this: if (typeof pluginLookup === 'string') {
- pluginImport = await dynamicImport(pluginLookup);
+ pluginImport = await importPlugin(pluginLookup);
}
// ...
async function importPlugin(lookup) {
// Using dynamicImport()...
// If dynamicImport() fails, try reading a file...
} |
|
But I don't think we can support global plugins without And also, we have many dependencies already, |
fix #7460
close #7535
I don't know how to keeplib/utils/getModulePath.mjsdifferent withlib/utils/getModulePath.cjsbecause they should use different strategies.This PR currently uses
@dual-bundle/import-meta-resolve, when we work on next major release which should be ESM only, we should change to use originalimport-meta-resolveinstead. This task should be added into #7396 if this PR is merged.