8000 fix(cjs): include `d.ts` cjs transformation when cjs package by userquin · Pull Request #526 · unjs/unbuild · GitHub
[go: up one dir, main page]

Skip to content

fix(cjs): include d.ts cjs transformation when cjs package #526

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

userquin
Copy link
Contributor
@userquin userquin commented Apr 3, 2025

Right now, we're generating wrong CJS d.ts files based on declaration option and we shoud check the package is NOT ESM ; we o 8000 nly need to transform d.ts files when type !== module.

/cc @pio

Check unjs/destr below and this gh repro: https://github.com/userquin/destr-consola-test

unjs/destr

image
unjs/destr

image
unjs/destr at arethetypeswrong

image
unjs/destr/package.json

  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs"
    }
  },
  "main": "./dist/index.cjs",
  "module": "./dist/index.mjs",
  "types": "./dist/index.d.ts",

unjs/destr exports

@pi0 pi0 requested a review from danielroe April 3, 2025 22:30
@userquin
Copy link
Contributor Author
userquin commented Apr 3, 2025

Some problems when using require, looks like we need the namespace creation. I'm going to check esm, but it should work (creating esm branch in the gh repo).

Arrrgg, it is working, I need to run tsc && node ./src/index.cjs:

node ./src/index.cjs
{ foo: 'bar' }

Works with both, node and node16 module resolution:

    "module": "Node16",
    "moduleResolution": "node16",

and

    "module": "CommonJS",
    "moduleResolution": "node",

NOTE: added build, build:node16 and typecheck:node16 script in the gh repro.

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

Successfully merging this pull request may close these issues.

2 participants
0