Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publishable Expo library has wrong main value in package.json out of the box. #30182

Open
1 of 4 tasks
D-Kuzin opened this issue Feb 26, 2025 · 0 comments
Open
1 of 4 tasks

Comments

@D-Kuzin
Copy link

D-Kuzin commented Feb 26, 2025

Current Behavior

When creating a fresh expo workspace using the command:
npx create-nx-workspace@latest --preset=expo --appName=expo

And creating a new expo library using the command:
nx g lib --publishable --importPath=@org/expo-lib

Then the library will have the following package.json by default:

{
  "name": "@org/expo-lib",
  "version": "0.0.1",
  "main": "src/index.ts",
  "peerDependencies": {
    "react": "~18.3.1",
    "react-native": "0.76.3"
  }
}

After adding some content into the index.ts file and building the library with the command:
yarn nx build expo-lib

When inspecting the dist folder of the library, the package.json content is the following:

{
  "name": "@org/expo-lib",
  "version": "0.0.1",
  "main": "src/index.ts",
  "peerDependencies": {
    "react": "~18.3.1",
    "react-native": "0.76.3"
  },
  "module": "./index.esm.js",
  "type": "module",
  "types": "./index.esm.d.ts"
}

When inspecting the contents, there doesn't exist any index.ts file as the package.json is referencing to.

Expected Behavior

It's expected that either:

  1. Rollup overwrites by default the main field with ./index.esm.js when building the library
  2. Expo library doesn't add the field main in the package.json when generating the library

GitHub Repo

https://github.com/D-Kuzin/nx-expo-lib

Steps to Reproduce

  1. Build expo-lib
  2. Insepct dist/expo-lib/package.json and see that there's a reference to src/index.ts

Nx Report

Node           : 23.8.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.9.2

nx                     : 20.4.6
@nx/js                 : 20.4.6
@nx/jest               : 20.4.6
@nx/eslint             : 20.4.6
@nx/workspace          : 20.4.6
@nx/devkit             : 20.4.6
@nx/eslint-plugin      : 20.4.6
@nx/expo               : 20.4.6
@nx/module-federation  : 20.4.6
@nx/react              : 20.4.6
@nx/rollup             : 20.4.6
@nx/web                : 20.4.6
@nx/webpack            : 20.4.6
typescript             : 5.7.3
---------------------------------------
Registered Plugins:
@nx/expo/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/rollup/plugin

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant