spatie / server-side-rendering

Server side rendering JavaScript in a PHP application
https://sebastiandedeyne.com/posts/2018/server-side-rendering-javascript-from-php
MIT License
602 stars 34 forks source link

V8js "No module loader" and return Array #46

Closed Ask1n closed 3 years ago

Ask1n commented 3 years ago

Hi,

V8js return V8Js::compileString():615: No module loader, i am change file https://github.com/spatie/server-side-rendering/blob/a16b78e40d6afb8a7df1b0a778940344d0bfd78c/src/Engines/V8.php#L15

// V8.php 

public function __construct(V8Js $v8)
{
      $this->v8 = $v8;

      $this->v8->setModuleLoader(function ($module) {
          switch ($module) {
              case '@vue/compiler-core':
                  return File::get(base_path('node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js'));

              case '@vue/runtime-core':
                  return File::get(base_path('node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js'));

              case '@vue/reactivity':
                  return File::get(base_path('node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js'));

              case '@vue/compiler-ssr':
                  return File::get(base_path('node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js'));

              case '@vue/shared':
                  return File::get(base_path('node_modules/@vue/shared/dist/shared.cjs.prod.js'));

              case '@vue/compiler-dom':
                  return File::get(base_path('node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js'));

              case '@vue/runtime-dom':
                  return File::get(base_path('node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js'));

              case 'vue':
                  return File::get(base_path('node_modules/vue/dist/vue.cjs.prod.js'));

              case 'vue-router':
                  return File::get(base_path('node_modules/vue-router/dist/vue-router.cjs.prod.js'));

              case '@vue/server-renderer':
                  return File::get(base_path('node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js'));

          }
      });
}

now ssr()->render() return array

ErrorException
Array to string conversion

i am change to ssr()->render()[0] it work, but is ok?

Why is this happening, is this the expected result?

spatie-bot commented 3 years ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.