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

Uncaught TypeError: out.global.___viteRenderAssets is not a function #7

Closed
Nicolab opened this issue Jul 31, 2021 · 2 comments
Closed

Comments

@Nicolab
Copy link

Nicolab commented Jul 31, 2021

Version: 1.3.2 & 2.0.0

I have tested with 1.3.2 and 2.0.0.

Details

Uncaught TypeError: out.global.___viteRenderAssets is not a function
    at _marko_template._._marko_renderer.t (app-layout.marko:19)
    at renderer (renderer.js:218)
    at proxyRenderer (hot-reload.js:73)
    at AppLayout.___rerender (Component.js:552)
    at hydrateComponentAndGetMount (index-browser.js:427)
    at tryHydrateComponent (index-browser.js:387)
    at index-browser.js:365
    at Array.map (<anonymous>)
    at Object.initServerRendered [as concat] (index-browser.js:361)
    at index-browser.js:293

app-layout.marko:19 is only a <head> tag

It's ok if I remove the js from the app-layout.marko. Also, If I don't provide data from res.marko() is ok.

Just for info, By searching in the final js I found t.global.___viteRenderAssets(t, "head-prepend").

Expected Behavior

Run without Uncaught TypeError: out.global.___viteRenderAssets is not a function error, because this error breaks the execution of the JS, it is currently unusable.

Actual Behavior

Built on the server side but does not execute in the browser because of this error

Possible Fix

Serialization may be the cause? (res.marko() and res.locals seems to be impacted)

Your Environment

Ubuntu 18.04
Node v14.15.4

I have updated the dependencies of the skeleton (but the bug is perhaps present on the original skeleton):

"dependencies": {
    "@marko/express": "^1.0.0",
    "express": "^4.17.1",
    "marko": "^5.15.1",
    "raptor-pubsub": "^1.0.5"
  },
  "devDependencies": {
    "@marko/compiler": "^5.15.0",
    "@marko/vite": "^2.0.0",
    "cross-env": "^7.0.3",
    "marked": "^2.1.3",
    "rimraf": "^3.0.2",
    "vite": "^2.4.4"
  },

Steps to Reproduce

Generate a vite express project with:

npx @marko/create

Replace app-layout/app-layout.marko content by this:

class {
  onCreate(input) {
    this.state = {
      pageTitle: input.pageTitle
    };
  }
}

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="description" content="An example application showcasing Vite & Marko.">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <${input.head}/>
  </head>
  <body>
    <sample-header title="Marko UI Components Playground"/>
    <div class="container">
      <main id="main">
        <h1>${state.pageTitle}</h1>
        <${input.body}/>
      </main>
    </div>
  </body>
</html>

And replace _./pages/index/index.js` content by this:

import template from "./template.marko";

export default (req, res) => {
  res.marko(template, {
    pageTitle: 'Welcome to my page',
  });
};

Then run:

npm run dev

or:

npm run build && npm run start

Stack Trace

Uncaught TypeError: out.global.___viteRenderAssets is not a function
    at _marko_template._._marko_renderer.t (app-layout.marko:19)
    at renderer (renderer.js:218)
    at proxyRenderer (hot-reload.js:73)
    at AppLayout.___rerender (Component.js:552)
    at hydrateComponentAndGetMount (index-browser.js:427)
    at tryHydrateComponent (index-browser.js:387)
    at index-browser.js:365
    at Array.map (<anonymous>)
    at Object.initServerRendered [as concat] (index-browser.js:361)
    at index-browser.js:293
@Nicolab
Copy link
Author

Nicolab commented Aug 1, 2021

I think it's not just adding arguments to res.marko() because when I remove them, I still have the bug. Even if I remove node_modules, package-lock.json and re-install all. Is there a cache somewhere else?

@Nicolab
Copy link
Author

Nicolab commented Aug 1, 2021

Resolved: marko-js/examples#15

@Nicolab Nicolab closed this as completed Aug 1, 2021
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

1 participant