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: TypeError: Cannot read properties of undefined (reading 'createHTMLDocument') when using renderToString in NextJS #5978

Open
3 tasks done
vivere-dally opened this issue Sep 6, 2024 · 1 comment
Labels
Awaiting Reply This PR or Issue needs a reply from the original reporter.

Comments

@vivere-dally
Copy link

Prerequisites

Stencil Version

4.21.0

Current Behavior

Followed the hydrate docs and added a new output target:

  {
    type: 'dist-hydrate-script',
  },

Running build produces and output.

import { renderToString } from 'mypkg';

export default async function handler(req, res) {
  const resp = await renderToString('<mycomponent></mycomponent>', {
    fullDocument: false,
  });
  res.status(200).send(resp);
}

causes

error - TypeError: Cannot read properties of undefined (reading 'createHTMLDocument')
at .../node_modules/mypkg/index.js:12292:37
at .../node_modules/mypkg/index.js:12295:4
at .../node_modules/mypkg/index.js:2226:4
at .../node_modules/mypkg/index.js:2236:4
at hydrateAppClosure (.../node_modules/mypkg/index.js:12857:2)
at hydrateFactory (.../node_modules/mypkg/index.js:23821:3)
at .../node_modules/mypkg/index.js:39166:37

Expected Behavior

work

System Info

System: node 20.12.2
    Platform: darwin (23.6.0)
   CPU Model: Apple M3 Pro (12 cpus)
    Compiler: .../node_modules/@stencil/core/compiler/stencil.js
       Build: 1724698030
     Stencil: 4.21.0 🐷
  TypeScript: 5.5.3
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

Just add the hydrate output to an existing working stencil components project

Code Reproduction URL

no

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Sep 6, 2024
@tanner-reits
Copy link
Member

@vivere-dally I checked things out in a prerender app I have and didn't experience any errors. If you have a reproduction case that's failing I can take a look at that, but won't be able to offer help otherwise.

@tanner-reits tanner-reits added Awaiting Reply This PR or Issue needs a reply from the original reporter. and removed triage labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Reply This PR or Issue needs a reply from the original reporter.
Projects
None yet
Development

No branches or pull requests

2 participants