Skip to content

Publishing node library using release does not include source code. #30094

Open
@rlmcneary2

Description

Current Behavior

I created a Node monorepo specifically to publish libraries. When publishing a library the tarball doesn't include source code files (.js files).

Note that:

  • libraries are generated in a directory named libs
  • I'm using swc to transpile the TS files.

Expected Behavior

The tarball should include the source code.

GitHub Repo

https://github.com/rlmcneary2/bug-nx-publish

Steps to Reproduce

  1. npx create-nx-workspace node-pub --preset node-monorepo --docker false --framework none
  2. cd node-pub
  3. npx nx g @nx/node:library libs/lib-test --compiler swc --linter eslint --publishable --unitTestRunner jest --importPath lib-test --strict true --testEnvironment node
  4. npx nx build lib-test
  5. npx nx release --first-release --dry-run
  6. npx nx release publish --dry-run

Publish output

> nx run lib-test:nx-release-publish


📦  lib-test@X.X.X-dry-run
=== Tarball Contents ===

230B README.md   
228B package.json
=== Tarball Details ===
name:          lib-test                                
version:       X.X.X-dry-run                           
filename:      lib-test-X.X.X-dry-run.tgz              
package size:  398 B                                   
unpacked size: 458 B                                   
shasum:        50a8271df0617ee1e04442e5051a9170c02b52a5
integrity:     sha512-b7mMs/VaZMz7u[...]hyj4YNPDNrziw==
total files:   2                                       
 
Would publish to https://registry.npmjs.org/ with tag "latest", but [dry-run] was set

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Successfully ran target nx-release-publish for project lib-test

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.18.1
OS             : darwin-x64
Native Target  : x86_64-macos
npm            : 10.8.2

nx                 : 20.4.4
@nx/js             : 20.4.4
@nx/jest           : 20.4.4
@nx/eslint         : 20.4.4
@nx/workspace      : 20.4.4
@nx/devkit         : 20.4.4
@nx/esbuild        : 20.4.4
@nx/eslint-plugin  : 20.4.4
@nx/node           : 20.4.4
typescript         : 5.7.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

I suspect it's because the package.json files property is incorrect. Maybe this is the node-standalone configuration?

{
  "name": "lib-test",
  "version": "0.0.1",
  "type": "commonjs",
  "main": "./src/index.js",
  "types": "./src/index.d.ts",
  "files": [
    "dist",
    "!**/*.tsbuildinfo"
  ],
  "dependencies": {
    "tslib": "^2.3.0"
  }
}

Activity

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

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions