wclr / yalc

Work with yarn/npm packages locally like a boss.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yalc publish - ~/.yalc/packages/my-package is missing most of its files

amunrarara opened this issue · comments

When using yalc publish, the output within the ~/.yalc/packages/ directory is missing almost everything that's in the project's dist folder; the only thing in there is index.js which has a single import statement, meant to start off several rounds of imports through 'bucket-export' files (files that are only used to export other files).

Running npm publish properly publishes the entire package to npm's registry, though, so it seems there's something funny happening with yalc.

Any guidance would be greatly appreciated, thank you!

NPM v20.10.0

Steps to reproduce:

  1. Clone this repo: https://github.com/ostyjs/nostr-hooks
  2. yalc publish the repo
  3. yalc add the repo to a React + Vite project (npx create-vite-app will do the trick)
  4. run yarn dev
  5. See the following error:
yarn run v1.22.22
$ vite && tailwindcss -i ./src/input.css -o ./src/output.css --watch

  VITE v5.2.11  ready in 106 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
✘ [ERROR] Could not resolve "./hooks"

    node_modules/@amunrarara/nostr-hooks/dist/index.js:1:14:
      1 │ export * from './hooks';
        ╵               ~~~~~~~~~
  1. Explore the dist/ directory in my npm registry deployment for that library: https://www.npmjs.com/package/@amunrarara/nostr-hooks?activeTab=code
  2. Compare to the dist/ found at ~/.yalc/packages/@amunrarara/nostr-hooks/2.6.3, which only contains index.js and nothing else.

Note that I updated my own copy's package.json name field to be @amunrara/nostr-hooks

package.json for posterity:

{
"name": "@amunrarara/nostr-hooks",
"version": "2.6.3",
"description": "React hooks for developing Nostr clients.",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/amunrarara/nostr-hooks.git"
},
"files": [
"./dist/**/*"
],
"funding": [
"https://getalby.com/p/sepehr"
],
"exports": {
".": {
"import": "./dist/index.js"
},
"./package.json": "./package.json"
},
"scripts": {
"build": "tsc",
"test": "jest",
"format": "prettier --write .",
"prepare": "npm run build",
"prepublishOnly": "npm run build"
},
"jest": {
"rootDir": ".",
"preset": "ts-jest/presets/default-esm",
"testEnvironment": "jsdom",
"transform": {
"^.+\.(t|j)sx?$": [
"ts-jest",
{
"useESM": true
}
]
},
"extensionsToTreatAsEsm": [
".ts",
".tsx"
],
"moduleNameMapper": {
"^nostr-hooks$": "/src/index.ts"
},
"modulePathIgnorePatterns": [
"dist"
],
"testRegex": "test.(js|ts|tsx)$",
"setupFilesAfterEnv": [
"/jest.setup.ts"
]
},
"keywords": [
"nostr",
"decentralized",
"social",
"censorship-resistance",
"client",
"react",
"hooks"
],
"author": "Sepehr Safari",
"license": "MIT",
"devDependencies": {
"@jest/globals": "^29.7.0",
"@testing-library/react": "^14.2.0",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.10",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^3.2.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"typescript": "^5.4.5"
},
"dependencies": {
"@nostr-dev-kit/ndk": "^2.8.1",
"@nostr-dev-kit/ndk-cache-dexie": "^2.4.1",
"lodash": "^4.17.21",
"zustand": "^4.5.2"
}
}

Is there, perhaps, some limited folder depth in which yalc defaults?

I'm totally unsure why the wildcard resolutions are not working. I did kind of resolve the issue by removing the "files" directive in package.json. However, now the entire project is present in the yalc store.

"files": [
    "./dist/**/*"
  ],

Can anyone explain what's wrong with this wildcard?

I believe the wildcard needs to be /dist/**/*, not ./dist/**/*. I haven't found an authorative reason as to why, but it solved the same problem in my case.