what features does the babel polyfill support? - babeljs

Is there any type of list of what features the babel-polyfill supports? We just started using babel and i'm wondering if some of the dependencies we currently rely on can be eliminated like es6-promises & whatwg-fetch. If babel-polyfill supported promises of course there would be no need to include es6-promises.

I think after some research i figured it out. Babel-Polyfill is pretty much core.js + Regenerator Runtime . Look at those projects individually to see what features will be polyfilled. For example, at the time of this writing core.js:
Fetch:
window.fetch is not a cross-platform feature, in some environments it
makes no sense. For this reason, I don't think it should be in
core-js. Looking at a large number of requests it may be added in the
future. Now you can use, for example, this polyfill.
Promises:
Modular standard library for JavaScript. Includes polyfills for
ECMAScript 5, ECMAScript 6: promises, symbols, collections, iterators,
typed arrays, ECMAScript 7+ proposals, setImmediate, etc.
So i need whatwg-fetch but i don't need es6-promises. Tested in IE11 (which doesn't have promises) so it appears to be working.

Related

Can Rollup & Plugins convert the majority of legacy libraries to es6 modules?

Our team's project is entirely es6 modules (ESM) internally, but has dependencies that have not yet made esm versions.
We've created various solutions, but they are definitely not modern, mainstream solutions. By this I mean Rollup workflows which convert legacy formats to esm. Or equivalent.
So here's the question: are there now Rollup converters/plugins which can let us bundle all, or at least most, legacy formats into esm? I.e. convert commonJS, iife, umd, amd, (and other) library formats into esm, or can at least be bundled into an esm bundle?
There are plugins that are designed to do this:
https://github.com/rollup/rollup-plugin-commonjs
https://github.com/rollup/rollup-plugin-legacy
https://github.com/piuccio/rollup-plugin-amd
The CommonJS plugin should cover UMD as well. They're not caveat-free — AMD is very hard to convert to ESM in some cases, and you can do some fairly nasty stuff with CommonJS that is hard to recreate (bundlers like webpack get around it by effectively simulating a Node environment), but they handle the common cases.
For the rest, if the maintainers won't accept PRs that add an ESM build alongside the default one (some won't, frustratingly), you might have to fork — depends on what you depend on :)

Purescript plugin system

Does purescript have something like Haskell's System.Plugins?
I need to create some 'generic interface' (sorry for this, I've been programming in object oriented languages for almost 15 years) that other developers will be able to use just by putting a module file in a plugins directory.
I wonder if it is possible since as far as I know Purescript does not have any metadata carried with types at runtime.
From a cursory glance, Haskell's plugins package is about dynamic loading of Haskell code. The similar concept in JavaScript is eval or adding a script element to the DOM.
You can make any type assumption for eval'd code using a foreign import or unsafeCoerce. However, you must take care to ensure that the assumption is correct.
I am not aware of a purescript package oriented around these sorts of plugins. In my estimation there would be too much variability in what a plugin could be to really have a sole package for it.

What are the advantages of ES5 over ES3?

Maybe it's a basic question, but what differences are there between:
- a web project developped with ES3 support and
- a web project developped with ES5 support?
In other words, what enhancements can you add to your projects if you support ES5 ?
It's probably hard to list here all things that are new in ES5, but the ones that may be helpful in your case are mostly related to language improvements. Some of the key points:
Methods for searching and manipulating array contents: indexOf, map, filter, reduce, forEach, etc.
Standard of representation for dates as strings (ISO 8601).
Functions for converting objects to and from JSON
'use strict' - strict mode changes some JavaScript silent errors to throw errors, fixes some Javascript mistakes to enable better optimisation and so on.
Switching to ES5 can probably speed up your development process a bit and can help make your code robust and optimised.

Scala Compiler Plugins with a Macro API

Typically, Scala compiler plugins operate directly on compiler internal data structures and utilities. Unfortunately, compiler APIs change rapidly, with every minor release. As a result, the effort required to maintain a compiler plugin is much larger than to maintain a Scala macro.
Is it possible to write a compiler plugin that uses the stable API of Scala macros? How can one do that?
It's unlikely that it's possible to be shielded from the changes in the infrastructure (order of phases, contracts of classes like PluginComponent, etc - that's pretty stable), but it's totally possible to refrain from using scala.tools.nsc.Global, which is what actually doesn't have any compatibility guarantees, and use the scala.reflect.macros.Universe subset of it.

AOT compilation or native code compilation of Scala?

My scala application needs to perform simple operations over large arrays of integers & doubles, and performance is a bottleneck. I've struggled to put my finger on exactly when certain optimizations kick in (e.g. escape analysis) although I can observe their results through various benchmarking. I'd love to do some AOT compilation of my scala application, so I can see or enforce (or implement) certain optimizations ... or compile to native code, if possible, so I can cut corners like bounds checking and observe if it makes a difference.
My question: what alternative compilation methods work for scala? I'm interested in tools like llvm, vmkit, soot, gcj, etc. Who is using those successfully with scala at this point, or are none of these methods currently compatible or maintained?
GCJ can compile JVM classes to native code. This blog describes tests done with Scala code: http://lampblogs.epfl.ch/b2evolution/blogs/index.php/2006/10/02/scala_goes_native_almost?blog=7
To answer my own question, there is no alternative backend for Scala except for the JVM. The .NET backend has been in development for a long time, but its status is unclear. The LLVM backend is also not yet ready for use, and it's not clear what its future is.