From 3d46e9fb7ddb8cd73f3297fc269771a350f9e19f Mon Sep 17 00:00:00 2001 From: Nicola Molinari Date: Sun, 4 Dec 2022 12:42:52 +0100 Subject: [PATCH] fix(mc-scripts): add babel plugin do-expressions to default vite config (#2903) * fix(mc-scripts): add babel plugin do-expressions to default vite config * fix: formatting --- .changeset/smooth-terms-share.md | 5 +++++ .prettierrc | 8 +++++++- packages/mc-scripts/src/commands/build-vite.ts | 5 ++++- packages/mc-scripts/src/commands/start-vite.ts | 5 ++++- playground/src/components/entry-point/entry-point.jsx | 4 ++-- 5 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 .changeset/smooth-terms-share.md diff --git a/.changeset/smooth-terms-share.md b/.changeset/smooth-terms-share.md new file mode 100644 index 0000000000..2f6943ccab --- /dev/null +++ b/.changeset/smooth-terms-share.md @@ -0,0 +1,5 @@ +--- +'@commercetools-frontend/mc-scripts': patch +--- + +Add `@babel/plugin-proposal-do-expressions` plugin to Vite config diff --git a/.prettierrc b/.prettierrc index be74bda79a..b0e0b243cc 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,8 +1,14 @@ { "trailingComma": "es5", "singleQuote": true, - "parser": "typescript", + "parser": "babel", "overrides": [ + { + "files": ["*.ts", "*.tsx"], + "options": { + "parser": "typescript" + } + }, { "files": "*.json", "options": { diff --git a/packages/mc-scripts/src/commands/build-vite.ts b/packages/mc-scripts/src/commands/build-vite.ts index c1d6fdbdce..5520fd2c23 100644 --- a/packages/mc-scripts/src/commands/build-vite.ts +++ b/packages/mc-scripts/src/commands/build-vite.ts @@ -59,7 +59,10 @@ async function run() { pluginReact({ jsxImportSource: '@emotion/react', babel: { - plugins: ['@emotion/babel-plugin'], + plugins: [ + '@emotion/babel-plugin', + '@babel/plugin-proposal-do-expressions', + ], }, }), pluginSvgr(), diff --git a/packages/mc-scripts/src/commands/start-vite.ts b/packages/mc-scripts/src/commands/start-vite.ts index f9a4e73bee..e2765392d2 100644 --- a/packages/mc-scripts/src/commands/start-vite.ts +++ b/packages/mc-scripts/src/commands/start-vite.ts @@ -45,7 +45,10 @@ async function run() { pluginReact({ jsxImportSource: '@emotion/react', babel: { - plugins: ['@emotion/babel-plugin'], + plugins: [ + '@emotion/babel-plugin', + '@babel/plugin-proposal-do-expressions', + ], }, }), pluginSvgr(), diff --git a/playground/src/components/entry-point/entry-point.jsx b/playground/src/components/entry-point/entry-point.jsx index 7b55257bef..55672e6972 100644 --- a/playground/src/components/entry-point/entry-point.jsx +++ b/playground/src/components/entry-point/entry-point.jsx @@ -9,8 +9,8 @@ import configureApolloClient from '../../apollo-client'; // Here we split up the main (app) bundle with the actual application business logic. // Splitting by route is usually recommended and you can potentially have a splitting // point for each route. More info at https://reactjs.org/docs/code-splitting.html -const AsyncPlaygroundRoutes = lazy( - () => import('../../routes' /* webpackChunkName: "app-kit-playground" */) +const AsyncPlaygroundRoutes = lazy(() => + import('../../routes' /* webpackChunkName: "app-kit-playground" */) ); // Ensure to setup the global error listener before any React component renders