Xanadu ES12 in Global

NS
Kilo Sage

Hello,

 

The Xanadu highlights in docs state:

  • Use ECMAScript 2021 (ES12) features in any server-side script.

I understand this to also mean Global scope, in scoped apps this has been available since Tokyo. I spun up a PDI which is running on build `glide-xanadu-07-02-2024__patch0-07-16-2024`

Apart from `const` and `let` no new ES features seem to be working. I was trying template literals, for...of loop, arrow function and spread operator. I tried running both in a Fix Script so I could make sure the ES12 toggle was on, and in background script. But the result isn't good.

Script compilation error: Script Identifier: null.null.script, Error Description: syntax error (null.null.script; line 4), Script ES Level: 0, Interpreted Mode: true

bg script NS_1-1722858083099.png

fix script NS_0-1722858542180.png

 

In a scoped app the same script runs like a charm

NS_2-1722858129645.png

 

 

The docs also state "No plugins or properties are required to install the new JavaScript engine."  So what gives? Any ideas?

 

edit: maybe this post went into a wrong category - idk how to change it though

3 ACCEPTED SOLUTIONS

NS
Kilo Sage

Still not working in Patch 3 (glide-xanadu-07-02-2024__patch3-10-23-2024)

Got reply from SN:


Thank you for your patience on this. At this stage, we could see that the Defect has been waived for Yokohama and Targeted to Zurich. 

Will keep you posted as soon as the fix is available. 

 

View solution in original post

NS
Kilo Sage

ServiceNow finally acknowledged that the feature indeed does not work:

KB1699139 + Related Problem: PRB1794568

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1699139

 

No info on when it'll be fixed though.

View solution in original post

Hi @NS 

I can say that for my initial test in a fix script in Zurich patch 0 it works in the global scope

View solution in original post

27 REPLIES 27

NS
Kilo Sage

I received info from ServiceNow that this should be working in Zurich. Time will tell. At this point I'm not holding my breath 🙂

 

"Thank you for waiting. The Problem PRB1794568 is in Fixed status and available in Zurich release. Once it is available, we request you to upgrade the instance and test accordingly."

Hi @NS 

I can say that for my initial test in a fix script in Zurich patch 0 it works in the global scope

I also spun up a Zurich instance and tested - looks pretty good based on an chatbot script snippet. Too bad background script still doesn't support these (I still bitterly remember "Use ECMAScript 2021 (ES12) features in any server-side script.")

 

 


*** Script: ECMAScript Feature Support Test
*** Script: ================================
*** Script: let/const (ES6):
*** Script: Arrow functions (ES6):
*** Script: Default parameters (ES6):
*** Script: Template literals (ES6):
*** Script: Destructuring (ES6):
*** Script: Spread operator (ES6):
*** Script: Promises (ES6):
*** Script: Async/Await (ES2017):
*** Script: BigInt (ES2020):
*** Script: Optional chaining (ES2020):
*** Script: Nullish coalescing (ES2020):
*** Script: Logical assignment (ES2021):
[0:00:00.199] Total Time

  

(function() {
    const results = [];

    try {
        // ES6
        let x = 1;
        const y = 2;
        results.push(['let/const (ES6)', x + y === 3]);

        const arrow = () => 42;
        results.push(['Arrow functions (ES6)', arrow() === 42]);

        function defParam(a = 5) { return a; }
        results.push(['Default parameters (ES6)', defParam() === 5]);

        const name = 'ES6';
        results.push(['Template literals (ES6)', `Hello ${name}` === 'Hello ES6']);

        const {a, b} = {a: 1, b: 2};
        results.push(['Destructuring (ES6)', a === 1 && b === 2]);

        results.push(['Spread operator (ES6)', Math.max(...[1, 2, 3]) === 3]);

        results.push(['Promises (ES6)', typeof Promise !== 'undefined' && typeof Promise.resolve === 'function']);

        // ES2017
        async function asyncTest() {}
        results.push(['Async/Await (ES2017)', typeof asyncTest === 'function']);

        // ES2020
        results.push(['BigInt (ES2020)', typeof BigInt(123) === 'bigint']);
        const optCh = ({foo: {bar: 42}}).foo?.bar;
        results.push(['Optional chaining (ES2020)', optCh === 42]);

        const nullish = null ?? 42;
        results.push(['Nullish coalescing (ES2020)', nullish === 42]);

        // ES2021
        let logicalTest;
        logicalTest ||= 5;
        results.push(['Logical assignment (ES2021)', logicalTest === 5]);

    } catch (e) {
        console.error("A syntax error occurred. This likely means a feature isn't supported.");
        console.error(e);
        return;
    }

    console.log("ECMAScript Feature Support Test");
    console.log("================================");
    results.forEach(([feature, passed]) => {
        console.log(`${feature}: ${passed ? '✅' : '❌'}`);
    });
})();