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
refactor(plugins): switched from require
to await import()
when loading plugins
#2558
Conversation
…oading plugins to isolate the conversion ahead of #2543
this obviously still needs clean up, but hoping to get some feedback. i'm not 100% i have my head around all that needs to change here, but assuming we change from however, the part that i did not anticipate is that the result does not appear to satisfy logging one of the example plugins from the tests shows the following, which i would expect to both satisfy
but it appears that the loaded module has some detail that i havent yet figured out that prevents it from satisfying |
this also got me thinking about how this situation of loading plugins potentially gets more complicated as we progress further. currently, only cjs plugins are expected. once we move to esm, we will want to support loading plugins that are also esm. loading with this partially comes to mind because i did consider if it could be worth considering using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes look good to me thus far
lib/plugins/index.js
Outdated
console.log({plugins: options.plugins}) | ||
console.dir(plugin, {depth: null}) | ||
console.log(isPlainObject(plugin)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a reminder to remove the debug logs when the PR is ready :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep 👍🏼
lib/plugins/index.js
Outdated
const [name, config] = parseConfig(plugin); | ||
plugin = isString(name) ? loadPlugin(context, name, pluginsPath) : name; | ||
? await castArray(options.plugins).reduce(async (plugins, plugin) => { | ||
const plugins2 = await plugins; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is a better name for plugins2
? Maybe normalizedPlugins
or awaitedPlugins
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, this is definitely part of the clean up that is necessary once this is working :)
and fixed paren grouping
… into async-import
i was able to resolve the previous issues by fixing the paren wrapping that i broke (this was the main problem) and using the |
however,
however, all tests, including integration tests pass in our supported node range from my checking. all scenarios within the dynamic import expression seem to be covered by tests as well. based on mysticatea/eslint-plugin-node#250, it sounds like the rule does not report correctly for this situation and is unlikely to be fixed soon. i hate to disable a rule like this and lose protection from other scenarios, but i'm unsure of a better approach for now. i'm open to suggestions |
…yntax` when loading plugins based on mysticatea/eslint-plugin-node#250
i went ahead and disabled the rule for that particular usage, since it seems like the best option, but open to alternative suggestions |
+1 for disabling. We can create a follow up issue to review once we concluded the ESM transition? Great work @travi 👏🏼 |
🎉 This PR is included in version 20.0.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 20.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
to isolate the conversion ahead of #2543