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
[WIP] Allow the open source orchestra to be injected with closed source components #620
base: main
Are you sure you want to change the base?
Conversation
@@ -8,6 +8,11 @@ module.exports = override( | |||
// the metronome design system has not been compiled before exporting. | |||
path.resolve('node_modules/@b12/metronome'), | |||
path.resolve('src/') | |||
]) | |||
]), | |||
addWebpackExternals({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes the React/ReactRedux packages from the build phase, so that all apps would rely on the global React/ReactRedux package in the global object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add this as an explanatory comment :)
c507f92
to
45c6ca9
Compare
######## | ||
|
||
Below, we'll walk through the frontend portion of the codebase written in | ||
React. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React. | |
React. Note: the current Orchestra frontend is written in Angular.js. This | |
document describes a currently experimental migration to React. |
*********** | ||
|
||
The frontend codebase uses the create-react-app starter as the base, so as to | ||
ease the configuration process. As of current, we use an add-on called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ease the configuration process. As of current, we use an add-on called | |
ease the configuration process. We currently use an add-on called |
The frontend codebase uses the create-react-app starter as the base, so as to | ||
ease the configuration process. As of current, we use an add-on called | ||
``customize-cra`` to customize some of the webpack features that we need, so that | ||
we don't have to 'eject' from create-react-app just to use those functionality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have to 'eject' from create-react-app just to use those functionality. | |
we don't have to 'eject' from create-react-app just to use that functionality. |
``customize-cra`` to customize some of the webpack features that we need, so that | ||
we don't have to 'eject' from create-react-app just to use those functionality. | ||
|
||
Features that we use as of current: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Features that we use as of current: | |
Features that we override: |
|
||
Features that we use as of current: | ||
- ``babelInclude`` - this is to include compilation of our open-source design | ||
system, as we do not precompile the design system before releasing an npm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
system, as we do not precompile the design system before releasing an npm | |
system (`metronome`), as we do not precompile the design system before | |
releasing an npm |
package. | ||
- ``addWebpackExternals`` - this allows us to exclude certain packages from the | ||
webpack compilation. Right now, we are excluding React, ReactDOM, and ReactRedux | ||
as these packages are depended on for both the closed source portion of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as these packages are depended on for both the closed source portion of the | |
so as to not duplicate the import of these packages in both the open and | |
closed source portions of the |
****************************** | ||
|
||
We integrate Orchestra with our closed-source product, and we had to figure out | ||
a way to inject closed source components in the open source world. Here are some |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a way to inject closed source components in the open source world. Here are some | |
a way to inject closed source step components in the open source shell. Here is how to |
|
||
We integrate Orchestra with our closed-source product, and we had to figure out | ||
a way to inject closed source components in the open source world. Here are some | ||
advice on how you can implement this feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
advice on how you can implement this feature. | |
implement this for your closed source step components. |
The closed source portion of the codebase would be compiled, and the compiled | ||
scripts would be included in the open source portion of the codebase. We include | ||
these scripts programmatically, by injecting the script tags into the compiled | ||
``index.html`` You can customize which scripts to be injected by modifying the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...modifying the VARIABLE_NAME variable of the orchestra/settings.py
file.
return render(request, 'orchestra/newindex.html') | ||
return render(request, 'orchestra/newindex.html', { | ||
'javascript_includes': [ | ||
_get_script_tag(static(file)) for file in ORCHESTRA_JS_INCLUDES |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we not need css here?
@@ -0,0 +1,5 @@ | |||
ORCHESTRA_JS_INCLUDES = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples go in
/example_project/example_project/settings.py :)
@@ -0,0 +1,6 @@ | |||
interface Window { | |||
orchestra?: { | |||
tasks: React.FC<{ id: string }>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a similar format to the Angular version
orchestra:
workflows:
workflow_slug:
version_slug:
step_slug:
Component
e.g.,
window.orchestra.workflows.example_workflow.v3.example_step = StepComponent
This PR extends the functionality of the new Orchestra frontend to allow closed source components to be injected in the respective places, and to use a singular source of React and ReactRedux packages so that both the open source and the closed source can share the same package.