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

Prefer publishConfig from package.json when defined #362

Open
1 task
humphd opened this issue Jan 22, 2024 · 1 comment
Open
1 task

Prefer publishConfig from package.json when defined #362

humphd opened this issue Jan 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@humphd
Copy link

humphd commented Jan 22, 2024

Describe the feature

I'm using unbuild in a pnpm monorepo. I love how unbuild works seamlessly with the definitions in my package.json to produce CommonJS, ESM, and Types automatically. However, I've run into an issue.

I'd like to use the src/ dir (i.e., TS) vs. dist/ (i.e., JS) when using the package within the monorepo via the workspace: protocol. Essentially, I want to be able to define a different config when not published, relying on pnpm's publishConfig to do the overrides when I publish to the npm registry:

    "publishConfig": {
        "type": "module",
        "exports": {
            ".": {
                "types": "./dist/index.d.ts",
                "require": "./dist/index.js",
                "import": "./dist/index.mjs"
            }
        },
        "main": "./dist/index.js",
        "module": "./dist/index.mjs",
        "types": "./dist/index.d.ts"
    },
    "main": "./src/index.ts",

Maybe there is a better way to do what I'm after, or maybe this is a feature that could be made to work with unbuild: if publishConfig is present in package.json, override things before using the bast config in package.json to define the build.

Additional information

  • Would you be willing to help implement this feature?
@humphd
Copy link
Author

humphd commented Jan 22, 2024

Maybe this would mean teaching

export function inferEntries(
to look for publishConfig and the list of keys it can override?

@pi0 pi0 added the enhancement New feature or request label Jan 22, 2024
@pi0 pi0 changed the title Prefer publishConfig when defined Prefer publishConfig from package.json when defined Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants