Procházet zdrojové kódy

feat: 增加两个babel插件

lanjianrong před 5 roky
rodič
revize
03474cdb0c
3 změnil soubory, kde provedl 23 přidání a 14 odebrání
  1. 17 13
      config/config.js
  2. 2 0
      package.json
  3. 4 1
      src/pages/Customer/Test/index.jsx

+ 17 - 13
config/config.js

@@ -1,43 +1,47 @@
 // https://umijs.org/config/
-import { defineConfig } from 'umi';
-import defaultSettings from './defaultSettings';
-import proxy from './proxy';
-import routes from './routes';
-const { REACT_APP_ENV } = process.env;
+import { defineConfig } from 'umi'
+import defaultSettings from './defaultSettings'
+import proxy from './proxy'
+import routes from './routes'
+const { REACT_APP_ENV } = process.env
 export default defineConfig({
   hash: true,
   antd: {},
   dva: {
-    hmr: true,
+    hmr: true
   },
   history: {
-    type: 'browser',
+    type: 'browser'
   },
   locale: {
     // default zh-CN
     default: 'zh-CN',
     antd: false,
     // default true, when it is true, will use `navigator.language` overwrite default
-    baseNavigator: false,
+    baseNavigator: false
   },
   dynamicImport: {
-    loading: '@/components/PageLoading/index',
+    loading: '@/components/PageLoading/index'
   },
   targets: {
-    ie: 11,
+    ie: 11
   },
   // umi routes: https://umijs.org/docs/routing
   routes,
   // Theme for antd: https://ant.design/docs/react/customize-theme-cn
   theme: {
-    'primary-color': defaultSettings.primaryColor,
+    'primary-color': defaultSettings.primaryColor
   },
   title: false,
   ignoreMomentLocale: true,
   proxy: proxy[REACT_APP_ENV || 'dev'],
   manifest: {
-    basePath: '/',
+    basePath: '/'
   },
   exportStatic: {},
   esbuild: {},
-});
+  extraBabelPlugins: [
+    '@babel/plugin-proposal-nullish-coalescing-operator',
+    '@babel/plugin-proposal-optional-chaining'
+  ]
+})

+ 2 - 0
package.json

@@ -70,6 +70,8 @@
   },
   "devDependencies": {
     "@ant-design/pro-cli": "^1.0.18",
+    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8",
+    "@babel/plugin-proposal-optional-chaining": "^7.13.12",
     "@types/classnames": "^2.2.7",
     "@types/express": "^4.17.0",
     "@types/history": "^4.7.2",

+ 4 - 1
src/pages/Customer/Test/index.jsx

@@ -87,7 +87,10 @@ const Test = ({ natures, dispatch }) => {
   }, [])
 
   const a = useMemo(() => {
-    console.log('依赖项更新了')
+    const e = null
+    const b = 2
+    const c = e ?? b
+    console.log('c', c)
   }, [state])
   // const customOptions = useCallback(originNode => {
   //   return originNode