From 2c785753a952b7e684e7b409e0a8b1f633620ba3 Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Wed, 13 Apr 2022 14:02:46 +1000 Subject: [PATCH] add jotai/babel/plugin-debug-label on dev server --- craco.config.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/craco.config.js b/craco.config.js index 46000fac..77d529ea 100644 --- a/craco.config.js +++ b/craco.config.js @@ -1,3 +1,4 @@ +const { whenProd } = require("@craco/craco"); const CracoAlias = require("craco-alias"); const CracoSwcPlugin = require("craco-swc"); @@ -11,20 +12,30 @@ module.exports = { tsConfigPath: "./tsconfig.extend.json", }, }, - { - plugin: CracoSwcPlugin, - options: { - swcLoaderOptions: { - jsc: { - target: "es2019", - transform: { - react: { - runtime: "automatic", + // Use swc on production only since Jotai doesn’t have swc plugins yet + // See https://github.com/pmndrs/jotai/discussions/1057 + ...whenProd( + () => [ + { + plugin: CracoSwcPlugin, + options: { + swcLoaderOptions: { + jsc: { + target: "es2021", + transform: { + react: { + runtime: "automatic", + }, + }, }, }, }, }, - }, - }, + ], + [] + ), ], + babel: { + plugins: ["jotai/babel/plugin-debug-label"], + }, };