From 90faeeb7d6be9ddf5aa74c9552df01ec58d5372c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Roma=C5=84czyk?= Date: Fri, 20 Sep 2024 17:34:23 +0200 Subject: [PATCH] fix: disable package imports by default (#755) * fix: disable package imports by default * chore: add changeset --- .changeset/lucky-paws-shop.md | 5 +++++ packages/repack/src/utils/getResolveOptions.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changeset/lucky-paws-shop.md diff --git a/.changeset/lucky-paws-shop.md b/.changeset/lucky-paws-shop.md new file mode 100644 index 000000000..712e93f2c --- /dev/null +++ b/.changeset/lucky-paws-shop.md @@ -0,0 +1,5 @@ +--- +'@callstack/repack': patch +--- + +Disable package imports by default diff --git a/packages/repack/src/utils/getResolveOptions.ts b/packages/repack/src/utils/getResolveOptions.ts index 77f0e155e..401fcf2e1 100644 --- a/packages/repack/src/utils/getResolveOptions.ts +++ b/packages/repack/src/utils/getResolveOptions.ts @@ -55,6 +55,7 @@ export function getResolveOptions(platform: string, options?: ResolveOptions) { let conditionNames: string[]; let exportsFields: string[]; + let importsFields: string[]; if (enablePackageExports) { /** @@ -79,6 +80,11 @@ export function getResolveOptions(platform: string, options?: ResolveOptions) { }); } + /** + * Disable importsFields completely since it's not supported by metro at all. + */ + importsFields = []; + /** * Match what React Native uses from metro-config. * Usage of 'extensionAlias' removes the need for @@ -125,5 +131,9 @@ export function getResolveOptions(platform: string, options?: ResolveOptions) { * Reference: Webpack's [configuration.resolve.extensionAlias](https://webpack.js.org/configuration/resolve/#resolveextensionalias) */ extensionAlias: extensionAlias, + /** + * Reference: Webpack's [configuration.resolve.importsFields](https://webpack.js.org/configuration/resolve/#resolveimportsfields) + */ + importsFields: importsFields, }; }