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

[De angular] osd-ui-shared-deps #4666

Closed
ashwin-pc opened this issue Aug 3, 2023 · 2 comments
Closed

[De angular] osd-ui-shared-deps #4666

ashwin-pc opened this issue Aug 3, 2023 · 2 comments
Labels
de-angular de-angularize work v2.11.0

Comments

@ashwin-pc
Copy link
Member

osd-ui-shared-deps relies on angular and will need to be changed

@ananzh
Copy link
Member

ananzh commented Sep 11, 2023

How angular dependencies are imported in OpenSearch Dashboards

This package is used to ensure that the shared libraries are bundled once, loaded once, and then used everywhere

entry.js file is a central place where it lists all the shared dependencies.
index.js file is mapping file to map package to shared package.

Below is a summary about how angular dependencies are imported in OpenSearch Dashboards through osd-ui-shared-deps :

note: For angular related package in osd-ui-shared-deps specifically, we have 1) @osd/i18n/angular 2) angular. I will use angular as an example.

  • When webpack encounters the angular import, it looks into its configuration for how to handle the import of the angular.
  • index.js handles the mapping for webpack. For example, angular: '__osdSharedDeps__.Angular', tells webpack that imports 'angular' should be replaced with the global variable __osdSharedDeps__.Angular. The global variable __osdSharedDeps__ is defined in the bundled output due to webpack configuration:
output: {
    path: UiSharedDeps.distDir,
    filename: '[name].js',
    sourceMapFilename: '[file].map',
    devtoolModuleFilenameTemplate: (info) =>
      `osd-ui-shared-deps/${Path.relative(REPO_ROOT, info.absoluteResourcePath)}`,
    library: '__osdSharedDeps__',
    hashFunction: 'Xxh64',
  },
  • The entry.js file specifies how angular goes into __osdSharedDeps__: export const Angular = require('angular'). Here, the angular module is bundled into the __osdSharedDeps__ global variable under the .Angular property and imports will transfer to something like below to use the shared bundle:
const angular = window.__osdSharedDeps__.Angular;

Therefore, if we don't have angular and @osd/i18n/angular, we could simply clean the related parts.

Impact

OpenSearch Dashboards

As long as we clean out angular and @osd/i18n/angular, I don't see other impacts from cleaning osd-ui-shared-deps for OpenSearch Dashboards.

  • In OpenSearch Dashboards, for angular, we are using import directly. I don't see other similar usages like @osd/ui-shared-deps/theme, @osd/ui-shared-deps/monaco, UiSharedDeps.externals, UiSharedDeps.publicPathLoader and etc related to angular.
  • For Testing, we will clean out all angular related tests. Seems not a problem to me.
  • For Build Process, I am not aware of build process have any Angular-specific steps.

Third-party Plugins/Modules

Some of them might still rely on Angular. As we discussed in the morning, removing Angular from shared dependencies would break those plugins but since we are on the de-angular path for a long while we should see minimal impact. But we should be ready to help users with such impacts and this requires them to either 1) de-angular or 2) report to us.

Other Libraries/Utilities

Have checked and verified that no other libraries or utilities are dependent on Angular in any way.

@ashwin-pc
Copy link
Member Author

Fixed in #4982

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
de-angular de-angularize work v2.11.0
Projects
Development

No branches or pull requests

3 participants