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

ultrahtml crashes with bun runtime: undefined is not an object (evaluating 't.type') #66

Open
JulianCataldo opened this issue Jan 15, 2024 · 2 comments

Comments

@JulianCataldo
Copy link

JulianCataldo commented Jan 15, 2024

Hello!

Reproduction repository here:

https://github.com/JulianCataldo/satori-html-bun

Steps are in the README

Works fine with tsx otherwise

@JulianCataldo
Copy link
Author

JulianCataldo commented Jan 16, 2024

Narrowing to:

import { html, parse } from "ultrahtml";

import inlineCSS from "ultrahtml/transformers/inline";

const doc = parse(html`<div>Hello world</div>`);

// THIS
const inliner = inlineCSS({ useObjectSyntax: true });

// Without `{ useObjectSyntax: true }` is fine

inliner(doc);
79 | const lastChild = (node: Node, parent?: Node) => parent?.children.filter((n: Node) => n.type === ELEMENT_NODE).pop() === node;
80 | const firstChild = (node: Node, parent?: Node) => parent?.children.filter((n: Node) => n.type === ELEMENT_NODE).shift() === node;
81 | const onlyChild = (node: Node, parent?: Node) => parent?.children.filter((n: Node) => n.type === ELEMENT_NODE).length === 1;
82 | 
83 | const createMatch = (selector: AST): Matcher => {
84 |     switch (selector.type) {
                 ^
TypeError: undefined is not an object (evaluating 'selector.type')
      at createMatch (/……………/__forks/satori-html/ultrahtml/src/selector.ts:84:13)
      at /……………/__forks/satori-html/ultrahtml/src/selector.ts:96:67
      at /……………/__forks/satori-html/ultrahtml/src/selector.ts:34:17
      at /……………/__forks/satori-html/ultrahtml/src/selector.ts:50:13
      at visit (/……………/__forks/satori-html/ultrahtml/src/index.ts:304:5)
      at visit (/……………/__forks/satori-html/ultrahtml/src/index.ts:308:9)
      at select (/……………/__forks/satori-html/ultrahtml/src/selector.ts:48:5)
      at /……………/__forks/satori-html/ultrahtml/src/transformers/inline.ts:72:21
      at /……………/__forks/satori-html/ultrahtml/test.ts:12:1

Probably an issue with parsel. Still investigating

@natemoo-re
Copy link
Owner

My guess would be on parsel-js being resolved incorrectly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants