Error: "expected token ..." when trying to use the notion client npm package inside a figma plugin

I want to use the notion client sdk inside a Figma plugin. It’s just used to call the Notion api, nothing particularly fancy about it. I get an error when I try to use it.

When I do this in some file:

import { Client, LogLevel } from "@notionhq/client";
export const notion = new Client({"<my credentials>"});

And then import the client in another file

import { notion } from "./someFile";

I get the following error:

Syntax error on line 372: Unexpected token ...

I probably have ran into this issue before in my life but don’t remember what it was. Probably some incompatibility issue. How do you generally debug these things? I have limited information on where to even look.

Thanks in advance if you have any ideas.

You put … in place of the most important word. Which token? :smiley:

Could be an issue with bundling. What compiler/bundler are you using and what’s the config? Make sure you are inlining everything into a single .js file.

I think it’s literallry “…” if I understand correctly ;).

Syntax error on line 372: Unexpected token ...

But i use the spread operator in my code and it is not an issue.

Thanks for helping!

Ah, sorry, I didn’t realize it’s a spread operator. In this case it’s likely something before ... that causes an issue. Maybe an open bracket that expects something different after. You can try to experiment with build targets in your compiler, e.g. try something like es2016 or earlier.