Documentation
Primary version
Primary version
  • Cubbles documentation
  • First steps
    • Generate a project
    • Create a webpackage
    • Create an elementary component
    • Create a compound component
      • Compound slot initialization
  • Runtime extension - RTE
    • User guide
      • RTE Integration
      • The Cubbles TAG API
        • The Cubbles Dependency API
      • The Cubbles Javascript API
        • Interacting with Cubbles from the outside
        • Adding dynamic connections
        • Interacting with Elementary Cubbles from the inside
      • The RTE Processing
        • RTE initialization and rendering timeline
      • The Cubbles IFrame API
        • The Cubbles IFrame Resizer API
      • The Cubbles mutation based start event API
      • FAQs
        • How to manually resolve dependency conflicts?
        • How to create a component instance dynamically?
        • How to render HTML Markup coming from input slot?
        • How to replace a dependency when declaring a component instance?
        • How to synchronize multiple dataflows between component instances?
        • How to handle the copyValue flag for non serializable instances?
    • Contributor guide
      • CIF processing
  • Developing with the vanilla boilerplate
    • Creating a new project
    • Developing elementaries using the vanilla boilerplate
    • Developing compounds using the vanilla boilerplate
    • Using the vanilla boilerplate scripts
  • Coder devtools - CDT
    • User guide
      • Create Cubbles artifacts
      • Upload a Webpackage
      • Generate a README file
      • Rename an artifact
      • Configure network proxy
      • Validate the manifest.webpackage file
      • Change active webpackage
      • Bulk upload of webpackages
      • Release a webpackage
      • Update the RTE version of a webpackage
      • Prepare a webpackage to be released
      • Update webpackage to the next development version
      • Generate a test environment for a component
      • Testing Cubbles components
      • Validate sources
      • Create a demo webpackage
    • Contributor guide
      • Checklist for releasing a new webpackage.modelVersion
  • Terms and concepts
    • Webpackage
    • Artifacts
    • User roles
    • Base
Powered by GitBook
On this page
  • Using the TAG API (Only for a component)
  • Using the Dependency API (For all components)
  1. Runtime extension - RTE
  2. User guide
  3. FAQs

How to replace a dependency when declaring a component instance?

Let's suppose that you want to replace the third-party-lib@1.0/awesome-lib-util utility with a different version (e.g. 2.0). To replace a dependency, you should exclude the old dependency and include the new desired one.

Using the TAG API (Only for a component)

You can replace the desired dependency by excluding it as above and including the desired dependency using the cubx-dependencies and the cubx-dependency tags as follows:

...
    <demo-component cubx-webpackage-id="demo-package@1.0">
        <cubx-dependencies>
            <cubx-dependency
                webpackage-id="third-party-lib@2.0"
                artifact-id="awesome-lib-util">
            </cubx-dependency>  
        </cubx-dependencies>
        <cubx-dependency-excludes>
            <cubx-dependency-exclude
                webpackage-id="third-party-lib@1.0"
                artifact-id="awesome-lib-util">
            </cubx-dependency-exclude>
        </cubx-dependency-excludes>
    </demo-component>
...

Using the Dependency API (For all components)

Similarly, you could replace the desired dependency by adding a new one and excluding an existing one using the window.cubx.CRCInit object, as shown below:

<head>
...
    <!--
        The below script block needs to be placed before(!)
        the crc-loader script is included
    -->
    <script>
        window.cubx = {
            CRCInit: {
              rootDependencies: [
                {
                    webpackageId: 'third-party-lib@2.0',
                    artifactId: 'awesome-lib-util'
                }
              ],
              rootDependencyExcludes: [
                {
                    webpackageId: 'third-party-lib@1.0',
                    artifactId: 'awesome-lib-util'
                }
              ]  
            }
        };
    </script>
...
</head>
...
PreviousHow to render HTML Markup coming from input slot?NextHow to synchronize multiple dataflows between component instances?

Last updated 6 years ago

For more details check .

The Cubbles Dependency API