Skip to content

Issues when rendering strings (TypeError: Cannot read property 'appendChild$' of undefined) #1

@aalemayhu

Description

@aalemayhu

Using this repository running the below script to produce HTML for the use-case where you would want to produce a static file for deployment. Reproducer and error message below. I was expecting it to print out a long line of HTML, which does work if <App> is removed.

# build_html.imba
import {App} from './app'

let html = <html>
	<head>
		<title> "Application"
	<body>
		<script type='module' src='./app'>
		<App>

console.log(String(html))

Error Output

(base) ➜  ssr-app-imba git:(main) ✗ npx imba --version
2.0.0-alpha.133
(base) ➜  ssr-app-imba git:(main) ✗ npx imba src/build_html.imba
cache dir does not exist - create /Users/scanf/src/github.com/alemayhu/ssr-app-imba/node_modules/imba/.imba-cache
TypeError: Cannot read property 'appendChild$' of undefined
    at App.insertInto$ (/Users/scanf/src/github.com/alemayhu/ssr-app-imba/src/build_html.imba:1204:12)
        -> /Users/scanf/src/github.com/alemayhu/ssr-app-imba/node_modules/imba/src/imba/dom/core.imba:311:10
    at Object.<anonymous> (/Users/scanf/src/github.com/alemayhu/ssr-app-imba/src/build_html.imba:3396:498)
        -> /Users/scanf/src/github.com/alemayhu/ssr-app-imba/src/build_html.imba:8:4
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.import_module.Module._extensions.<computed> (/Users/scanf/src/github.com/alemayhu/ssr-app-imba/node_modules/imba/loader.imba.js:316:16)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:763:16)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

Commenting out

<!-- (base) ➜  ssr-app-imba git:(main) ✗ npx imba src/build_html.imba -->
<!DOCTYPE html><html class="a-b"><head class="a-c"><title class="a-d">Application</title>
<link rel='stylesheet' href='/__assets__/src/app.Z14AEOKZ.css'>
</head><body class="a-e"><script class="a-f" type="module" src="/__assets__/src/app.OS5SUIKO.js"></script></body></html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions