Skip to content

Plugin loader: derive id from parent directory when module basename is generic (plugin.js/index.js) #596

Description

@melvincarvalho

What happens

The loader derives a plugin's id from the module basename. The natural out-of-tree convention is <name>/plugin.js, so every plugin derives the id plugin, and the (correct) duplicate-id guard refuses to boot until each entry carries an explicit id.

Repro

createServer({ plugins: [
  { module: 'relay/plugin.js', prefix: '/relay' },
  { module: 'webrtc/plugin.js', prefix: '/webrtc' },
] })
// → duplicate plugin id 'plugin'

Evidence

All 32 plugins in https://github.com/JavaScriptSolidServer/plugins hit this; compose.test.js and serve.js there carry 32 hand-written id: fields solely to dodge it. See REPORT.md ("Five loader/core bugs", #1).

Suggested fix

When the basename is generic (plugin, index), derive the id from the parent directory: relay/plugin.jsrelay. Backward-compatible (explicit id still wins); removes the most common plugin-author footgun.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpluginCould be implemented as a plugin (#206); core/plugin line defined in #564

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions