Skip to content

Commit

Permalink
fix: disable package imports by default (#755)
Browse files Browse the repository at this point in the history
* fix: disable package imports by default

* chore: add changeset
  • Loading branch information
jbroma authored Sep 20, 2024
1 parent c4a3235 commit 90faeeb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-paws-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@callstack/repack': patch
---

Disable package imports by default
10 changes: 10 additions & 0 deletions packages/repack/src/utils/getResolveOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function getResolveOptions(platform: string, options?: ResolveOptions) {

let conditionNames: string[];
let exportsFields: string[];
let importsFields: string[];

if (enablePackageExports) {
/**
Expand All @@ -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
Expand Down Expand Up @@ -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,
};
}

0 comments on commit 90faeeb

Please sign in to comment.