Genesys Cloud - Developer Community!

 View Only

Sign Up

Using purecloud-platform-client-v2 with new Angular build system

  • 1.  Using purecloud-platform-client-v2 with new Angular build system

    Posted 02-24-2026 07:43

    Hi team,

    we are using 'purecloud-platform-client-v2' in our Angular project and the only way how to use it is described in the following blueprint:

    Develop an Angular app that uses the Genesys Cloud Platform SDK
    https://developer.genesys.cloud/blueprints/angular-app-with-genesys-cloud-sdk/

    This approach is using the 'custom-webpack' configuration using following setup in 'extra-webpack.config.js':
    module.exports = {
      externals: {
        'purecloud-platform-client-v2': "require('platformClient')",
      },
    }

    As the Angular switched in last versions to use esbuild instead of webpack by default, we would like to use the esbuild too.
    However, the solution above is glued to webpack and we did not found any support in esbuild configuration to achieve the same approach.

    Question: is there a plan for the 'purecloud-platform-client-v2' to be supported by new Angular build system?

    We found following post, but unfortunately without any reaction !
    https://community.genesys.com/discussion/support-esm-for-purecloud-platform-client-v2

    Our solution

    We were trying to figure out how it could be possible to use 'purecloud-platform-client-v2' with new Angular build system and we found following solution:
    note: we are not experienced webpack or esbuild users, so maybe there is better way.

    #1 Setup new Angular build system
    "builder": "@angular/build:application"
    or
    "builder": "@angular-devkit/build-angular:browser-esbuild" 

    #2 Create new Java Script file in your project, e.g. 'require-platform-client.js' with the content:
    const platformClient = require('platformClient');

    #3 Add the script 'require-platform-client.js' to angular.json scripts configuration after purecloud scripts:
    "scripts": [
      "node_modules/purecloud-platform-client-v2/dist/web-cjs/purecloud-platform-client-v2.min.js",
      "node_modules/purecloud-client-app-sdk/dist/purecloud-client-app-sdk.js",
      "src/require-platform-client.js"
    ]

    #4 In the typescript class, where the lib is used put following import and use it:

    // example of import of type from 'purecloud-platform-client-v2'
    import {Models} from 'purecloud-platform-client-v2';

    // platformClient is defined in the 'require-platform-client.js' script, so it is available in browser, we just need to declare it
    // to allow make IDE happy, we can type the 'platformClient' explicitely, so intellisence will work 
    declare var platformClient: typeof import('purecloud-platform-client-v2');

    export class Test {

      private client = platformClient.ApiClient.instance;
      private usersApi = new platformClient.UsersApi();

     constructor() {

       this.client.setEnvironment('<environment>');
       this.client.loginPKCEGrant('<client_id>', '<redirect_url>').then((response: any) => {

         this.usersApi.getUsersMe().then((user: Models.UserMe) => {
           console.log(`getUsersMe: ${JSON.stringify(user)}`);
         })
        )
      }
    }

    #5 Build and run

    Using this approach we are able to build the application using esbuild and all works fine also after deployment.

    Question: Is this solution ok? Do you see there some possible problems or improvements? Is there some recommended approach by Genesys?


    #PlatformSDK

    ------------------------------
    Miroslav Stupavský
    ------------------------------