Skip to content

exports field in package.json blocks dist/index.css import documented in README #61

Description

@jackson-lewis

Description

Since v3.1.1 (package.json exports field was added to "fix package.json module exports to correctly reference build outputs"), importing the default stylesheet as documented in the README no longer works:

import 'react-loqate/dist/index.css';

This now throws:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/index.css' is not defined by "exports" in node_modules/react-loqate/package.json

Reproduction

npm install react-loqate@3.1.2
node -e "require.resolve('react-loqate/dist/index.css')"
# ERR_PACKAGE_PATH_NOT_EXPORTED

The file physically exists at dist/index.css in the published package — it's just not reachable because the exports map only whitelists "." and "./package.json":

"exports": {
  ".": {
    "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
    "require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
  },
  "./package.json": "./package.json"
}

Expected behavior

The README's own "Installation" section still documents this import:

import AddressSearch from 'react-loqate';
// to use the default styles for the default components
import 'react-loqate/dist/index.css';

so ./dist/index.css (or a ./dist/* wildcard) should be included in exports.

Suggested fix

"exports": {
  ".": { ... },
  "./dist/index.css": "./dist/index.css",
  "./package.json": "./package.json"
}

Environment

  • react-loqate: 3.1.2
  • Reproduced with plain Node require.resolve (v24.12.0) aolve) via Next.js — not runtime- or bundler-specific, it's the package's exports map.

Workaround

For anyone hitting this in a webpack/Next.js project, aliasing the path manually works:

config.resolve.alias["react-loqate/dist/index.css"] = path.join(
  path.dirname(require.resolve("react-loqate/package.json
  "dist/index.css",
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions