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

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

Open
amunrarara opened this issue May 5, 2024 · 4 comments

Comments

@amunrarara
Copy link

amunrarara commented May 5, 2024

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

@amunrarara
Copy link
Author

amunrarara commented May 5, 2024

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"
}
}

@amunrarara
Copy link
Author

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

@amunrarara
Copy link
Author

amunrarara commented May 5, 2024

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?

@kaliatech
Copy link

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.

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

No branches or pull requests

2 participants