Skip to content

Multiple versions of polka can't play nice #211

@43081j

Description

@43081j

In some cases, you may end up with something like this:

import {someApp} from 'wherever'; // Assume this package bundles polka, so it has its own copy
import polka from 'polka';

const server = polka();
const app = someApp();

app.server; // a Polka instance

server.use(app.server); // error since `!(app.server instanceof Polka)`

you shouldn't run into this often since your package manager would usually de-dupe and you'd have a single polka version

however, its very possible something you depend on which consumes polka instances (or any polka types) is pinned to an older 1.x than you are for example.

to solve this, maybe instead of base instanceof Polka, we can brand the class and check for that instead (some sort of _$polkaVersion or something, so we can also only consume same-major instances)

} else if (typeof base === 'function' || base instanceof Polka) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions