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

SyntaxError: Named export 'resolvePageComponent' not found #99

Closed
HuyPham55 opened this issue Jul 21, 2022 · 1 comment
Closed

SyntaxError: Named export 'resolvePageComponent' not found #99

HuyPham55 opened this issue Jul 21, 2022 · 1 comment

Comments

@HuyPham55
Copy link

HuyPham55 commented Jul 21, 2022

  • Laravel Vite Plugin Version: "0.5.0"
  • Laravel Version: ^9.19
  • Node Version: v16.13.1
  • NPM Version: 8.10.0
  • Host operating system: Windows 10
  • Web Browser & Version: Chrome
  • Running in Sail / Docker: None

Description:

After npm run build, running node bootstrap/ssr/ssr.mjs causes the following error. More detail below:

file:///<path_to_project_root>/bootstrap/ssr/ssr.mjs:6
import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers/index.js";
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'resolvePageComponent' not found. The requested module 'laravel-vite-plugin/inertia-helpers/index.js' is a CommonJS module, which may not
support all module.exports as named exports.

Related documents:

  1. https://laravel.com/docs/9.x/vite#ssr
  2. https://laravel.com/docs/9.x/starter-kits#server-side-rendering

Steps To Reproduce:

Every command and description is described in 2 official URLs above

  1. Install fresh new Laravel project
  2. Install dependencies composer install
  3. Install Laravel Breeze
  4. Run php artisan breeze:install vue --ssr to scaffold authentication with SSR
  5. npm install
  6. npm run build
  7. node bootstrap/ssr/ssr.mjs

Attempt to fix:

I went to <project_root>\node_modules\laravel-vite-plugin\inertia-helpers\index.js and change from

export async function resolvePageComponent(path, pages) {
const page = pages[path];
if (typeof page === 'undefined') {
throw new Error(Page not found: ${path});
}
return typeof page === 'function' ? page() : page;
}

to

exports.resolvePageComponent = function(path, pages) {
const page = pages[path];
if (typeof page === 'undefined') {
throw new Error(Page not found: ${path});
}
return typeof page === 'function' ? page() : page;
}

And run step 6-7 again, it works like a charm. There must be syntax problem, or am I missing a step in the process?

If it's a bug, please fix it soon.

@timacdonald
Copy link
Member

Duplicate of #93

This issue will be fixed in the next release. Please see #93 (comment) for a interim solution.

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