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

Enable usage of this plugin by release-it's require based system #160

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

rwjblue
Copy link
Collaborator

@rwjblue rwjblue commented Oct 15, 2021

Since the move to type: modules in package.json this package no longer
works within release-it's normal plugin resolution / resolving steps
(because it is internally using import-from which is basically just
doing require relative to the current working directory; and you can't
require a ES modules based file).

This adds a very simple wrapper script and leverages the pre-existing
static async method isEnabled on the plugin instance to absorb async
from a dynamic import() expression. The PluginClass.isEnabled() hook
is always called before new PluginClass is called, so this system of
absorbing the async in isEnabled then returning an instance of "the
real plugin" from the fake plugin's constructor is pretty safe.

@rwjblue rwjblue added the bug Something isn't working label Oct 15, 2021
Since the move to `type: modules` in package.json this package no longer
works within `release-it`'s normal plugin resolution / resolving steps
(because it is internally using `import-from` which is basically just
doing `require` relative to the current working directory; and you can't
`require` a ES modules based file).

This adds a very simple wrapper script and leverages the pre-existing
static async method `isEnabled` on the plugin instance to absorb async
from a dynamic `import()` expression. The `PluginClass.isEnabled()` hook
is always called before `new PluginClass` is called, so this system of
absorbing the async in `isEnabled` then returning an instance of "the
real plugin" from the fake plugin's constructor is pretty safe.
@rwjblue rwjblue merged commit 237a61f into master Oct 15, 2021
@rwjblue rwjblue deleted the add-cjs-wrapper branch October 15, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant