Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions #30

Open
digitalsadhu opened this issue Mar 26, 2023 · 2 comments
Open

extensions #30

digitalsadhu opened this issue Mar 26, 2023 · 2 comments

Comments

@digitalsadhu
Copy link
Member

digitalsadhu commented Mar 26, 2023

We need a way to extend the base server setup with minimal configuration on behalf of the user. We are currently thinking that an approach that mirrors the structure of an app might be a good way to go.

The file structure for such an extension would look like this:

# Extensions

```bash
# plugin structure
/my-extension
    /package.json
    /server.js
    /build.js
    /config/schema.js
    /document.js
    /fallback.js
    /lazy.js
    /scripts.js
    /schemas/content.js

Some files would replace core functionality and in turn, if present would be replaced by files in the app if present. For example /document.js. Some files would be applied one after the other in the order core -> extension 1 -> extension 2 -> app For example server.js and build.js. Documentation would be used to make it clear which files override/are overridden and which files are applied one after another.

Installing an extension would be done by npm installing the extension along side the core podlet-server package like so

npm i @podium/podlet-server my-podlet-server-extension

And the extension itself would include a property in package.json that identifies it as a podlet server extension

// my-podlet-server-extension/package.json
{
    name: "",
    version: "",
    etc: "",
    "podium": {
        "podlet-server-extension": true,
    }
}

The podlet-server module will then scan the app's package.json for direct dependencies and check their package.json files for this extension key and, if found, pick up and load the various files contained in the package before checking the extensions own package.json for dependencies and checking those dependencies for any extension keys and loading loading them in as well if found. Finally, the podlet-server will load in the app itself.

@trygve-lie
Copy link
Contributor

This looks good to me.

Just wondering about this one:

    "podium": {
        "podlet-server-extension": true,
    }

could this be more suitable (considering we'll do some work on layouts too):

    "podium": {
        "extension": ["podlet-server"],
    }

In the therms of layouts; lets say we'll end up with multiple layouts but in terms of an extension it can span multiple layouts:

    "podium": {
        "extension": ["layout-express-server", "layout-nextjs-server"],
    }

@digitalsadhu
Copy link
Member Author

yeah I wondered if something more flexible might be more appropriate. This looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants