prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
287 stars 53 forks source link

Automatic upgrade is failing #942

Closed madiyetov closed 1 year ago

madiyetov commented 1 year ago

Versions

Reproduction

I've upgraded the slice-machine version to 1.0.1 from 0.7.1. When running the slice machine for the first time I get a casting error (ArrowFunctionExpression). It's because my nuxt.config.js file has function declaration like this: export default async () => ({}) I've changed the arrow function to this: export default async function() {return {}} But it throws Casting "FunctionDeclaration" is not supported error.

Error log
``` /node_modules/.pnpm/@slicemachine+manager@0.2.0_monocle-ts@2.3.13_newtype-ts@0.3.5_puppeteer@19.11.1/node_modules/@slicemachine/manager/dist/managers/project/ProjectManager.cjs:142 throw new errors.SliceMachineError(`Failed to initialize project: ${errors$1.join(", ")}`); ^ SliceMachineError: Failed to initialize project: Error: Error in `@slicemachine/adapter-nuxt2` during `project:init` hook: Casting "ArrowFunctionExpression" is not supported at ProjectManager.initProject (/node_modules/.pnpm/@slicemachine+manager@0.2.0_monocle-ts@2.3.13_newtype-ts@0.3.5_puppeteer@19.11.1/node_modules/@slicemachine/manager/dist/managers/project/ProjectManager.cjs:142:13) at async Module.migrateSMJSON (/node_modules/.pnpm/start-slicemachine@0.7.1_monocle-ts@2.3.13_newtype-ts@0.3.5_puppeteer@19.11.1/node_modules/start-slicemachine/dist/legacyMigrations/migrateSMJSON.cjs:109:5) at async StartSliceMachineProcess.run (/node_modules/.pnpm/start-slicemachine@0.7.1_monocle-ts@2.3.13_newtype-ts@0.3.5_puppeteer@19.11.1/node_modules/start-slicemachine/dist/StartSliceMachineProcess.cjs:49:5) { _sliceMachineError: true } ``` Node.js v18.12.1

Steps to reproduce

Create a Nuxt project with nuxt.config.js has an arrow function declaration and with Slice Machine v0.7.1. And upgrade it to v1.0.1.

What is expected?

Change the codebase to use the new slice machine version

What is actually happening?

It is failing

hypervillain commented 1 year ago

Thanks, were on it!

MarcMcIntosh commented 1 year ago

Hi @madiyetov I've managed to recreate this issue in outnuxt-starter-prismic-multi-page :)

Here are the conditions required to recreate the issue.

Changing any one of those should fix the issue, I'll investigate further to come up with a long term solution :)

MarcMcIntosh commented 1 year ago

You might need to manually configure the project add this to the nuxt.conf.js file

{
  buildModules: ["@nuxtjs/prismic"],
  prismic: {
    endpoint: "https://<your-repo>.cdn.prismic.io/api/v2",
    modern: true
  },
  build: {
    transpile: ["@prismicio/vue"]
  }
 }
mdeclercq commented 1 year ago

Hi @madiyetov,

Are you still encountering the issue? This was resolved in the version 1.0.3.

Thanks,

mdeclercq commented 1 year ago

Hi,

I'm closing the issue, let us know in case it re-occurs.

Thanks,