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

Attempted import error: 'hls.js' does not contain a default export #57964

Closed
1 task done
laugharn opened this issue Nov 2, 2023 · 28 comments · Fixed by #58967
Closed
1 task done

Attempted import error: 'hls.js' does not contain a default export #57964

laugharn opened this issue Nov 2, 2023 · 28 comments · Fixed by #58967
Labels
bug Issue was opened via the bug report template. locked Module Resolution Module resolution (CJS / ESM, module resolving).

Comments

@laugharn
Copy link
Contributor

laugharn commented Nov 2, 2023

Link to the code that reproduces this issue

https://github.com/laugharn/next-mux-repro

To Reproduce

  1. Start the application in development (pnpm run dev)
  2. Go to http://localhost:3000
  3. See the import in in app/page.jsx causes the compile error

Current vs. Expected behavior

The export from hls.js should be detected correctly. I'm using the @muxinc library for demo purposes because that's how this emerged in our project, but importing hls.js directly has the same effect.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6020
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: N/A
  pnpm: 8.10.0
Relevant Packages:
  next: 14.0.2-canary.9
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router

Additional context

This looks like it was introduced in 14.0.2-canary.1 and my assumption is #57784 specifically.

@laugharn laugharn added the bug Issue was opened via the bug report template. label Nov 2, 2023
@EliHood
Copy link

EliHood commented Nov 3, 2023

@laugharn wouldn't it make sense for muxinc library to be compatible with next 14, not the other way around ? also don't think this is a next js specific issue... but i could be wrong.

@laugharn
Copy link
Contributor Author

laugharn commented Nov 3, 2023

It is compatible with Next 14 up to 14.0.2-canary.0 and then the bundling behavior changes. It stands to reason that other packages besides hls.js (the actual problem dependency) are breaking. If the end result is these packages should change their build process fair enough but the outcome here is the result of a change in Next.

@EliHood
Copy link

EliHood commented Nov 3, 2023

I reproduced your issue successfully.... hmm will poke around with this...

Update: This issue exists for next 14 as well, not just canary.

{
  "dependencies": {
    "@mux/mux-video-react": "0.8.0",
    "next": "14.0.0",
    "react": "^18.2.0",
    "react-dom": "latest"
  },
  "scripts": {
    "build": "next build",
    "dev": "next",
    "start": "next start"
  }
}

Failed to compile
./node_modules/@mux/playback-core/dist/index.mjs
Attempted import error: 'hls.js' does not contain a default export (imported as 'ue').
This error occurred during the build process and can only be dismissed by fixing the error.

I downgraded to mux-video-react 0.7.0, and the error is not happening (i see hello world now),

{
  "dependencies": {
    "@mux/mux-video-react": "0.7.0",
    "next": "14.0.2-canary.1",
    "react": "^18.2.0",
    "react-dom": "latest"
  },
  "scripts": {
    "build": "next build",
    "dev": "next",
    "start": "next start"
  }
}

Just not convinced if this is a next js issue, it seems like a mux-video-react issue. But maybe im missing something.

@sharpsteelsoftware

This comment has been minimized.

@skworden
Copy link

I forgot to add "use client"; and it caused the same error.

@GabrielDucharme

This comment has been minimized.

@luwes
Copy link

luwes commented Nov 13, 2023

thanks @laugharn!

#57784 seems to be causing Next.js builds to fail with some packages

hls.js does have a default export as you can see here
https://cdn.jsdelivr.net/npm/hls.js@1.4.12/dist/hls.mjs

@LiamWinterton
Copy link

Also experiencing this issue

@md97212

This comment has been minimized.

@Vintotan
Copy link

Vintotan commented Nov 14, 2023

I also experience this issue when using next.js version 14.0.2. Downgrading to next.js version 13.5.6 fixed this issue for me.

@GabrielDucharme
Copy link

GabrielDucharme commented Nov 14, 2023 via email

@hyperapps
Copy link

OK... I had this same problem. I systematically backed down mux player version by version... the last stable release of mux player that does not have this error is 1.11.3 (1.11.4 is where the break starts). This is true of all version of nextjs (13 and 14 work fine with 1.11.3 or earlier). For now, I backed down to 1.11.3 until this gets fixed.

@timomedia
Copy link

Same bug with nextjs 14.0.3

@EliHood
Copy link

EliHood commented Nov 17, 2023

So is it agreed that this is a mux video issue, not a next js issue ? or were not sure yet ?

@timomedia
Copy link

So is it agreed that this is a mux video issue, not a next js issue ? or were not sure yet ?

It's not a mux problem, I use another player rather than mux and it has the same error. Version 14.0.1 does not have this error

@baltie
Copy link

baltie commented Nov 17, 2023

Same problem with @arcgis/core library. Works fine in v14.0.1, but not since v14.0.2. Same error regarding missing a default export, but the default export is there.

@lukasIO
Copy link

lukasIO commented Nov 17, 2023

pretty sure that this is the same issue as I raised in #58592 and is also outlined in #57962.
Details in are in the issue.
I checked the dist of hls.js and it has that same pattern of a scoped module.exports that seems to cause this, starting with 14.0.2

@vatoer
Copy link

vatoer commented Nov 19, 2023

downgrading to 14.01 worked form

@mitchuman
Copy link

issue still persists on 14.0.3. Downgrading to 14.0.1 worked

@maxhelsel
Copy link

stepped down to version 14.0.1 and the error is gone, mux player works fine now.

@EliHood The issue is Next.js, and the version to blame is 14.0.2; this problem will prevent many people from keeping up with current versions and bugfixes - this issue has been open for weeks, it's been reproduced, it's affecting multiple libraries, and it would be really great if this could be given some level of priority

@EliHood
Copy link

EliHood commented Nov 21, 2023

Thanks for all of these findings guys, will try to investigate / debug this issue further.

@lukasIO
Copy link

lukasIO commented Nov 22, 2023

Someone opened a PR already with a potential fix #58572

@EliHood
Copy link

EliHood commented Nov 23, 2023

Yeah Lukas, we can wait for that to get merged, i think that might resolve it. Thanks for sharing that.

@mfwgenerics
Copy link

Also seeing this with @arcgis/core. Presents as:

./node_modules/@arcgis/core/widgets/support/widgetUtils.js
Attempted import error: '@esri/arcgis-html-sanitizer' does not contain a default export 

Boy did this ruin my afternoon! Downgrading to 14.0.1 has fixed it.

@muhaimincs
Copy link
Contributor

Also seeing this with @arcgis/core. Presents as:

./node_modules/@arcgis/core/widgets/support/widgetUtils.js
Attempted import error: '@esri/arcgis-html-sanitizer' does not contain a default export 

Boy did this ruin my afternoon! Downgrading to 14.0.1 has fixed it.

How do you solve this? Downgrade to 14.0.1?

@jamesvclements
Copy link

@muhaimincs should be fixed in next@v14.0.4-canary.33

@ode96-dev
Copy link

@jamesvclements upgrading to next@v14.0.4 solved the issue. Thanks

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 22, 2023
@huozhi huozhi added the Module Resolution Module resolution (CJS / ESM, module resolving). label Jan 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Module Resolution Module resolution (CJS / ESM, module resolving).
Projects
None yet
Development

Successfully merging a pull request may close this issue.