relay icon indicating copy to clipboard operation
relay copied to clipboard

[relay-compiler] This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'

Open Rick83600 opened this issue 8 years ago • 6 comments

Hello, :)

I'm in trouble to solve this issue.

I use :

  • "react-relay": "1.5.0"
  • "relay-compiler": "1.5.0",
  • "relay-runtime": "1.5.0",
  • "relay-local-schema": "^0.7.0",
⇒  ./node_modules/.bin/relay-compiler --verbose --src ./src/relay --schema ./resources/graphql/schema.json --extensions js --extensions jsx
HINT: pass --watch to keep watching for changes.
ERROR:
Parse error: SyntaxError: This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7) in "index.js"
From: CodegenRunner.compileAll
    at /home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:2503:18
    at /home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:2505:9
    at Set.forEach (<anonymous>)
    at ASTCache.parseFiles (/home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:2493:12)
    at /home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:5144:15
    at Object.run (/home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:481:31)
    at CodegenRunner.parseFileChanges (/home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:5141:36)
    at CodegenRunner.<anonymous> (/home/tristan/Documents/github/ui/node_modules/relay-compiler/bin/relay-compiler:5128:13)
    at Generator.next (<anonymous>)
    at step (/home/tristan/Documents/github/ui/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)

best regards

Rick83600 avatar Sep 21 '18 10:09 Rick83600

can you try latest version https://github.com/facebook/relay/releases/tag/v1.7.0-rc.1?

sibelius avatar Sep 21 '18 11:09 sibelius

issue resolved :) thanks you

Rick83600 avatar Sep 21 '18 20:09 Rick83600

I just started using Relay and running into this issue with latest version of everything related.

export default from './Category'
export CategoryConnector from './CategoryConnector'

This is what the code that triggers SyntaxError looks like. And babel.config.js looks like this:

module.exports = {
  presets: ['next/babel'],
  plugins: [
    [
      'babel-plugin-module-resolver',
      {
        root: ['./src'],
      },
    ],
    '@babel/plugin-proposal-export-default-from',
    'relay',
  ],
}

Changing order of plugins has no effect.

CrocoDillon avatar Oct 05 '19 22:10 CrocoDillon

After digging some more into it I now realize that this works:

export default from './SomeThing'

But this doesn't:

export SomeThing from './SomeThing'

Which re-exports the default export as a named export. You might want to look into this; I personally use these kind of exports rarely and just excluded the folder where I'm using it as it doesn't contain anything for Relay anyway.

CrocoDillon avatar Oct 07 '19 18:10 CrocoDillon

not sure if this is a valid syntax

try this

export { default as SomeThing } from './SomeThing'

sibelius avatar Oct 07 '19 18:10 sibelius

Ah I see, it seems to be an additional proposal to the proposal 😅 https://github.com/tc39/proposal-export-default-from

I might try your way, it will probably work. For now I'm fine with excluding the folder.

CrocoDillon avatar Oct 08 '19 19:10 CrocoDillon