From 957dbc67ea8d1681389441d3441c229555d2f70b Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 26 Feb 2021 09:02:56 -0500 Subject: [PATCH 1/2] Ensure Ember 3.27+ can determine global for template compilation. Node 12+ has access to `globalThis` (including within a VM context), but older versions do not. Due to the detection done in https://git.io/Jtb7s, when we can't find `globalThis` (and don't define `global` global) evaluating `ember-template-compiler.js` throws an error "unable to locate global object". This ensures that either `globalThis` or `global` are defined. --- lib/utils.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 3194d7d4..fbc87268 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -143,11 +143,21 @@ function getTemplateCompiler(templateCompilerPath, EmberENV = {}) { // the shared global config let clonedEmberENV = JSON.parse(JSON.stringify(EmberENV)); - let context = vm.createContext({ + let sandbox = { EmberENV: clonedEmberENV, module: { require, exports: {} }, require, - }); + }; + + // if we are running on a Node version _without_ a globalThis + // we must provide a `global` + // + // this is due to https://git.io/Jtb7s (Ember 3.27+) + if (typeof globalThis === 'undefined') { + sandbox.global = sandbox; + } + + let context = vm.createContext(sandbox); script.runInContext(context); From 5ae2db80d203d1c7a66f44abc9c735b2f9f3e91a Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 26 Feb 2021 09:05:07 -0500 Subject: [PATCH 2/2] Run ember-try scenarios in Node 10. This would have caught the error reported in https://github.com/emberjs/ember.js/issues/19431, we should run with the lowest supported Node version. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7048e5ae..b7c677c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: 10.x - name: install dependencies run: yarn install - name: test