yuanqing / create-figma-plugin

:battery: The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
https://yuanqing.github.io/create-figma-plugin/
MIT License
948 stars 91 forks source link

Make Preact Compat Plugin optional #212

Closed TheUltDev closed 10 months ago

TheUltDev commented 10 months ago

Hello. I love the project, but I've outgrown the UI Kit. I forked the kit and ported it to use React instead of Preact as well as other styling differences and functionality.

I would like to continue to use the build package, but it loads the Preact Compat plugin. Currently I am patching the library instead of forking but it would be nice if it was an option.

Here's the patch I'm using for those interested:

diff --git a/lib/utilities/build-bundles-async/build-bundles-async.js b/lib/utilities/build-bundles-async/build-bundles-async.js
index e44dbd50553277e2aeccf90a0cecb28acb1aea42..bb02a522c756d95484c2efb47e461a7660d5a03a 100644
--- a/lib/utilities/build-bundles-async/build-bundles-async.js
+++ b/lib/utilities/build-bundles-async/build-bundles-async.js
@@ -5,7 +5,6 @@ import { globby } from 'globby';
 import indentString from 'indent-string';
 import { importFresh } from '../import-fresh.js';
 import { esbuildCssModulesPlugin } from './esbuild-css-modules-plugin.js';
-import { esbuildPreactCompatPlugin } from './esbuild-preact-compat-plugin.js';
 export async function buildBundlesAsync(options) {
     const { config, minify, outputDirectory } = options;
     await Promise.all([
@@ -91,7 +90,7 @@ async function buildUiBundleAsync(options) {
             logLevel: 'silent',
             minify,
             outfile: resolve(outputDirectory, constants.build.pluginUiFilePath),
-            plugins: [esbuildPreactCompatPlugin(), esbuildCssModulesPlugin(minify)],
+            plugins: [esbuildCssModulesPlugin(minify)],
             stdin: {
                 contents: js,
                 resolveDir: process.cwd()
TheUltDev commented 10 months ago

(or allow overriding plugins, I could not find a way to do that)

jonathanhudak commented 10 months ago

Did you try this? https://yuanqing.github.io/create-figma-plugin/recipes/#disabling-automatic-swapping-of-react-imports

TheUltDev commented 10 months ago

Doh, yeah that works, must have configured it wrong.