4 ms·
I've been hit by this at least a half dozen times over my career. Apps scripts are probably the latest one causing me pain. I love being able to integrate with
by jkoudys 7y ago
I've been hit by this at least a half dozen times over my career. Apps scripts are probably the latest one causing me pain. I love being able to integrate with docs & sheets, but man if that ecma version isn't ancient af.
- deathanatos 7y ago> man if that ecma version isn't ancient af. It is incredibly ancient. It's possible to use Babel w/ it though, and write reasonably modern JS. There's a CLI tool out there to upload something into an Apps Script … app? too; at one point, I had a project w/ a Makefile that would run the project through Babel and then upload it to Google. I didn't try all the features (and I didn't have any npm/package management), but things like format strings, for(… of …) loops, let/const, new Map() all worked. Babel is a wonderful, wonderful thing.
- jkoudys 7y agoIf it were simply ancient, that'd be one thing, but it's a weird hybrid of es3 with _some_ es5 features, and some es6 ones that often don't work the same. e.g. it has `const`, but no `let`, and it's not even block scoped so it's not that useful. Destructuring is there, but for arrays only and not object properties. I built my babel config to balance clean, new syntax with the least intrusive transforms possible. e.g. I have loose template literals on, since `\`hello ${world}!\`` is an easy transform (and still readable in the final source) as `'hello ' + world + '!'`. Generators, for .. of, and object rest/spread, are okay, but babel puts a ridiculous amount of helper functions at the top to support this. I suppose I could always configure each project with a shim file, but that's extra overhead I really could do without. block-scoping, arrow-functions, function-name, shorthand-properties, spread (for arrays and arguments), template-literals (loose, so `+` not `String#concat`), and exponentiation-operator I found give the most bang for your buck. `for .. of` is nice but if I can pass arrow functions into my `forEach` callbacks that's pretty clean too. Pretty great being able to say ``` rows.forEach(row => { const payload = row.map(([name, rank, serialNo]) => ({ name, rank, serialNo })); SomeApi.doThing({ onComplete() { foo(); }, payload, }); }); ``` in gapps. That said, it took a while to even figure out how much was possible, but yeah it's a big step up.