Next.js Static Export Broke

78 views
Skip to first unread message

Dylan Bucicchia

unread,
Sep 2, 2024, 10:27:22 AM9/2/24
to Blockly
Hello, I'm working on a project that uses Blockly for easy block coding. I've been working on this for a while and it's almost done. However, today i tried to test the static export on Next.js so I can ensure that I will be able to deploy the site. The export went fine, but when I opened the html file, the site looked like this:
Screenshot 2024-09-02 at 08-22-42 .png

The site is supposed to look like this:
Screenshot 2024-09-02 at 08-22-30 .png

All of my code for this site is available here:

When you run "npm i && npm run dev" in the console, it should open localhost:3000 where the site will be viewable, but if you run "npm run build", the site will compile into the out directory, running the index.html file in that directory leads to the broken site.

Any help on this matter is appreciated as I am trying to get this site deployed in the next week.

Thanks!
- Dylan

Christopher Allen

unread,
Sep 2, 2024, 10:31:56 AM9/2/24
to blo...@googlegroups.com
Hi Dylan,

Hello, I'm working on a project that uses Blockly for easy block coding. I've been working on this for a while and it's almost done. However, today i tried to test the static export on Next.js so I can ensure that I will be able to deploy the site.

I don't think anyone on the Blockly team is that familiar with Next.js, and we don't unfortunately have time to debug every Blockly developer's project for them, but if you can provide us with a bit more information then we might be able to help or at least point you in the right direction.

The obvious place to start is the same as for almost any other web app debugging: do any error messages appear in the console, and if so what do they say?


Best wishes,

Christopher

Dylan Bucicchia

unread,
Sep 3, 2024, 5:26:10 AM9/3/24
to Blockly
Thanks for the quick response!
I totally forgot to look in the console (my bad)

At first it gives these warnings which seem to be related to Next.js:
Loading failed for the <script> with source “file:///_next/static/chunks/webpack-953556fdf238d252.js”. index.html:1:517
Loading failed for the <script> with source “file:///_next/static/chunks/framework-ecc4130bc7a58a64.js”. index.html:1:600
Loading failed for the <script> with source “file:///_next/static/chunks/main-678ea17784401d5f.js”. index.html:1:678
Loading failed for the <script> with source “file:///_next/static/chunks/pages/_app-ef0c2d814daa91a8.js”. index.html:1:762
Loading failed for the <script> with source “file:///_next/static/chunks/d711c980-35baa5180bb4620c.js”. index.html:1:844
Loading failed for the <script> with source “file:///_next/static/chunks/ee9ce975-31d5f14ab71fbd00.js”. index.html:1:926
Loading failed for the <script> with source “file:///_next/static/chunks/690-9ddff9650b0d4649.js”. index.html:1:1003
Loading failed for the <script> with source “file:///_next/static/chunks/pages/index-557f5c67a89af9cf.js”. index.html:1:1088
Loading failed for the <script> with source “file:///_next/static/FYPDXEWgvLmg0imH3xMTx/_buildManifest.js”. index.html:1:1174
Loading failed for the <script> with source “file:///_next/static/FYPDXEWgvLmg0imH3xMTx/_ssgManifest.js”. index.html:1:1258

But then it shows an error, which I think is the issue here:
SyntaxError: CustomElementRegistry.whenDefined: 'blockly' is not a valid custom element name index.js:6248

I went to go check the index.js file but oddly, there doesn't seem to be one? I'm kind of stuck here.Screenshot 2024-09-02 144252.png

Christopher Allen

unread,
Sep 3, 2024, 6:30:58 AM9/3/24
to blo...@googlegroups.com
Hi Dylan,

Thanks for the quick response!

You're most welcome.
 
At first it gives these warnings which seem to be related to Next.js:
Loading failed for the <script> with source “file:///_next/static/chunks/webpack-953556fdf238d252.js”. index.html:1:517
Loading failed for the <script> with source “file:///_next/static/chunks/framework-ecc4130bc7a58a64.js”. index.html:1:600
Loading failed for the <script> with source “file:///_next/static/chunks/main-678ea17784401d5f.js”. index.html:1:678
Loading failed for the <script> with source “file:///_next/static/chunks/pages/_app-ef0c2d814daa91a8.js”. index.html:1:762
Loading failed for the <script> with source “file:///_next/static/chunks/d711c980-35baa5180bb4620c.js”. index.html:1:844
Loading failed for the <script> with source “file:///_next/static/chunks/ee9ce975-31d5f14ab71fbd00.js”. index.html:1:926
Loading failed for the <script> with source “file:///_next/static/chunks/690-9ddff9650b0d4649.js”. index.html:1:1003
Loading failed for the <script> with source “file:///_next/static/chunks/pages/index-557f5c67a89af9cf.js”. index.html:1:1088
Loading failed for the <script> with source “file:///_next/static/FYPDXEWgvLmg0imH3xMTx/_buildManifest.js”. index.html:1:1174
Loading failed for the <script> with source “file:///_next/static/FYPDXEWgvLmg0imH3xMTx/_ssgManifest.js”. index.html:1:1258

But then it shows an error, which I think is the issue here:
SyntaxError: CustomElementRegistry.whenDefined: 'blockly' is not a valid custom element name index.js:6248

I went to go check the index.js file but oddly, there doesn't seem to be one? I'm kind of stuck here.

I know almost nothing about Next.js, but hopefully another forum contributor who is more familiar with it will chime in.  In the meantime, here are the things I'd investigate:

Best wishes,

Christopher

Dylan Bucicchia

unread,
Sep 3, 2024, 8:17:36 AM9/3/24
to Blockly
I looked through all your suggestions and couldn't figure it out, bit I went on GitHub pages and found out that there is a built in Next.js compiler. When i used that workflow and commited my files, everything deployed with no issue!

One more thing, could you check this out and let me know if it shows up well for you?
https://cloverbots-fll.github.io/

Other than that I really appreciate the help, thank you!
- Dylan

Christopher Allen

unread,
Sep 3, 2024, 8:18:26 AM9/3/24
to blo...@googlegroups.com
I looked through all your suggestions and couldn't figure it out, bit I went on GitHub pages and found out that there is a built in Next.js compiler. When i used that workflow and commited my files, everything deployed with no issue!

Great!
 
One more thing, could you check this out and let me know if it shows up well for you?

It does.  Looks good to me.


Reply all
Reply to author
Forward
0 new messages