Skip to main content
Question

Which is the best structure for spliting code?

  • December 6, 2022
  • 3 replies
  • 602 views

fuwhis

I’m on process to build a Figma plugin. But the problem that I could not import or export functions, constants variable from outside of file code.ts (this is root file of resource).

How can we split or separate a file to be a reusable methods, constants for ease-to-maintain?

In case, Figma required only one built-in file, should I use webpack to bundle to a single file? If yes, what kind of the best webpack that useful for solution? Thanks.

3 replies

steventraaan
  • New Participant
  • 8 replies
  • February 23, 2023

Perhaps bundling with webpack can help you achieve the code splitting you’re looking for. Figma provides some good boilerplate that should get you started.


Francesco_Bianchi1

I like webpack, but I think the boilerplate with esbuild and Vite provided by Figma is better (they provided a better typescript structure with separation between the sandbox and iFrame).


steventraaan
  • New Participant
  • 8 replies
  • March 7, 2023

Interesting! I didn’t realize this was an option Figma provides. Will take a look into it, thanks!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings