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: NextJS 15 TypeError in Development for client or server side rendered components #6166

Open
3 tasks done
artursopelnik opened this issue Feb 19, 2025 · 4 comments
Open
3 tasks done
Assignees
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@artursopelnik
Copy link

Prerequisites

Stencil Version

4.26.0

Current Behavior

Hi Ionic/Stencil Team

I'm working on a design system using StencilJS and Next.js 15 with App Router.

When I run Next.js in development mode (npm run dev) and open the page in the browser—especially when opening it a second time—I see a TypeError logged in the console. What could be causing this? Both the client-side rendering and SSR itself seem to be working fine.

Any insights or potential fixes would be greatly appreciated! Thanks in advance.

Image
next dev

   ▲ Next.js 15.1.7
   - Local:        http://localhost:3000
   - Network:      http://192.168.178.42:3000

 ✓ Starting...
 ✓ Ready in 1743ms
 ○ Compiling / ...
 ✓ Compiled / in 888ms (608 modules)
 GET / 200 in 1228ms
 ○ Compiling /server ...
 ✓ Compiled /server in 598ms (711 modules)
 GET /server 200 in 732ms
 ⨯ TypeError: doc.querySelectorAll is not a function
    at eval (webpack-internal:/stencil-library/dist/components/src/components/my-component/my-component.tsx:9:24)
    at (ssr)/../stencil-library/dist/components/my-component.js (.next/server/app/server/page.js:236:1)
    at __webpack_require__ (.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(ssr)/../react-library-ssr/lib/components/stencil-generated/MyComponent.ts:5:111)
    at (ssr)/../react-library-ssr/lib/components/stencil-generated/MyComponent.ts (.next/server/app/server/page.js:214:1)
    at __webpack_require__ (.next/server/webpack-runtime.js:33:43)
    at eval (webpack-internal:///(ssr)/../react-library-ssr/lib/components/stencil-generated/components.ts:5:70)
    at (ssr)/../react-library-ssr/lib/components/stencil-generated/components.ts (.next/server/app/server/page.js:225:1)
    at Object.__webpack_require__ [as require] (.next/server/webpack-runtime.js:33:43)
   7 |   shadow: true,
   8 | })
>  9 | export class MyComponent {
     |                        ^
  10 |   /**
  11 |    * The first name
  12 |    */ {
  digest: '3493695745'

Expected Behavior

The pages loaded without an error.

System Info

System: node 22.13.1
    Platform: darwin (23.6.0)
   CPU Model: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 cpus)
    Compiler: /Users/artursopelnik/IdeaProjects/stenciljsnextjs15-ssr/node_modules/@stencil/core/compiler/stencil.js
       Build: 1739293045
     Stencil: 4.26.0 🐇
  TypeScript: 5.5.4
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

git clone https://github.com/artursopelnik/stenciljsnextjs15-ssr

1
Install all packages on root folder with `npm install``

2
Build projects in package with:

  • stencil-library => npm run build
  • react-library => npm run build
  • react-library-ssr => npm run build

3
Start NextJS
cd ./packages/nextjs15
npm run dev

Code Reproduction URL

https://github.com/artursopelnik/stenciljsnextjs15-ssr

Additional Information

Codesandbox:
https://codesandbox.io/p/github/artursopelnik/stenciljsnextjs15-ssr/main?import=true

@ionitron-bot ionitron-bot bot added the triage label Feb 19, 2025
@johnjenkins
Copy link
Contributor

Thanks for raising!
For whoever looks at this - It's caused by this line introduced in 4.26.0

@christian-bromann christian-bromann self-assigned this Feb 19, 2025
@christian-bromann christian-bromann added Bug: Validated This PR or Issue is verified to be a bug within Stencil and removed triage labels Feb 19, 2025
@christian-bromann
Copy link
Member

We got this reported internally, will take a look!

@artursopelnik
Copy link
Author

artursopelnik commented Feb 19, 2025

@johnjenkins
It works without TypeError in 4.25.3 💯

@danielleroux
Copy link
Contributor

danielleroux commented Feb 25, 2025

@artursopelnik Tested a possible fix #6174, but could no execute the steps from section Steps to Reproduce react-library and react-library-srr is no valid ts project to execute the build task

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants