Git Product home page Git Product logo

Comments (2)

ananzh avatar ananzh commented on June 3, 2024

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.

from opensearch-dashboards.

ashwin-pc avatar ashwin-pc commented on June 3, 2024

Fixed in #4982

from opensearch-dashboards.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.