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

Bug: build failure with error "Default condition should be last one" #1011

Closed
1 task done
sykim4 opened this issue Nov 13, 2024 · 0 comments · Fixed by #1013
Closed
1 task done

Bug: build failure with error "Default condition should be last one" #1011

sykim4 opened this issue Nov 13, 2024 · 0 comments · Fixed by #1013
Labels
bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@sykim4
Copy link
Contributor

sykim4 commented Nov 13, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Which Mux Elements/Packages does this apply to? Select all that apply

mux-player-react

Which browsers are you using?

Chrome

Which operating systems are you using?

macOS

Description

Currently not directly consuming the mux library but via a nested dependency in my next app like so:

app -> dependency A -> dependency B -> @mux/mux-player-react

when trying to run next build, I get the following error:

Module not found: Default condition should be last one

https://nextjs.org/docs/messages/module-not-found

When I rearrange the exports from this:

  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs.js",
      "default": "./dist/index.cjs.js",
      "types@<4.3.5": "./dist/types-ts3.4/index.d.ts",
      "types": "./dist/types/index.d.ts"
    },
    "./lazy": {
      "import": "./dist/lazy.mjs",
      "default": "./dist/lazy.mjs",
      "types@<4.3.5": "./dist/types-ts3.4/lazy.d.ts",
      "types": "./dist/types/lazy.d.ts"
    },
    "./themes/*": {
      "import": "./dist/themes/*.mjs",
      "require": "./dist/themes/*.cjs.js",
      "default": "./dist/themes/*.cjs.js",
      "types@<4.3.5": "./dist/types-ts3.4/themes/*.d.ts",
      "types": "./dist/types/themes/*.d.ts"
    }
  },

to this:

  "exports": {
    ".": {
      "import": "./dist/index.mjs",
      "require": "./dist/index.cjs.js",
      "types@<4.3.5": "./dist/types-ts3.4/index.d.ts",
      "types": "./dist/types/index.d.ts",
      "default": "./dist/index.cjs.js"
    },
    "./lazy": {
      "import": "./dist/lazy.mjs",
      "types@<4.3.5": "./dist/types-ts3.4/lazy.d.ts",
      "types": "./dist/types/lazy.d.ts",
      "default": "./dist/lazy.mjs"
    },
    "./themes/*": {
      "import": "./dist/themes/*.mjs",
      "require": "./dist/themes/*.cjs.js",
      "types@<4.3.5": "./dist/types-ts3.4/themes/*.d.ts",
      "types": "./dist/types/themes/*.d.ts",
      "default": "./dist/themes/*.cjs.js"
    }
  },

the build is fixed.

Using node v18.14.2, next v14.2.18.

node docs seem to specify that default should always come last
Webpack docs also seem to infer that default should be the last condition but also to avoid it as it can be "handled differently between tooling"

Current Behavior

next build fails with Module not found: Default condition should be last one

Expected Behavior

next build should be successful

Errors

No response

What version of the package are you using?

No response

@sykim4 sykim4 added bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Nov 13, 2024
luwes pushed a commit that referenced this issue Nov 20, 2024
fixes #1011

Co-authored-by: Stephanie Kim <stephanie.kim@glassdoor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant