Generate dist/dynamic-modules.json for relevant packages#10046
Generate dist/dynamic-modules.json for relevant packages#10046dlabaj merged 3 commits intopatternfly:mainfrom
Conversation
|
Preview: https://patternfly-react-pr-10046.surge.sh A11y report: https://patternfly-react-pr-10046-a11y.surge.sh |
scripts/parse-dynamic-modules.js
Outdated
|
|
||
| /** @type {ts.CompilerOptions} */ | ||
| const defaultCompilerOptions = { | ||
| target: ts.ScriptTarget.ES2020, |
There was a problem hiding this comment.
I am wondering if it would be preferred to get some of the compiler options from https://github.com/patternfly/patternfly-react/blob/main/packages/tsconfig.base.json#L9-L12
There was a problem hiding this comment.
This code just parses the relevant info from package-specific build outputs, i.e. there is nothing emitted.
I've hardcoded the above TypeScript compiler option defaults to keep things simple and self-contained.
I see no problem with individual scripts defining their own options assuming they represent a separate build step, i.e. my understanding is that packages/tsconfig.base.json base config is mainly used for building the packages via Rollup.
I can try reusing some options from the base config as suggested, but it shouldn't have any impact on the generated dynamic-modules.json files.
|
@vojtechszocs @Hyperkid123 So i'm not sure this is accounting for next components correctly. |
|
@vojtechszocs I think the next/deprecated modules should not be listed. There are conflicting names and the API difference will cause unexpected issues. |
|
You are right, module paths containing either "next" or "deprecated" should be excluded. This issue also exists in OpenShift Console dynamic plugin SDK code (dynamic-module-parser.ts). I'll update this PR as well as relevant Console code. |
666d73c to
6c3bf4f
Compare
|
@nicolethoen PR updated, please have a look.
|
This PR modifies
scripts/build-single-packages.jsso that adist/dynamic-modules.jsonfile is generated for each package containing dynamic modules.We generate
dynamic-modules.jsonfiles to make it easier for consuming projects to share specific PatternFly dynamic modules (instead of sharing the whole package indexes) via webpack module federation.Each
dynamic-modules.jsonfile maps package index exports to their corresponding dynamic modules, for example:The algorithm that parses dynamic module information favors modules with most specific file paths, for example
dist/dynamic/components/Wizard/hooksis favored overdist/dynamic/components/Wizard.Dynamic modules nested under
deprecatedornextdirectories are ignored.Note: this code was ported from openshift/console#13521