stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: Stencil Library doesnt work with Next Js Pages routing

Open brunnohofmann opened this issue 3 years ago • 1 comments

Prerequisites

Stencil Version

4.0.0

Current Behavior

Im integrating a Stencil library with a NextJs application.

Altough it seems to work fine with the new App Routing, when using the Pages route structure, the component cannot be shown receiving the following error:

TypeError: Cannot read properties of undefined (reading '$instanceValues$')

One interesting thing is that if I remove all the props, the component works.

Expected Behavior

Stencils libraries should work on App routing and Pages routing

System Info

System: node 16.17.0
    Platform: darwin (22.6.0)
   CPU Model: Apple M1 Pro (10 cpus)
    Compiler: /Users/brunnohofmann/stencilbug/stencil-library/node_modules/@stencil/core/compiler/stencil.js
       Build: 1695049867
     Stencil: 4.3.0 🐫
  TypeScript: 5.1.6
      Rollup: 2.42.3
      Parse5: 7.1.2
      Sizzle: 2.42.3
      Terser: 5.19.4

Steps to Reproduce

I create this repository with a empty stencil library and a next js application. https://github.com/brunnohofmann/stencil_next_js_bug

  • Clone the repo

  • Follow read-me

  • Open the next-js running application.

  • Go to / url - Stencil component should work

  • Go to /test - Stencil component it not visible

  • Try removing all the props from stencil component

  • Build, Install and Run again

  • Stencil component is working on any url

Code Reproduction URL

https://github.com/brunnohofmann/stencil_next_js_bug

Additional Information

No response

brunnohofmann avatar Sep 20 '23 10:09 brunnohofmann

Enabling import inject fixed the problem.

stencil.config.ts extras: { enableImportInjection: true }

brunnohofmann avatar Oct 06 '23 07:10 brunnohofmann