Navigating Third-Party Library Compatibility in SuiteScript 2.1: A Blog Series

April 29, 2024 | 9 minute read
Mohammed Kassem
SuiteCloud Advocate
Text Size 100%:

Welcome to your definitive guide on integrating third-party libraries with NetSuite’s SuiteScript 2.1. This blog series will guide you through the decision-making process and highlight key strategies for integrating third-party libraries seamlessly with your SuiteCloud projects. You'll gain essential skills to enhance the functionality and efficiency of your SuiteScript applications. Each installment offers a detailed, step-by-step walkthrough to not only execute each task but understand the reasoning behind these effective strategies.

integration compass

We begin our journey by following the clear pathway shown in our guide's diagram—your most straightforward route to successful integration. Use this diagram as a compass for a seamless integration. In this first article, we'll discuss the advantages of third-party libraries, introduce the JavaScript SDK ecosystem, and cover how to select the appropriate libraries for your needs.

Upcoming Topics

Looking ahead, "Integrating Third-Party Libraries in SuiteScript 2.1: A Detailed Guide" will provide you with actionable strategies for incorporating AMD, UMD, and non-AMD libraries. In the final article "Enhancing SuiteScript with Third-Party Libraries: A TypeScript, Zod, and Webpack Walkthrough," you’ll go through hands-on examples using powerful, modern libraries.

Comprehensive Resources

As we navigate this path, I will empower you with resources like the "Research Checklist - SuiteScript Compatibility with Third-Party Libraries,” which is a mental model for researching libraries for compatibility. And for the unpopular set of developers exploring beyond the happy path, I will help you address and overcome the incompatible library scenario.

Now, let's get started!

Navigating Third-Party Library Compatibility in SuiteScript 2.1

step 1: navigate integration

Developers often use third-party libraries in their SuiteCloud projects to:

  • Save time: Libraries prevent reinventing the wheel, eliminating the need to build from scratch and streamlining the process of packaging, merging, or adopting code with other products and services. This approach frees developers to concentrate on core business functionalities that drive value.
  • Enhance quality: Adopting community-tested features contributes to reliability and keeps application logic aligned with the latest practices and standards.
  • Improve UI/UX: Access to responsive UI components and the ability to customize these UI components significantly improves the user experience.

The promise of faster development, enhanced quality, and improved user experience often leads SuiteCloud developers to embrace third-party libraries. However, navigating the landscape of SuiteScript 2.1-compatible libraries can be challenging. This article guides you through the complexities of compatibility, empowering you with practical strategies for library research, selection, and integration.

Understanding the JavaScript SDK Ecosystem

JavaScript is a single-threaded language that processes one operation at a time in each execution context. However, it's also designed to perform asynchronous operations, especially within environments that support event-driven programming. This is achieved through its non-blocking, event-driven architecture that allows JavaScript to handle multiple I/O operations in the background with the help of callbacks, promises, and async/await functions—advanced features that enable developers to write cleaner, more readable asynchronous code.

The JavaScript ecosystem is unique in that it offers a variety of Software Development Kits (SDKs) to cater to different execution environments. Each SDK bundles the core JavaScript language with a specific runtime environment, a set of APIs, and a collection of development tools. This contrasts with other programming languages that might offer a single, standard SDK.

The JavaScript SDKs are designed to support a wide range of applications, including web browsers where they interact with the Document Object Model (DOM), server-side environments like Node.js that provide modules for filesystem access and network communication, and even specialized platforms like NetSuite, which use SuiteScript 2.1 for extending and customizing native NetSuite functionality.

JavaScript frameworks, like Angular, React, and Vue.js, are built upon existing SDKs by offering their structured toolsets, libraries, and design patterns. This layered approach helps developers create complex web applications more efficiently by leveraging the foundation provided by the underlying SDK. Given this diversity, developers are tasked with selecting the appropriate standard libraries from the SDK that align with the needs of their target platform.

Here are some popular JavaScript SDK examples:

 Environment

Language + Runtime

Standard Library (APIs)

Tools

Browser (Google Chrome)

JavaScript + V8

WHATWGPIs 

Chrome DevTools

Node.js

JavaScript + V8

Node Standard Library (APIs) 

npm, Chrome DevTools

SuiteScript 2.1

JavaScript + GraalJS

SuiteScript APIs

Node CLI, Chrome DevTools

SuiteScript 2.1 is built upon the GraalVM and GraalJS runtime. Moving to Graal delivers improved performance and aligns SuiteScript with the modern ECMAScript 2021 standards, including support for features like server-side Promises and async/await syntax. While GraalJS powers these advancements, it doesn't directly change the core functionality of SuiteScript 2.1 or SuiteCloud Development Framework (SDF). Instead, the modernization opens the door for developers to seamlessly integrate compatible third-party libraries, offering new ways to augment their SuiteCloud projects and leverage the latest JavaScript capabilities available.

The Compatibility Challenge

In SuiteCloud projects, the integration of third-party libraries can present compatibility challenges. This becomes the case when developers attempt to integrate libraries tailored for other environments such as Node.js or browsers, as they may not directly align with SuiteScript's unique API structure. Every environment has differences in security models and global scopes, so integrating these libraries into another environment may result in errors when a library tries to access context where APIs don’t exist.

Examples:

  • Node.js-specific library (fs) in a browser environment
  • Browser-specific API (localStorage) in a Node.js (server-side) environment
  • Node.js library (path, console.log) in server-side SuiteScript

These examples highlight the importance of understanding the target environment and the potential need for adaptation of the library.

Broad Spectrum of Compatibility

There is no one-size-fits-all approach to integrating third-party libraries into your SuiteCloud projects. Some libraries integrate seamlessly into the SuiteScript environment while others may require modifications to function correctly.

Here’s a chart of the compatibility spectrum with examples and details on compatibility, applicability, and availability:

Description

Example

Compatibility

Applicability

Libraries Available

Libraries specifically designed for SuiteScript, ensuring seamless integration and high performance.

Fasttrack toolkit, SuiteScript Unit Testing Library

High

High

Fewer

Libraries compatible with SuiteScript offering a wide range of features, suitable for various applications.

Zod, Lodash

High – Pure JS

High

Many

Libraries with high compatibility but intended for specific use cases, limiting their overall applicability.

Custom HTML Suitelet with React, Material UI, Bootstrap, JQuery

High – Browser runtime

Limited

Moderate

Libraries with no compatibility but dependencies could be shimmed.

Node.js Polyfill (path)

 

Could work with Shimming/Tweaks

None

Unknown

Unknown

Tools or libraries that lack compatibility with SuiteScript, making them unsuitable for integration.

Express

None

None

None

SuiteScript 2.1 Runtime Spectrum of Compatibility

Understanding the compatibility spectrum is essential to determine which libraries can be easily integrated into SuiteScript and which may require more substantial modification or alternative approaches. This insight ensures that you choose libraries that align with the SuiteScript environment, avoiding unnecessary complexity and technical overhead. In general, integrating libraries designed for SuiteScript is highly compatible and applicable but fewer of them are available.

Click here for a list of SuietScript 2.1-compatible build time and runtime libraries

SuiteCloud Unit Testing Library: Dependency X-ray

Imagine putting a library under an X-ray machine. Because most libraries are built on top of another library, the below illustration shows how libraries built with SuiteScript in mind integrate smoothly with the development stack. The SuiteCloud Unit Testing framework library is a highly compatible, highly applicable library that’s built “on top of” (or “wraps”) Jest which is written “on top of” Node.js. This specialized layer provides tools to automatically run tests and generate code coverage reports, offering insights into the thoroughness of the tests conducted.

Conclusion

While careful consideration is required to ensure a successful integration, third-party libraries can be powerful tools for SuiteScript developers. These pre-built components offer several advantages like reduced development time and access to functionalities that would be time-consuming or complex to develop from scratch. By carefully evaluating compatibility, potential performance impact, and ongoing maintenance requirements, you can leverage the power of third-party libraries to enhance your SuiteScript projects while effectively mitigating performance hurdles.

Remember, integrating libraries made for SuiteScript is highly compatible and applicable and therefore, integrating these libraries should be your first pick. Click here see a list of known SuiteScript 2.1-compatible build time and runtime libraries. But if you have a specific library you'd like to integrate and it's not in the list of known SuiteScript 2.1-compatible libraries, then read my article on how to identify and research third-party libraries for compatibility.

And for those that decide to go down the unpaved road and integrate a library with little to no compatibility, I’ll show you techniques to ensure that chosen third-party libraries operate within the SuiteScript environment. Just remember, you do add technical overhead because you need to maintain the code moving forward.

In my next blog article along the "happy path," I'll dive into using third-party libraries in SuiteCloud projects by providing step-by-step guidance to seamlessly integrate AMD, non-AMD, and UMD Libraries into your SuiteCloud project.

Mohammed Kassem

SuiteCloud Advocate