SyntaxError: possible import expression rejected around line {N}
Hello, Figam Developers.
I am developer of figma codegen (plugin). Thank you for developing this wonderful thing. 🥇
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 :)
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 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?
I've had to fix by post-processing the js after it's built. Silly bug.
I'm doing that too. 😞
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.