From c72ddc234779c7bdaad28f7ad625df530ed42691 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 27 Jan 2019 13:22:06 -0800 Subject: [PATCH] add zero-config support for loading ES modules in Node --- bin/_mocha | 4 +++- package-lock.json | 5 +++++ package.json | 1 + test/integration/options.spec.js | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bin/_mocha b/bin/_mocha index 2ea8317467..3c1fc780e0 100755 --- a/bin/_mocha +++ b/bin/_mocha @@ -1,10 +1,12 @@ #!/usr/bin/env node 'use strict'; +const esmRequire = require('esm')(module); + /** * This file remains for backwards compatibility only. * Don't put stuff in this file. * @see module:lib/cli */ -require('../lib/cli').main(); +esmRequire('../lib/cli').main(); diff --git a/package-lock.json b/package-lock.json index c0ce5fba37..ce7d543be9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4813,6 +4813,11 @@ "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", "dev": true }, + "esm": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/esm/-/esm-3.1.4.tgz", + "integrity": "sha512-GScwIz0110RTNzBmAQEdqaAYkD9zVhj2Jo+jeizjIcdyTw+C6S0Zv/dlPYgfF41hRTu2f1vQYliubzIkusx2gA==" + }, "espree": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.0.tgz", diff --git a/package.json b/package.json index 1b21b2a746..3bc5d938bc 100644 --- a/package.json +++ b/package.json @@ -489,6 +489,7 @@ "debug": "3.2.6", "diff": "3.5.0", "escape-string-regexp": "1.0.5", + "esm": "3.1.4", "findup-sync": "2.0.0", "glob": "7.1.3", "growl": "1.10.5", diff --git a/test/integration/options.spec.js b/test/integration/options.spec.js index 81eac5786a..8c160c9ad6 100644 --- a/test/integration/options.spec.js +++ b/test/integration/options.spec.js @@ -774,7 +774,7 @@ describe('options', function() { setTimeout(function() { // kill the child process mocha.kill('SIGINT'); - }, 1000); + }, 1500); }); }); });