Skip to content

Add support for both CJS/ESM plugins#2876

Merged
Harjun751 merged 5 commits into
MarkBind:masterfrom
Harjun751:plugin-pains
Mar 30, 2026
Merged

Add support for both CJS/ESM plugins#2876
Harjun751 merged 5 commits into
MarkBind:masterfrom
Harjun751:plugin-pains

Conversation

@Harjun751

@Harjun751 Harjun751 commented Mar 28, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Resolves #2867

Can consider closing #2851

Overview of changes:
(Scope of this PR shifted quite a bit, but ultimately it's still addressing the same )

Updates plugin loading logic to load .cjs/.esm files, allowing for more flexibility when mixing modules in the markbind plugin directory.

Adds a new test site to test out all possible configurations of scopes and plugin modules.

Adds documentation on how to manage the different module systems with plugins. Bump minor version of node in user guide.

Check out the deploy preview's "Writing Plugins" page for the changes

Details image

Anything you'd like to highlight/discuss:

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add support for both CJS/ESM plugins

Let's

  • Update plugin loading to allow for .cjs/.mjs extensions
  • Add a new test site to test custom plugin configurations
  • Update documentation on writing custom ESM/CJS plugins
  • Bump minor node version in user guide to
    allow for ESM loading using require

Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Reviewer checklist:

Indicate the SEMVER impact of the PR:

  • Major (when you make incompatible API changes)
  • Minor (when you add functionality in a backward compatible manner)
  • Patch (when you make backward compatible bug fixes)

At the end of the review, please label the PR with the appropriate label: r.Major, r.Minor, r.Patch.


Breaking change release note preparation (if applicable):

  • To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:

  • what was the old feature that was made obsolete
  • any replacement feature (if any), and
  • how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

@codecov

codecov Bot commented Mar 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.04%. Comparing base (b641bc9) to head (a698212).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
packages/core/src/plugins/PluginManager.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2876   +/-   ##
=======================================
  Coverage   71.04%   71.04%           
=======================================
  Files         131      131           
  Lines        7117     7119    +2     
  Branches     1683     1653   -30     
=======================================
+ Hits         5056     5058    +2     
- Misses       1961     2055   +94     
+ Partials      100        6   -94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Harjun751 Harjun751 requested a review from a team March 28, 2026 05:25

@gerteck gerteck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks for the PR, just some notes or possible nits

Comment thread docs/devGuide/development/writingPlugins.md
Comment thread docs/devGuide/development/writingPlugins.md
Documentation lists v22 as minimum node version.

Due to changes in ESM migration, core uses
`createRequire` to import custom plugins.
This can work with ESM, but it's locked
behind an experimental flag for the CLI.

List minimum version to v22.12 so users
can use custom ESM plugins without issues.
@Harjun751 Harjun751 changed the title Update documentation on custom CJS/ESM plugins Add support for both CJS/ESM plugins Mar 29, 2026
Comment thread packages/core/src/plugins/PluginManager.ts
@Harjun751 Harjun751 requested review from a team and gerteck March 29, 2026 09:46

@gerteck gerteck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a comment on the comment

Also, in the PR description, could you add if applicable:

Breaking change release note preparation (if applicable):
To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:
what was the old feature that was made obsolete
any replacement feature (if any), and
how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

An example is in #2622

Comment thread packages/core/src/plugins/PluginManager.ts Outdated
@Harjun751

Copy link
Copy Markdown
Contributor Author

LGTM, just a comment on the comment

Also, in the PR description, could you add if applicable:

Breaking change release note preparation (if applicable):
To be included in the release note for any feature that is made obsolete/breaking

Give a brief explanation note about:
what was the old feature that was made obsolete
any replacement feature (if any), and
how the author should modify his website to migrate from the old feature to the replacement feature (if possible).

An example is in #2622

Just tested, there's no breaking change in v6.0 vs now 👍

@Harjun751 Harjun751 merged commit cb0edbc into MarkBind:master Mar 30, 2026
12 checks passed
@github-actions github-actions Bot added the r.Minor Version resolver: increment by 0.1.0 label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

r.Minor Version resolver: increment by 0.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept both CJS and ESM for MarkBind plugins or just ESM

2 participants