From 2441224b9aaf89e7ea58c67ff65b175eb13290d7 Mon Sep 17 00:00:00 2001 From: Bao Nguyen Date: Tue, 18 Aug 2026 22:23:24 +0700 Subject: [PATCH 1/2] fix: resolve config plugins through Expo --- plugin/src/withDateTimePickerStyles.ts | 2 +- test/plugin.test.js | 54 ++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 test/plugin.test.js diff --git a/plugin/src/withDateTimePickerStyles.ts b/plugin/src/withDateTimePickerStyles.ts index cee54cba..281c9f75 100644 --- a/plugin/src/withDateTimePickerStyles.ts +++ b/plugin/src/withDateTimePickerStyles.ts @@ -4,7 +4,7 @@ import { withAndroidColors, withAndroidColorsNight, withAndroidStyles, -} from '@expo/config-plugins'; +} from 'expo/config-plugins'; type ResourceXML = AndroidConfig.Resources.ResourceXML; diff --git a/test/plugin.test.js b/test/plugin.test.js new file mode 100644 index 00000000..fbca7981 --- /dev/null +++ b/test/plugin.test.js @@ -0,0 +1,54 @@ +import fs from 'fs'; +import path from 'path'; +import vm from 'vm'; +import ts from 'typescript'; + +describe('Expo config plugin', () => { + it('loads config plugins through the Expo package re-export', () => { + const sourcePath = path.join( + __dirname, + '../plugin/src/withDateTimePickerStyles.ts', + ); + const source = fs.readFileSync(sourcePath, 'utf8'); + const {outputText} = ts.transpileModule(source, { + compilerOptions: { + module: ts.ModuleKind.CommonJS, + target: ts.ScriptTarget.ES2022, + }, + fileName: sourcePath, + }); + const requestedModules = []; + const pluginModule = {exports: {}}; + const expoConfigPlugins = { + AndroidConfig: { + Colors: {assignColorValue: jest.fn()}, + Styles: { + assignStylesValue: jest.fn(), + getAppThemeGroup: jest.fn(), + }, + }, + withAndroidColors: jest.fn(), + withAndroidColorsNight: jest.fn(), + withAndroidStyles: jest.fn(), + }; + + vm.runInNewContext( + outputText, + { + exports: pluginModule.exports, + module: pluginModule, + require: (request) => { + requestedModules.push(request); + if (request === 'expo/config-plugins') { + return expoConfigPlugins; + } + throw new Error(`Cannot find module '${request}'`); + }, + }, + {filename: sourcePath}, + ); + + expect(requestedModules).toEqual(['expo/config-plugins']); + expect(pluginModule.exports.default).toEqual(expect.any(Function)); + }); +}); From 1fce12a3f30daa3d5a25ce3f4fec2af829956f80 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Mon, 31 Aug 2026 22:11:46 +0200 Subject: [PATCH 2/2] Delete test/plugin.test.js --- test/plugin.test.js | 54 --------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 test/plugin.test.js diff --git a/test/plugin.test.js b/test/plugin.test.js deleted file mode 100644 index fbca7981..00000000 --- a/test/plugin.test.js +++ /dev/null @@ -1,54 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import vm from 'vm'; -import ts from 'typescript'; - -describe('Expo config plugin', () => { - it('loads config plugins through the Expo package re-export', () => { - const sourcePath = path.join( - __dirname, - '../plugin/src/withDateTimePickerStyles.ts', - ); - const source = fs.readFileSync(sourcePath, 'utf8'); - const {outputText} = ts.transpileModule(source, { - compilerOptions: { - module: ts.ModuleKind.CommonJS, - target: ts.ScriptTarget.ES2022, - }, - fileName: sourcePath, - }); - const requestedModules = []; - const pluginModule = {exports: {}}; - const expoConfigPlugins = { - AndroidConfig: { - Colors: {assignColorValue: jest.fn()}, - Styles: { - assignStylesValue: jest.fn(), - getAppThemeGroup: jest.fn(), - }, - }, - withAndroidColors: jest.fn(), - withAndroidColorsNight: jest.fn(), - withAndroidStyles: jest.fn(), - }; - - vm.runInNewContext( - outputText, - { - exports: pluginModule.exports, - module: pluginModule, - require: (request) => { - requestedModules.push(request); - if (request === 'expo/config-plugins') { - return expoConfigPlugins; - } - throw new Error(`Cannot find module '${request}'`); - }, - }, - {filename: sourcePath}, - ); - - expect(requestedModules).toEqual(['expo/config-plugins']); - expect(pluginModule.exports.default).toEqual(expect.any(Function)); - }); -});