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

Proposal: "overrides" #67

Open
colinhacks opened this issue Jun 5, 2024 · 1 comment
Open

Proposal: "overrides" #67

colinhacks opened this issue Jun 5, 2024 · 1 comment

Comments

@colinhacks
Copy link

This is a second proposal to solve the core problem described here: #65. Namely, I'm trying to construct a TypeScript monorepo with "live types" across package boundaries.

To do this, I'm now attempting to a custom "typescript" export condition that points to my TypeScript source code. I can then configure compilerOptions.customConditions such that TypeScript looks at the raw .ts source of my local packages in development instead of the .d.ts artifacts.

Currently tshy overrides everything in "exports" including any custom conditions I'd like to define. This could be resolved with a general-purpose "overrides" field that gets deep-merged into the generated package.json.

  "tshy": {
    "exports": {
      "./package.json": "./package.json",
      ".": "./src/index.ts"
    },
    "overrides": {
      "exports": {
        ".": { 
          "ts": "./src/index.ts" 
        }
      }
    }
  },

This config would result in something like this:

{
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "ts": "./src/index.ts",
      "import": {
        "types": "./dist/esm/index.d.ts",
        "default": "./dist/esm/index.js"
      },
      "require": {
        "types": "./dist/commonjs/index.d.ts",
        "default": "./dist/commonjs/index.js"
      },
    }
  }
}
@isaacs
Copy link
Owner

isaacs commented Jul 7, 2024

Is exports the only thing that it'd be able to override? It feels like it could just be called exportsOverrides or something in that case, and then the logic is just that it'll be deep-merged on top of whatever else tshy generates. So kind of a general purpose manual escape-hatch for whatever.

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