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

excluded files are still added to exports #93

Open
smeijer opened this issue Sep 18, 2024 · 1 comment
Open

excluded files are still added to exports #93

smeijer opened this issue Sep 18, 2024 · 1 comment

Comments

@smeijer
Copy link

smeijer commented Sep 18, 2024

Files that are excluded by an exclude: [glob], and are not written to ./dist, are still written to package.json#exports. I've created a small repo here: https://stackblitz.com/edit/tshy-exclude-exports?file=package.json&terminal=dev

Assuming the following package.json config:

  "tshy": {
    "exclude": [
      "src/**.test.ts"
    ],
    "exports": [
      "src/*.ts"
    ]
  },

And the following source files:

/src/index.ts
/src/another.ts
/src/another.test.ts

The following dist files are generated: (as expected)

/dist/commonjs/another.d.ts       
/dist/commonjs/another.d.ts.map   
/dist/commonjs/another.js         
/dist/commonjs/another.js.map     
/dist/commonjs/index.d.ts         
/dist/commonjs/index.d.ts.map     
/dist/commonjs/index.js           
/dist/commonjs/index.js.map       
/dist/commonjs/package.json 
/dist/esm/another.d.ts       
/dist/esm/another.d.ts.map   
/dist/esm/another.js         
/dist/esm/another.js.map     
/dist/esm/index.d.ts         
/dist/esm/index.d.ts.map     
/dist/esm/index.js           
/dist/esm/index.js.map       
/dist/esm/package.json 

Generated package.json#exports (unexpected)

  "exports": {
    "./another.test": {  <<< this shouldn't be here
      "import": {
        "types": "./dist/esm/another.test.d.ts",
        "default": "./dist/esm/another.test.js"
      },
      "require": {
        "types": "./dist/commonjs/another.test.d.ts",
        "default": "./dist/commonjs/another.test.js"
      }
    },
    "./another": {
      "import": {
        "types": "./dist/esm/another.d.ts",
        "default": "./dist/esm/another.js"
      },
      "require": {
        "types": "./dist/commonjs/another.d.ts",
        "default": "./dist/commonjs/another.js"
      }
    },
    ".": {
      "import": {
        "types": "./dist/esm/index.d.ts",
        "default": "./dist/esm/index.js"
      },
      "require": {
        "types": "./dist/commonjs/index.d.ts",
        "default": "./dist/commonjs/index.js"
      }
    },
    "./package.json": "./package.json"
  },
@isaacs
Copy link
Owner

isaacs commented Sep 18, 2024

Ah, yes, when it expands the glob exports, it's not using the excluded as an ignore patter, as it should be.

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