I am seeing syntax error in the SEO debug messages...
# suitecommerce
k
I am seeing syntax error in the SEO debug messages for a 2020.1 SCA website. The error message is:
[12:01:27.219] [    +0 ms ] Logs generated by console.log():
[    +0 ms ] SyntaxError: Unexpected token 'const'
at anonymous (<https://www.toolfetch.com/sca-dev-2020-1/extensions/shopping_2.js?t=1596211304348:466>)
I used the “const” variable declaration in the extensions code. Does the SEO Page Generator support the “const” variable declaration?
I searched shopping_2.js file and it looks like the SEO page generator does not support this keyword. The error is occurring on the first use of the const keyword. Ugh.
p
No. That’s too modern for seo generator.
k
OMG. you are joking. The keyword is all through the SCA code, but that code TypeScript, so the TypeScript compiler must be converting it to var. Darn it.
@PabloZ, thanks for confirming.
p
core typescript gets transpiled to ancient js
extension code just gets concatenated.
k
I have not heard the term transpiled.
Yep. Darn darn it. I even checked in Mozilla MDN web docs to see if all of the browsers supported the const statement. They do.
Time time to rewrite some extensions. 🙂
Thanks again for confirming
p
all browsers support string.contains and array.contains and SEO generator does not.
k
Do you know if NetSuite has documented what javascript version the SEO page generator supports?
p
I think it’s ecmascript 5
💯 2
k
Thanks
p
If you want to keep writing modern js you can try adding a transpiler to your development process, and let the transpiler target ecmascript 5 for you. https://babeljs.io/ Or code in typescript that also can transpile to that target standard. Any transpilation needs to happen in your machine before any file gets uploaded by gulp extension:deploy.
k
Cool. Thanks.
p
extensions developed by NetSuite are written in typescript, and do this. You can “get inspiration” from them.
k
I am guessing that they have added the babeljs.io or something similar to their development tools. Because I tried to use TypeScript early on in the 2020.1 extension development and it wasn’t supported. Then I recall seeing something on Slack about this.
p
they use typescript which can be addded as a npm dependency to your project and you can configure a watcher that will automatically generate a js file for each ts file on the fly on any change
s
Adding TypeScript to extensions is one of those things that is one the roadmap but I obviously cannot say if/when
For now, please continue to code like it's 1999 2009
😂 1
k
I will. I learned my lesson. 🙂 I am not in a hurry to use TypeScript. I much prefer the require.js Define declaration to what I am seeing in the TypeScript implementation in the core code. I don’t like to see hardcoded references between modules.
It seems to brittle to me