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

chore: Allow external extensions to include their own package.json files #26004

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

kgabryje
Copy link
Member

SUMMARY

Superset supports external frontend extensions by registering them in superset-frontend/src/setup/setupExtensions.ts. However, the extensions could not easily add their own dependencies to superset's dependencies. This PR allows external extensions to install new dependencies by including package.json file within superset-frontend/src/setup tree (not necessarily root level, it will work with path such as superset-frontend/src/setup/my-cool-extension-dir/package.json).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

  1. Run npm install or npm ci when there is no package.json file under src/setup dir - there should be no changes to node_modules nor package-lock.json
  2. Create a "fake" extension dir under src/setup and create a package.json file in it, e.g. src/setup/my-extension/package.json. Add some dependencies to it and run npm install or npm ci. Verify that the new dependencies were installed correctly

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@john-bodley
Copy link
Member

@kgabryje how do we perceive handling dependencies conflicts (due to custom extensions) with Superset dependencies?

CC: @justinpark

@kgabryje
Copy link
Member Author

kgabryje commented Nov 17, 2023

@kgabryje how do we perceive handling dependencies conflicts (due to custom extensions) with Superset dependencies?

@john-bodley The way we do it in Preset is we use Superset's dependencies as extension's peer dependencies and generate a package-lock.json. That ensures that there are no new deps added.
However, if you don't do that and there are some conflicting dependencies (like your extension has a dependency that uses react 18 as its dependency), then a separate node_modules for your extension will get generated, which will contain the deps that it could not resolve from the main superset's package-lock.

@john-bodley
Copy link
Member

@justinpark and @michael-s-molina you're probably better suited for processing @kgabryje's #26004 (comment).

@michael-s-molina
Copy link
Member

@kgabryje I noticed that we have many setup files in src/setup that are not related to extensions but general setup of Superset. What do you think about creating a src/extensions folder to put the extensions? This folder could contain a README file with instructions on how to setup the extensions, how to handle dependencies, etc.

@kgabryje
Copy link
Member Author

@kgabryje I noticed that we have many setup files in src/setup that are not related to extensions but general setup of Superset. What do you think about creating a src/extensions folder to put the extensions? This folder could contain a README file with instructions on how to setup the extensions, how to handle dependencies, etc.

I agree that extensions deserve their own folder, but I'm afraid that such change of structure might be a breaking change for some orgs. For example, Preset's build process assumes that extension-related files are in src/setup. I propose we add this refactor to a list of tasks for 4.0

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kgabryje kgabryje merged commit b5e7e70 into apache:master Nov 21, 2023
27 checks passed
josedev-union pushed a commit to Ortege-xyz/studio that referenced this pull request Jan 22, 2024
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
sfirke pushed a commit to sfirke/superset that referenced this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants