These changes are primarily aiming for having an acceptable developer
experience when working on changes locally and want to run the test
suite.
By using `esm` as a required package to be executed *before* the
individual test files are executed, `esm` allows CommonJS/`require()`
based code to use code written with ES Modules syntax.
In practise that means our existing CommonJS based test suite that is
`require()`ing the source code witten in ES Modules, is seamless and
totally transparent. It just works without any build or transpiling
pipeline like `babel` involved.
Caveat: the `esm` package only support Node.js 6.x and above.
That is more than okey, as we've got continous integration to verify
how our changes works on different versions of Node.js, browsers & deno.
Refs https://www.npmjs.com/package/esm
By making the main source code an ES module placed in `mustache.mjs`,
what used to be in `mustache.js` is now built based off of the ES module
source inside `mustache.mjs`.
This is done primarily to avoid breaking existing projects already using
mustache.js, by keeping the UMD-version in `mustache.js` part of the git
repository in addition to the minified version in `mustache.min.js`.
After experiment with several compilers;
- Babel
- TypeScript
- Rollup
and examining their build output, [Rollup](https://rollupjs.org/) was chosen
because of the UMD output it creates which closely resembles what we've
historically had in the previous `mustache.js` source code.
The contents of `.js | .min.js` files has been generated by running
the following npm script:
```
$ npm run build
```
Also change linting w/eslint to target the `.mjs` file, since the output
of rollup that ends up in the old `mustache.js` file is not sensible to
do linting on.
This is a precursor to introducing a build step that will change what
we expose from this package. Better off writing some tests to verify
existing projects with different module systems continue to work as
expected.
Primarily because it's been ages since we bumped eslint and as a precursor
to allowing some future test files to be written in a more modern type
of JavaScript. Especially think about tests written using puppeteer.js
which is heavily `Promise` based, where the async-await syntax makes
it soooo less painful to write.
Silly not being able to use that because of an outdated eslint version
doesn't understand that syntax construct at all.