From 9d06a35c578aa590f278dc5b26bb4778e7ff86bd Mon Sep 17 00:00:00 2001 From: Artem Zakharchenko Date: Tue, 24 Nov 2026 13:01:15 +0100 Subject: [PATCH] fix: do not bundle polyfills --- test/app/metro.config.js | 14 ++++++++++++++ tsup.config.ts | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/app/metro.config.js b/test/app/metro.config.js index a39ecac..af2d566 100644 --- a/test/app/metro.config.js +++ b/test/app/metro.config.js @@ -12,4 +12,18 @@ module.exports = mergeConfig(getDefaultConfig(__dirname), { path.resolve(packageRoot, 'node_modules'), ], }, + transformer: { + /** + * @note Disable inline requires to match the default of "@expo/metro-config". + * This is the stricter mode: every import is evaluated eagerly, in order. + */ + getTransformOptions: async () => { + return { + transform: { + experimentalImportSupport: false, + inlineRequires: false, + }, + } + }, + }, }) diff --git a/tsup.config.ts b/tsup.config.ts index f62fdc1..2aca993 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,11 +1,16 @@ import { defineConfig } from 'tsup' export default defineConfig({ - entry: ['src/index.ts'], + entry: ['src/**/*.{ts,js}'], + /** + * @note Do not bundle the modules. Bundling inlines the polyfills into + * the entry module, hoisting the "msw" and interceptor imports above them. + * Metro then evaluates those before the polyfills unless "inlineRequires" is on. + */ + bundle: false, format: ['esm'], platform: 'neutral', outDir: 'lib', - external: ['msw', /^@mswjs\/.+/, /^react-native(?:\/|$)/], clean: true, sourcemap: true, onSuccess: 'tsc --project tsconfig.build.json',