Use a version of ngrok which runs on recent versions of Windows and MacOS.
Switch to using the npm `overrides` property, to avoid needing to mantain a separate fork of `zuul-ngrok`
Had obviously been forgotten, but those test files should have been part
of the ordinary lint phase.
The fact that we had forgotten to lint these files, allowed a missing
semi-colon to sneak into `./test/cli-test.js` file.
Refs https://github.com/janl/mustache.js/pull/777
These changes adds an `exports` field to package.json with the main
goal of allowing the root/main export to be our ESM syntax version of
the package, as opposed to the UMD/CommonJS version.
This will make it easier for using projects written with ESM to use
mustache.js out of the box, without having to figure out that they'd
have to `import mustache/mustache.mjs` to get the ESM version.
It is also assumed to be beneficial for tools like http://skypack.dev
to choose the correct ESM version when appropriate.
Refs https://nodejs.org/api/packages.html#packages_package_entry_points
Because the source code is written in ESM syntax and we cannot use the
`esm` package to make `require()` ESM compatible, since that package
does not support legacy versions of Node.js.
Also in our usage tests in CI, we need to mimck the npm packaging
behaviour where building is involved.
Because `esm` does not support legacy versions of Node.js, at least not
below Node.js 6 as of writing this, we have to avoid using that whenever
tests are running on legacy versions.
But now that the source code (`mustache.js`) is written in ESM syntax,
how on earth are we going to run tests on these legacy versions of
Node.js? We gotta run the build step first, so that we end up with a
`mustache.js` file in CJS, or strictly speaking it will be UMD.
That's kinda pain in the backside isn't it? Yes, but running tests on
legacy versions are not meant to be done locally, but rather in CI. That
means we can easily automate the flow of (1) building the source code
before (2) starting the test suite.
For our futureselves, if we want to stop running tests on legacy
versions of Node.js; the changes introduces in this commit, could be
removed completely.
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
Primarily because installing `git` hooks are easy to forget for
maintainers, whilst telling `npm` to do something as a consequence of
`$ npm version <patch | minor | major>` is seamless.
Also worth mentioning we what we used to do in the pre-commit hook
script is now greatly simplified as we don't want to have the build
output and/or the `.min.js` in git anymore.
Therefore, as long as we've bumped the version number in the source
code, we're basically done, after having amended that change into the
git commit the `npm` CLI creates.
Although we'll now end up with only `mustache.js` in the git repo,
being written in ESM syntax, the npm package will still be as before:
- `mustache.js`: UMD, meaning CommonJS, AMD or global scope
- `mustache.mjs`: ESM
Windows shell does not recognize 'single quotes' the same way as bash. The 'single quotes' in the build command have been changed to "double quotes" instead.
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.
In an effort of ensuring consistent code style in test files as with
the "production" source code, we should run eslint as part of the
`$ npm test` script as well.
Most of the related fixes was done by `eslint` using the `--fix` argument.
Only special configuration tweaks for tests compared to the other
source code, is to allow functions declaration without names. The
rationale for allowing that in tests, is that the important reason we
have them in the source code (proper stacktraces) aren't as important
in test files.
As of writing this, we cannot use the latest version of eslint v2.x
because there's something in there that causes explotions when run
with pre Node.js 1 installed.
These changes makes zuul use ngrok for exposing itself to the outside world, rather than the default localtunnel implementation. That's because we've had quite a lot of issues with flakyness which seems to be related to localtunnel, e.g.:
```
- starting: <internet explorer 9 on Windows 2008>
events.js:160
throw er; // Unhandled 'error' event
^
Error: connection refused: localtunnel.me:44896 (check your firewall settings)
at Socket.<anonymous> (/home/travis/build/janl/mustache.js/node_modules/localtunnel/client.js:84:32)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1290:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
```
I thought this was fixed by [using Node.js 6 instead of Node.js 4](https://github.com/janl/mustache.js/pull/667), but sadly that was not the case as it re-appeared with Node.js 6 as well.
Had to use a [custom version of zuul-ngrok](https://github.com/rase-/zuul-ngrok/pull/12) which contains a newer version of ngrok. The dependency used by the upstream module threw an error when running on my computer, the updated version worked as a charm though. We should change to using the upstream module as soon as the PR with that ngrok version bump lands.
Set `concurrency: 1` otherwise ngrok would fail and make IE11 tests stall forever because of too many connections being made within a short time period. I've notice it can take quite some time (20+ minutes) to get all the tests through as it seems ngrok still seems to throttle the connections somehow, but the important thing is getting these tests to work.
Previously mocha, uglifyjs and jshint used when publishing a new version were ensured / installed by `Rakefile` via the pre-commit git hook. Those modules were automatically installed globally if not present in `$PATH`.
Installing modules globally has one particular downside that we should avoid: we can't ensure developers publishing new mustache.js versions have the same version of these 3rd party modules installed.
If instead we make these modules local dev dependencies, we can ensure which versions are installed, and we make 3rd party dependencies explicit by listing them in `package.json`, rather than in `Rakefile`.
First shot at getting greenkeeper to ignoring eslint updates landed with commit 85fa743258.
Sadly that commit had a minor `greenkeper` misspelling in package.json, which obviously didn't have much effect for greenkeeper.
This commit fixes that blooper in hopes that greenkeeper will stop opening PRs about new eslint versions, as we don't want to
update at the moment cause eslint 3.x requires Node.js v4.x.