wclr / yalc

Work with yarn/npm packages locally like a boss.
MIT License
5.64k stars 147 forks source link

yalc not support package.json `exports` and `files` #165

Closed byteab closed 3 years ago

byteab commented 3 years ago

  "name": "foo",
  "private": true,
  "version": "3.5.1",
  "description": "a desc",
  "main": "index.js",
  "module": "esm/index.js",
  "types": "index.d.ts",
  "files": [
    "**"
  ],
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "types": "./index.d.ts",
      "module": "./esm/index.js",
      "default": "./index.js"
    },
    "./vanilla": {
      "types": "./vanilla.d.ts",
      "module": "./esm/vanilla.js",
      "default": "./vanilla.js"
    },
    "./middleware": {
      "types": "./middleware.d.ts",
      "module": "./esm/middleware.js",
      "default": "./middleware.js"
    }
  }
}

import middleware from 'foo/middleware' not working

wclr commented 3 years ago

I'm not sure what you mean by not working, and what yalc has to do with the exports field.

byteab commented 3 years ago

I want to import a sub module defined inside "exports" field, but as it seems a local package added by yalc not respect package.json exports field.

so it's not possible to do import vanilla foo/vanilla

wclr commented 3 years ago

by yalc not respect package.json exports field.

How yalc should respect exports field?

byteab commented 3 years ago

I am really sorry, it was my mistake.

devinrhode2 commented 2 years ago

I seem to have a similar issue... but...

running npm publish --dry-run prints out:

npm notice === Tarball Contents === 
npm notice 655B  package.json                 
npm notice 3.0kB src/AuthorizedApiBase.test.ts
npm notice 904B  src/AuthorizedApiBase.ts     
npm notice 1.5kB tsconfig.json     

From here I could tell that yalc and npm are doing the same thing. Yalc is doing everything correctly, something about our package.json config/setup is wrong...

devinrhode2 commented 2 years ago

my main field was ./dist/index.cjs - the ./ prefix ruined the whole thing somehow... clearly I made a mistake but yalc+npm tried to smooth it over..

changing it to just dist/index.cjs fixed the issue.

I also added "files": ["dist"], to avoid included src files and tsconfig.json.