Skip to content

[bug]: Invalid package.json exports configuration causes Metro bundler warning #1600

@hayata-suenaga

Description

@hayata-suenaga

Description

The wildcard exports patterns in package.json cause Metro bundler (used by Expo/React Native) to produce warnings about non-existent files.

Warning Message

WARN  The package /Users/.../node_modules/algoliasearch contains an invalid package.json configuration. Consider raising this issue with the package maintainer(s).

Reason: The resolution for "/Users/.../node_modules/algoliasearch/dist/lite/builds/browser.js" defined in "exports" is /Users/.../node_modules/algoliasearch/dist/lite/builds/browser.js.js, however this file does not exist. Falling back to file-based resolution.

Root Cause

The following wildcard exports patterns in package.json are causing the issue:

"exports": {
  ...
  "./dist/*": "./dist/*.js",
  "./dist/lite/builds/*": "./dist/lite/builds/*.js"
}

When Metro resolves ./dist/lite/builds/browser.js, the wildcard pattern ./dist/lite/builds/* captures browser.js as the * portion, and then substitutes it into ./dist/lite/builds/*.js, resulting in ./dist/lite/builds/browser.js.js — which doesn't exist.

Environment

  • algoliasearch version: 5.46.0
  • Bundler: Metro (via Expo)
  • Platform: React Native / Expo

Client

Search

Version

5.46.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions