Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token 'export': ´export * from './lib/module/svgChart'´ when using Next.js & Expo in monorepo #127

Closed
daniel-heg opened this issue Oct 12, 2023 · 5 comments

Comments

@daniel-heg
Copy link

Hi,
first of all, thank you for this lib!

I am using the expo & next.js starter from tamagui (source here).
And I ran into the following issue when using the SvgChart while running on "web" (Expo / React Native does work):

export * from './lib/module/svgChart';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1178:20)
    at Module._compile (node:internal/modules/cjs/loader:1220:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)

I am importing like this (so there is no problem with Skia):

import SvgChart, { SVGRenderer } from '@wuba/react-native-echarts/svgChart'

Also, I have tried to add the Webpack extensions to next.conf.js like explained here, but that did not work,

I also tried adding @wuba/react-native-echarts/svgChart to the transpilePackages Array, but that did not work either.

What am I doing wrong?

Thank you

@zhiqingchen
Copy link
Member

#95

@daniel-heg
Copy link
Author

Yes, I found that issue and tried everything from that thread.

But I am on '1.2.5' and it somehow does not work.

@zhiqingchen
Copy link
Member

Can you provide a complete demo repository

@daniel-heg
Copy link
Author

Thank you, but that won't be necessary. I finally found the solution!

In next.js I had to put the whole package name into the transpilePackages array, not just the .../svgChart.
So if anyone else has the same Problem, my next.config.js looks like this to make the package work:

...
    transpilePackages: [
      ...,
      'echarts',
      'zrender',
      '@wuba/react-native-echarts'
    ],
...

@zhiqingchen
Copy link
Member

Thanks for providing this information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants