Skip to content

package.json exports ignores some conditions (@astrojs/compiler breaking) #2357

@paperclover

Description

@paperclover

What version of Bun is running?

0.5.8

What platform is your computer?

No response

What steps can reproduce the bug?

Bun Docs show that package.json exports can define these fields.
image

It is missing import and require, where the former breaks importing @astrojs/compiler as it defines this for it's exports:

  "exports": {
    ".": {
      "browser": "./browser/index.js",
      "import": "./node/index.js",
      "default": "./browser/index.js"
    },
    ...
  },

And bun picks up browser, and ignores import.

node docs here define import, require, and node-addons which bun ignores. I've never seen that last one but it seems to have some extra logic where the first two can just be treated as a higher priority than browser.

Reproduction:

import {transform} from '@astrojs/compiler';
transform("");

What is the expected behavior?

Loading the node version of the astro compiler.

What do you see instead?

image

Additional information

Workaround for astro compiler:

import { transform } from "./node_modules/@astrojs/compiler/node/index.js";

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbun installSomething that relates to the npm-compatible client

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions