From c18675f35ea8dd12b04b554273f17d64ba792a95 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:57:59 +0530 Subject: [PATCH 1/3] Fix: tests, resolve importSync module resolution issue --- packages/macros/tests/babel/import-sync.test.ts | 4 ++-- tests/scenarios/v2-addon-type-module-test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/macros/tests/babel/import-sync.test.ts b/packages/macros/tests/babel/import-sync.test.ts index 9d7536a4f..945554819 100644 --- a/packages/macros/tests/babel/import-sync.test.ts +++ b/packages/macros/tests/babel/import-sync.test.ts @@ -11,7 +11,7 @@ describe('importSync', function () { import { importSync } from '@embroider/macros'; importSync('foo'); `); - expect(code).toMatch(/import esc from "\.\.\/\.\.\/src\/addon\/es-compat2"/); + expect(code).toMatch(/import esc from "\.\.\/\.\.\/src\/addon\/es-compat2\.js"/); expect(code).toMatch(/esc\(require\(['"]foo['"]\)\)/); expect(code).not.toMatch(/window/); }); @@ -31,7 +31,7 @@ describe('importSync', function () { import { importSync as i } from '@embroider/macros'; i('foo'); `); - expect(code).toMatch(/require\(['"]foo['"]\)/); + expect(code).toMatch(/require\(['"]foo['"]\)\)/); expect(code).not.toMatch(/window/); }); test('import of importSync itself gets removed', () => { diff --git a/tests/scenarios/v2-addon-type-module-test.ts b/tests/scenarios/v2-addon-type-module-test.ts index ec898767e..a76c4fbee 100644 --- a/tests/scenarios/v2-addon-type-module-test.ts +++ b/tests/scenarios/v2-addon-type-module-test.ts @@ -15,6 +15,7 @@ appScenarios addon.pkg.exports = { './*': './src/*.js', './addon-main.cjs': './addon-main.cjs', + './side-effecting.js': './src/side-effecting.js' }; addon.pkg['ember-addon'].main = 'addon-main.cjs'; @@ -32,8 +33,7 @@ appScenarios */ 'demo.js': ` import { importSync } from '@embroider/macros'; - - importSync('./side-effecting.js'); + importSync('v2-addon/side-effecting.js'); `, }, }); From 6d92e47cd9214fa08ed00598ce9503ae941667d1 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Tue, 3 Dec 2024 23:16:40 +0530 Subject: [PATCH 2/3] fix: the path to relative path --- tests/scenarios/v2-addon-type-module-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scenarios/v2-addon-type-module-test.ts b/tests/scenarios/v2-addon-type-module-test.ts index a76c4fbee..969b22226 100644 --- a/tests/scenarios/v2-addon-type-module-test.ts +++ b/tests/scenarios/v2-addon-type-module-test.ts @@ -33,7 +33,7 @@ appScenarios */ 'demo.js': ` import { importSync } from '@embroider/macros'; - importSync('v2-addon/side-effecting.js'); + importSync('./side-effecting.js'); `, }, }); From 452e826fbd6d8bc2a54ca4f74aa8a4646a948732 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Tue, 3 Dec 2024 23:31:01 +0530 Subject: [PATCH 3/3] fix: remove extra "/)" --- packages/macros/tests/babel/import-sync.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/macros/tests/babel/import-sync.test.ts b/packages/macros/tests/babel/import-sync.test.ts index 945554819..bdbe015a5 100644 --- a/packages/macros/tests/babel/import-sync.test.ts +++ b/packages/macros/tests/babel/import-sync.test.ts @@ -31,7 +31,7 @@ describe('importSync', function () { import { importSync as i } from '@embroider/macros'; i('foo'); `); - expect(code).toMatch(/require\(['"]foo['"]\)\)/); + expect(code).toMatch(/require\(['"]foo['"]\)/); expect(code).not.toMatch(/window/); }); test('import of importSync itself gets removed', () => {