Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ember Ember 3.27+ can determine global for template compilation #663

Merged
merged 2 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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