ontola / home

Ontola web page
https://ontola.io
3 stars 1 forks source link

AWS amplify no longer building #45

Closed joepio closed 1 year ago

joepio commented 1 year ago

I ran a migration on AWS, and since then the builds are failing. We can revert this

# if things go sideways, reset the migration
aws amplify update-app --region eu-west-2 --app-id d2f2o1bodsi4fu --platform  WEB_DYNAMIC

But I think we should try making it work with the new architecture on amplify.

joepio commented 1 year ago

Worked!

joepio commented 1 year ago

For some reason it broke again?

joepio commented 1 year ago

Not sure whats going on

joepio commented 1 year ago
2022-12-27T09:17:21.437Z [WARNING]: file:///codebuild/output/src479924625/src/home/node_modules/.pnpm/next-mdx-remote@4.2.0_biqbaboplfbrettd7655fr4n2y/node_modules/vfile-matter/index.js:11
                                    import {load} from 'js-yaml'
                                    ^^^^
                                    SyntaxError: Named export 'load' not found. The requested module 'js-yaml' is a CommonJS module, which may not support all module.exports as named exports.
                                    CommonJS modules can always be imported via the default export, for example using:
                                    import pkg from 'js-yaml';
                                    const {load} = pkg;
                                    at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
                                    at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
                                    at async Promise.all (index 0)
                                    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
                                    at async importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
2022-12-27T09:17:21.440Z [WARNING]: 
2022-12-27T09:17:21.440Z [WARNING]: > Build error occurred
2022-12-27T09:17:21.443Z [WARNING]: Error: Failed to collect page data for /blog
                                    at /codebuild/output/src479924625/src/home/node_modules/.pnpm/next@12.3.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/build/utils.js:916:15 {
                                    type: 'Error'
                                    }
2022-12-27T09:17:21.468Z [INFO]: ELIFECYCLE  Command failed with exit code 1.
2022-12-27T09:17:21.492Z [ERROR]: !!! Build failed
2022-12-27T09:17:21.493Z [INFO]: Please check the supported SSR features to find if your build failure is related to an unsupported feature: https://docs.aws.amazon.com/amplify/latest/userguide/ssr-Amplify-support.html#supported-unsupported-features. You may also find this troubleshooting guide useful: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html
2022-12-27T09:17:21.493Z [ERROR]: !!! Non-Zero Exit Code detected

We use gray-matter for markdown parsing, and that uses js-yaml, that seems like it isn't imported correctly due to some commonJS import issue. I know I've made some changes lately to NodeJS vs CommonJS module import in this project (because of errors during build), but I may have inadvertently created a new issue.

joepio commented 1 year ago

I think setting "type": "module" might help fix this issue, but I can't set it without failing the build.

next-i18next requires us to use CommonJS modules for its config file, so I can't use ESmodules in next.config.js.

I can rename next.config.js to next.config.cjs to allow commonJS modules, but if I do that, the locales aren't imported correctly if I run pnpm build:

rror: Invalid locale returned from getStaticPaths for /services/[pid], the locale en is not specified in next.config.js
    at /Users/joep/dev/github/ontola/home/node_modules/.pnpm/next@12.3.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/build/utils.js:661:23
    at Array.forEach (<anonymous>)
    at buildStaticPaths (/Users/joep/dev/github/ontola/home/node_modules/.pnpm/next@12.3.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/build/utils.js:615:17)
    at async /Users/joep/dev/github/ontola/home/node_modules/.pnpm/next@12.3.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/build/utils.js:886:115
    at async Span.traceAsyncFn (/Users/joep/dev/github/ontola/home/node_modules/.pnpm/next@12.3.4_biqbaboplfbrettd7655fr4n2y/node_modules/next/dist/trace/trace.js:79:20)

> Build error occurred
joepio commented 1 year ago

Vercel works just fine, though. So AWS Amplify has a weird bug in my specific configuration.

joepio commented 1 year ago

And netflify works, too! Since netlify has a free offering and Vercel costs 240 dollars a year, I'll stick with netlify for now.