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

Introducing the extensions Folder and the New Extension Scaffold #4111

Merged
merged 34 commits into from
May 7, 2024

Conversation

adrians5j
Copy link
Member

@adrians5j adrians5j commented May 5, 2024

Changes

For quite some time, we've had multiple approaches when it comes to locating custom code (plugins/extensions), where sometimes we'd be creating code inside of the apps/{project-application} folder , and sometimes outside of it, within a new yarn workspace, .e.g. packages/myPackage. Our docs contain examples with both approaches being used.

And not only that. Once a piece of code was written, users would still manually have to import it in an entrypoint file, like:

  • GraphQL API - apps/api/graphql/src/index.ts (a ~150 LOC file 🫢)
  • Admin - apps/admin/src/App.tsx

So, all in all, not only there wasn't a one-and-only approach of doing things / locating the code, but also, having to perform multiple steps in order to bring a plugin/extension to life was simply not ideal DX and error-prone.

With this PR, we are fixing this, by basically introducing the extensions folder in project root, and making it the central place where users will be creating their plugins/extensions. So, this way, users won't have to deal much (if at all) with the apps folder.

Note

Keeping users outside of the apps folder also helps with improving project upgrades (more stability).

Furthermore, users won't even have to register their plugins in mentioned entrypoint files, because, via the new New Extension scaffold that we're also introducing, this daunting step is automatically done for them.

exts-scaffoldds.mov

Other Changes

1. apps/theme -> extensions/theme

One other improvement we did here was moving the apps/theme folder into extensions/theme, so that, again, users have less reasons to go into the apps folder. Which also finally makes the apps folder only contain the actual project applications, which makes 100% sense:

image

2. Introducing the @webiny/api-serverless-cms Package

With this PR, we've also introduced the @webiny/api-serverless-cms package, which exports the plugin factories users often need while developing on the backend.

The main factories are createContextPlugin and createGraphQLSchemaPlugin, which will be now promoted as the standard way of extending on the backend. The main reason is that these factories automatically have the whole context object defined, so user's don't need to do anything in order to have the full auto complete and type-safety.

image

How Has This Been Tested?

Manually.

Documentation

Changelog. Docs. Videos.

adrians5j

This comment was marked as outdated.

@adrians5j adrians5j changed the title Scaffolding - API / Admin Plugins Extensions May 6, 2024
@adrians5j adrians5j marked this pull request as ready for review May 6, 2024 13:17
@adrians5j adrians5j changed the title Extensions Introducing the extensions Folder May 6, 2024
@adrians5j adrians5j changed the title Introducing the extensions Folder Introducing the extensions Folder and the New Extension Scaffold May 6, 2024
@adrians5j
Copy link
Member Author

/cypress

Copy link

github-actions bot commented May 7, 2024

Cypress E2E tests have been initiated (for more information, click here). ✨

@adrians5j adrians5j merged commit 0846888 into next May 7, 2024
91 checks passed
@adrians5j adrians5j added this to the 5.40.0 milestone May 15, 2024
@adrians5j adrians5j deleted the adrian/plugin-scaffolds branch July 5, 2024 07:01
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

Successfully merging this pull request may close these issues.

None yet

1 participant