plugin-typings icon indicating copy to clipboard operation
plugin-typings copied to clipboard

SyntaxError: possible import expression rejected around line {N}

Open eliot-liner opened this issue 1 year ago • 2 comments

Hello, Figam Developers.

I am developer of figma codegen (plugin). Thank you for developing this wonderful thing. 🥇

스크린샷 2024-10-09 오후 6 02 35

While looking for a place to report, I found a similar Pull Request and am posting the issue here. (ref. https://github.com/figma/plugin-typings/issues/36)

An error occurs if you include import( in the bundle file. I run prettier at runtime, but the service terminates unexpectedly due to an alert, so I cannot develop the plugin. Even if it is not a prettier, problems can occur in major libraries.

example bundle file

"use strict";
(() => {
  // src/index.ts
  figma.codegen.on("generate", () => {
    console.log("import(");
    return [];
  });
})();
//# sourceMappingURL=index.js.map

If you do not understand the situation, please ask a question. I would appreciate it if you could fix it :)

eliot-liner avatar Oct 09 '24 09:10 eliot-liner

Hi @eliot-liner, this is expected behavior.

For now, you can get around this limitation by using string concatenation:

"use strict";
(() => {
  // src/index.ts
  const IMPORT_STRING = "im" + "port";
  figma.codegen.on("generate", () => {
    console.log(`${IMPORT_STRING}(`);
    return [];
  });
})();

knguyen-figma avatar Oct 16 '24 17:10 knguyen-figma

@knguyen-figma thanks for answer.

If this were my code, I could change it as you suggested, but it's in the comments in the bundle file of the library I'm using.

The library I am using at runtime is called “prettier”.

And I don't know why this is expected behavior. Shouldn't imports in comments or console logs be excluded from errors?

eliot-liner avatar Oct 18 '24 09:10 eliot-liner

I've had to fix by post-processing the js after it's built. Silly bug.

darknoon avatar Nov 10 '24 23:11 darknoon

I'm doing that too. 😞

eliot-liner avatar Nov 11 '24 01:11 eliot-liner

Thanks for the bug report. We'll bediscussing solutions to this issue internally.

Closing this issue since this repo is for our type definitions package...please report future runtime issues via the support forum or by opening a ticket with support.

jefflee-figma avatar Nov 22 '24 22:11 jefflee-figma