ReviewOS

stacks/bun-plugin-dtsx

Consuming the package doesn't work

#4
Closed mfeckie opened this 9 days ago ·
9 days ago

Describe the bug

error: Could not resolve: "bun-plugin-dts-auto". Maybe you need to "bun install"?
import dts from 'bun-plugin-dts-auto'
                ^
/Users/experiments/totter/build.ts:1:17 16error: script "build" exited with code 1 (SIGHUP)

Errors when trying to consume the plugin

Manually editing package.json in node_modules to remove this line https://github.com/stacksjs/bun-plugin-dts-auto/blob/main/package.json#L25 seems to resolve the problem

Reproduction

Reproduction

System Info

  System:
    OS: macOS 13.5
    CPU: (10) arm64 Apple M1 Pro
    Memory: 240.33 MB / 32.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.asdf/installs/nodejs/18.16.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.19.4 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.6.10 - ~/Library/pnpm/pnpm
    Watchman: 2023.07.24.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 115.1.56.20
    Chrome: 115.0.5790.114
    Edge: 114.0.1823.67
    Safari: 16.6

Used Package Manager

bun

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
9 days ago

The problem is in package.json.

You are bundling and you are including only the bundled files but you are saying to use source code for bun.

  "exports": {
    ".": {
      "bun": "./src/index.ts",
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  },

src/index.ts is not included in npm package. This package should be exclusive for Bun so have nonsense include node bundle files. You can bundle directly for Bun. Anyway modify to:

  "exports": {
    ".": {
      "bun": "./dist/index.js",
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js"
    }
  },
9 days ago

My bad on the late response here. Been busy working on a Stacks release, and we are now finally in a place to consume this ourselves. And duh, ran into this issue, too.

The problem is that we aren't exporting the src files at the moment. A fix is incoming 💪

9 days ago

v0.3.0 is now released and it resolves this issue https://github.com/stacksjs/bun-plugin-dts-auto/releases/tag/v0.3.0

Sign in to comment on this issue.