zodern/meteor-relay

Error: Method name is missing. Do you have the relay babel plugin configured?

Sergeant61 opened this issue · 5 comments

Hello, I would like to talk about a problem I had recently. I will give two examples below. In the first one, I am getting the error mentioned. I am opening this task to inform those who have experienced this situation. We cant do "Export apart from declarations" When, I put export separately i got this error: Method name is missing. Do you have the relay babel plugin configured?

const methodAppStoresList = createMethod({
  schema: z.object({
    slug: z.string(),
  }),
  async run({ }) {

    return ''
  },
})

export { methodAppStoresList }

Working without error:

export const methodAppStoresList = createMethod({
  schema: z.object({
    slug: z.string(),
  }),
  async run({ }) {

    return ''
  },
})

The babel plugin can only detect that you're exporting the result of createMethod if you use the second syntax.

This probably should be documented better. It is possible to improve the babel plugin to detect the first syntax, but I'm not sure if it is worth the complexity.

Hello, I have previously mentioned the problem related to this code. I'm using meteor-relay inside a meteor package and created my .babelrc file to be the outermost one in the package directory.

Npm.depends({
   '@zodern/babel-plugin-meteor-relay': '1.1.2',
})

It works correctly with this package on my Mac m1 machine. However, I am getting the error I mentioned above on my Win 11 machine. I tried to create .babelrc in the home directory but it didn't work. Thanks for the help.

zodern commented

@Sergeant61 could you please create a reproduction I can look at?

@zodern I realized my mistake while preparing a sample project for you, but it's still a mystery why you run it like this on mac. My mistake is not giving name when using pipeline. It says in the error message, but the fact that the error does not occur on mac misled me. I thought it was from Babel. If you still want to test it, here is the sample project link: https://github.com/Sergeant61/simple-meteor-relay-test