From e3f73b2b893428400a7109272f0f578b8ff89697 Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Thu, 24 Aug 2023 21:15:09 +0200 Subject: [PATCH 1/3] Drop support for Node v12 and v14, add support for Node v16, v18 and v20 --- .github/workflows/ci.yml | 8 ++++---- README.md | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9ddc20a..933343f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 12.x + node-version: 16 - name: install dependencies run: yarn install --frozen-lockfile - name: lint:js @@ -35,7 +35,7 @@ jobs: fail-fast: false matrix: os: [ubuntu, windows] - node-version: [12.x, 14.x] + node-version: [16, 18, 20] steps: - uses: actions/checkout@v3 @@ -59,7 +59,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 12.x + node-version: 16 - name: install dependencies run: yarn install --ignore-lockfile - name: node tests @@ -96,7 +96,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 12.x + node-version: 16 - name: install dependencies run: yarn install - name: test diff --git a/README.md b/README.md index b5b67f94..aa96e152 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ * Ember.js v3.8 or above * Ember CLI v3.8 or above -* Node.js v12 or above +* Node.js v16 or above ## Tagged Template Usage / Migrating from `htmlbars-inline-precompile` diff --git a/package.json b/package.json index 7ef8da40..d17f37e4 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "webpack": "^5.58.2" }, "engines": { - "node": "12.* || 14.* || >= 16" + "node": "16.* || 18.* || >= 20" }, "publishConfig": { "registry": "https://registry.npmjs.org" From 610b248eedae6abf3b3d1737943fad6fa68029bb Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Thu, 24 Aug 2023 21:46:41 +0200 Subject: [PATCH 2/3] Increase yarn's network timeout on windows --- .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 933343f4..2cfda08a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: with: node-version: ${{ matrix.node-version }} - name: install dependencies - run: yarn install --ignore-engines --frozen-lockfile + run: yarn install --ignore-engines --frozen-lockfile --network-timeout 600000 - name: node tests run: yarn test:node - name: ember test From ac34380aa68cae7176aad8de820628b9b7caf4d3 Mon Sep 17 00:00:00 2001 From: Bert De Block Date: Fri, 25 Aug 2023 06:33:11 +0200 Subject: [PATCH 3/3] Remove `global` fallback --- lib/utils.js | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 4091b2b6..a7a22013 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -115,23 +115,6 @@ function buildOptions(projectConfig, templateCompilerPath, pluginInfo) { return htmlbarsOptions; } -const hasGlobalThis = (function () { - try { - let context = vm.createContext(); - - // we must create a sandboxed context to test if `globalThis` will be - // present _within_ it because in some contexts a globalThis polyfill has - // been evaluated. In that case globalThis would be available on the - // current global context but **would not** be inherited to the global - // contexts created by `vm.createContext` - let type = vm.runInContext(`typeof globalThis`, context); - - return type !== 'undefined'; - } catch (e) { - return false; - } -})(); - function getTemplateCompiler(templateCompilerPath, EmberENV = {}) { let templateCompilerFullPath = require.resolve(templateCompilerPath); let cacheData = TemplateCompilerCache.get(templateCompilerFullPath); @@ -161,7 +144,7 @@ function getTemplateCompiler(templateCompilerPath, EmberENV = {}) { // the shared global config let clonedEmberENV = JSON.parse(JSON.stringify(EmberENV)); - let sandbox = { + let context = vm.createContext({ EmberENV: clonedEmberENV, console, @@ -173,17 +156,7 @@ function getTemplateCompiler(templateCompilerPath, EmberENV = {}) { // fake the module into thinking we are running inside a Node context 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 (!hasGlobalThis) { - sandbox.global = sandbox; - } - - let context = vm.createContext(sandbox); + }); script.runInContext(context);