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

feat(bundling): generate matching d.ts files for rollup #18342

Merged
merged 2 commits into from
Jul 28, 2023

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Jul 27, 2023

This PR updates the rollup executor such that it produces .d.ts files matching the output bundle.

It also:

  1. Use [name].esm.js and [name].cjs.js naming convention so Node/TSC doesn't have problems matching CJS files with their .d.ts file -- subsequent requires/imports from .cjs requires file extension to be included, which puts the burden on lib authors.
  2. Updates the exports field to align with current best practice (import + default, no types)
  3. Generates types still when SWC is used

So a user using dual formats will see:

{
  "exports": {
    "./package.json": "./package.json",
    ".": {
      "import": "./index.esm.js",
      "default": "./index.cjs.js"
  }
}

The types are inferred from file names e.g. index.cjs.d.ts or index.esm.d.ts.

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

@vercel
Copy link

vercel bot commented Jul 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2023 2:13am

@jaysoo jaysoo force-pushed the feat/rollup-dts branch from edcbadf to d449bc4 Compare July 27, 2023 14:09
@jaysoo jaysoo marked this pull request as ready for review July 27, 2023 14:18
@jaysoo jaysoo requested a review from a team as a code owner July 27, 2023 14:18
@jaysoo jaysoo requested a review from ndcunningham July 27, 2023 14:18
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from d449bc4 to 6600e31 Compare July 27, 2023 14:29
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from 6600e31 to b9d8cf1 Compare July 27, 2023 14:33
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from b9d8cf1 to 9765310 Compare July 27, 2023 14:39
@jaysoo jaysoo force-pushed the feat/rollup-dts branch 2 times, most recently from a6a74a5 to 8076507 Compare July 27, 2023 15:36
@jaysoo jaysoo requested a review from a team as a code owner July 27, 2023 15:36
@jaysoo jaysoo requested a review from FrozenPandaz July 27, 2023 15:36
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from 8076507 to 87ac4a6 Compare July 27, 2023 16:23
@jaysoo jaysoo requested a review from a team as a code owner July 27, 2023 16:23
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from 87ac4a6 to 92d02b2 Compare July 27, 2023 17:32
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from 92d02b2 to de83d78 Compare July 27, 2023 18:20
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from de83d78 to 70e76e9 Compare July 27, 2023 19:32
@jaysoo jaysoo force-pushed the feat/rollup-dts branch from 70e76e9 to bb90772 Compare July 27, 2023 20:01
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants