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

Upgrading from 0.30.0 to 0.31.0 breaks webpack #228

Closed
suneg opened this issue Sep 28, 2022 · 5 comments · Fixed by #237
Closed

Upgrading from 0.30.0 to 0.31.0 breaks webpack #228

suneg opened this issue Sep 28, 2022 · 5 comments · Fixed by #237
Labels
bug Something isn't working

Comments

@suneg
Copy link

suneg commented Sep 28, 2022

We've encountered that upgrading to the latest release causes problems downstream in our React/Webpack setup.

Creating an optimized production build...
Failed to compile.

Module not found: Error: Default condition should be last one

This looks related to PR #221

Downgrading back to 0.30.0 makes everything work again.

@DerZade
Copy link
Contributor

DerZade commented Oct 7, 2022

Can confirm.

Also the only difference between the files built with 0.31.0 as opposed to 0.30.0 seems to be related to the changes made in #221 (only exports in package.json are different).

@LeonHuzen
Copy link

Can confirm, the output of different versions to the package.json:

0.31.0 & 0.32.0:

"exports": {
  ".": {
    "import": {
      "default": "./esm/index.js",
      "types": "./types/index.d.ts"
    }
  }
},

0.30.0:

  "exports": {
    ".": {
      "import": "./esm/index.js",
      "types": "./types/index.d.ts"
    }
  },

@Macil
Copy link
Contributor

Macil commented Dec 19, 2022

Webpack expects that the default property is always the last one inside of an exports object. (The Nodejs documentation for the exports field mentions that the order is important: look for "key order is signficant" in https://nodejs.org/api/packages.html. Here's an example of another project running into this issue and fixing it by reordering the properties: transitive-bullshit/chatgpt-api#25.)

If you edit the exports to reorder the properties like this, then it works fine with Webpack:

"exports": {
  ".": {
    "import": {
      "types": "./types/index.d.ts",
      "default": "./esm/index.js"
    }
  }
},

@dsherret
Copy link
Member

Yeah that’s a bug. Types should come first. TypeScript works the same way (sorry, I didn’t know the order mattered until recently)

@dsherret dsherret added the bug Something isn't working label Dec 19, 2022
Macil added a commit to Macil/dnt that referenced this issue Dec 19, 2022
@dsherret
Copy link
Member

dsherret commented Dec 19, 2022

Fixed in 0.32.1 (thanks @Macil!). Sorry for the delay on this. It was actually wrong before in 0.30.0 too (and prior versions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants