Skip to content

Accept both CJS and ESM for MarkBind plugins or just ESM #2867

@Harjun751

Description

@Harjun751

Related: #2851

With #2863 handled, MarkBind's core code is now outputting ESM. This means that custom plugins are now handled differently. We need to look into whether we can accept both CJS and ESM plugins from users without workarounds, or if we have to support just ESM officially (in which case we have to create a deprecation notice).

Technical information:
First, PluginManager.ts resolves the plugin path URL:

// Check the environment's node_modules folders
try {
const resolvedPluginPath = require.resolve(pluginName);
return resolvedPluginPath;
} catch (err) {

Then, Plugin.ts actually imports/requires it:

/**
* The plugin module
*/
// eslint-disable-next-line import/no-dynamic-require
this.plugin = require(pluginPath);

All this is done with createRequire

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions