vercel / ncc

Compile a Node.js project into a single file. Supports TypeScript, binary addons, dynamic requires.
https://npmjs.com/@vercel/ncc
MIT License
9.13k stars 287 forks source link

Cannot use `ncc` with Yarn 3 #939

Open Speykious opened 2 years ago

Speykious commented 2 years ago

I'm making a Discord bot with Yarn 3 in Typescript. ncc has no problem with Typescript, but it seems that it doesn't account for PNP at all. image

If I try yarn pnpify ncc build, it just exists after doing nothing.

If it helps, here's my package.json

{
  "name": "sorbot",
  "version": "4.0.0",
  "packageManager": "yarn@3.2.0",
  "main": "src/index.ts",
  "private": true,
  "scripts": {
    "build": "pnpify tsc --project tsconfig.json",
    "dev": "pnpify nodemon -w src/ src/index.ts"
  },
  "devDependencies": {
    "@types/dotenv-flow": "^3.1.1",
    "@types/imap": "^0.8.35",
    "@types/node": "^17.0.31",
    "@types/nodemailer": "^6.4.4",
    "nodemon": "^2.0.16",
    "ts-node": "^10.7.0",
    "typescript": "^4.3.5"
  },
  "dependencies": {
    "@discordjs/builders": "^0.13.0",
    "@discordjs/rest": "^0.4.1",
    "@types/mailparser": "^3.4.0",
    "@yarnpkg/pnpify": "^4.0.0-rc.4",
    "argon2": "^0.28.5",
    "discord-api-types": "^0.32.1",
    "discord.js": "^13.7.0",
    "dotenv-flow": "^3.2.0",
    "imap": "^0.8.19",
    "mailparser": "^3.5.0",
    "nodemailer": "^6.7.5",
    "pg": "^8.7.3",
    "pg-hstore": "^2.3.4",
    "sequelize": "^6.19.0",
    "tsconfig-paths": "^4.0.0"
  },
  "dependenciesMeta": {
    "ts-node@10.7.0": {
      "unplugged": true
    }
  }
}

and my tsconfig.json

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Node 16",

  "include": ["src/**/*"],

  "compilerOptions": {
    "lib": ["ESNext"],
    "module": "CommonJS",
    "target": "ESNext",
    "moduleResolution": "node",
    "resolveJsonModule": true,

    "sourceMap": true,
    "outDir": "dist",

    "strict": true,
    "noImplicitReturns": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "ts-node": {
    "esm": true,
    "require": ["tsconfig-paths/register"]
  }
}
Speykious commented 2 years ago

Falling back to nodeLinker: node-modules makes it work again, but I would like to use nodeLinker: pnp whenever possible. I saw that apparently ncc supports pnp from https://github.com/vercel/ncc/pull/598, but that was on Yarn 2, which I didn't test myself... Should it just work on Yarn 3 and I'm missing something?