-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from rwjblue/add-cjs-wrapper
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// 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 | ||
|
||
// dynamic `import()` statements work on Node ^12.17.0 and >= 14; which | ||
// is within our support range; we can remove this inline disable | ||
// when https://github.com/mysticatea/eslint-plugin-node/pull/256 (or another | ||
// PR like it) lands | ||
|
||
// eslint-disable-next-line node/no-unsupported-features/es-syntax | ||
let RealPluginModule = await import('./index.js'); | ||
RealPlugin = RealPluginModule.default; | ||
} | ||
|
||
constructor(...args) { | ||
// now we just use the "real plugin" as is | ||
return new RealPlugin(...args); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters