diff --git a/cjs-wrapper.cjs b/cjs-wrapper.cjs new file mode 100644 index 0000000..cbeb2ae --- /dev/null +++ b/cjs-wrapper.cjs @@ -0,0 +1,17 @@ +// this will be populated inside the static `isEnabled` method just below +let RealPlugin; + +module.exports = class FakeCJSWrapperPlugin { + + static async isEnabled() { + // we use the async of this method to enable us to absorb the dynamic + // import statement + let RealPluginModule = await import('./index.js'); + RealPlugin = RealPluginModule.default; + } + + constructor(...args) { + // now we just use the "real plugin" as is + return new RealPlugin(...args); + } +} diff --git a/package.json b/package.json index 468bea2..330b6f3 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,12 @@ "release-it": "^14.11.6", "sinon": "^11.1.2" }, + "exports": { + ".": { + "import": "./index.js", + "require": "./cjs-wrapper.cjs" + } + }, "peerDependencies": { "release-it": "^14.0.0" }, @@ -54,7 +60,7 @@ }, "release-it": { "plugins": { - "./index.js": { + "./cjs-wrapper.cjs": { "infile": "CHANGELOG.md", "launchEditor": true }