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

NX Overwrites type in package.json with @nx/vite:build executor #27057

Closed
1 of 4 tasks
simeon-raykov opened this issue Jul 23, 2024 · 1 comment · Fixed by #27084
Closed
1 of 4 tasks

NX Overwrites type in package.json with @nx/vite:build executor #27057

simeon-raykov opened this issue Jul 23, 2024 · 1 comment · Fixed by #27084

Comments

@simeon-raykov
Copy link

Current Behavior

Currently, NX overwrites the type in our package.json in the dist folder if we use the @nx/vite:build executor with the generatePackageJson: true option. We want to use type: 'commonjs', but we get type: 'module' instead.

Screenshot 2024-07-23 at 9 55 39

Expected Behavior

@nx/vite:build does not overwrite the type in package.json if it's already set in the library's package.json when used with the generatePackageJson: true option

GitHub Repo

No response

Steps to Reproduce

  1. Create a new library using NX JS.
  2. Use Vite as the bundler.
  3. Add "type": "commonjs" to package.json.
  4. Add "generatePackageJson": true to the @nx/vite:build.options.
  5. Build the library.
  6. The package.json in the dist folder does not have "type": "commonjs".

Nx Report

Node   : 20.11.0
OS     : darwin-arm64
yarn   : 3.6.1

nx (global)        : 19.5.0
nx                 : 19.1.1
@nx/js             : 19.1.1
@nx/jest           : 19.1.1
@nx/linter         : 19.1.1
@nx/eslint         : 19.1.1
@nx/workspace      : 19.1.1
@nx/cypress        : 19.1.1
@nx/devkit         : 19.1.1
@nx/eslint-plugin  : 19.1.1
@nx/next           : 19.1.1
@nx/playwright     : 19.1.1
@nx/plugin         : 19.1.1
@nx/react          : 19.1.1
@nx/storybook      : 19.1.1
@nrwl/tao          : 19.1.1
@nx/vite           : 19.1.1
@nx/web            : 19.1.1
@nx/webpack        : 19.1.1
nx-cloud           : 19.0.0
typescript         : 5.1.6
---------------------------------------
Community plugins:
@jscutlery/semver      : 5.2.2
@nx-tools/nx-container : 6.0.1
---------------------------------------
Local workspace plugins:
         @ps/web-martech-cms-types
         @ps/web-shared-analytics
         @ps/web-shared-api-types
         @ps/web-core-tools
         @ps/web-core-intl

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

ndcunningham pushed a commit that referenced this issue Jul 24, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
The `@nx/vite:build` executor is always overwriting the
`packageJson.type` field when generating a packageJson.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The `@nx/vite:build` executor should respect the existing type in
packageJson

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #27057
FrozenPandaz pushed a commit that referenced this issue Jul 24, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
The `@nx/vite:build` executor is always overwriting the
`packageJson.type` field when generating a packageJson.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The `@nx/vite:build` executor should respect the existing type in
packageJson

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #27057

(cherry picked from commit db7cb5d)
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants