Skip to content

Commit

Permalink
Merge pull request #663 from ember-cli/ensure-global-can-be-found-for…
Browse files Browse the repository at this point in the history
…-canary

Ember Ember 3.27+ can determine global for template compilation
  • Loading branch information
rwjblue authored Feb 26, 2021
2 parents 20184be + 5ae2db8 commit a7f8a7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a7f8a7b

Please sign in to comment.