From f937dec57d492b9927fe6235f0103b3f1a9cdf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E4=B9=99=E5=B1=B1?= Date: Wed, 9 Jan 2019 12:33:15 +0800 Subject: [PATCH] [Deps]: add babel plugins to make dynamic import work add two plugins: babel-plugin-dynamic-import-node and babel-plugin-syntax-dynamic-import --- .babelrc | 2 ++ package.json | 2 ++ packages/enzyme-test-suite/test/Adapter-spec.jsx | 1 + .../test/_helpers/dynamicImportedComponent.jsx | 11 +++++++++++ 4 files changed, 16 insertions(+) create mode 100644 packages/enzyme-test-suite/test/_helpers/dynamicImportedComponent.jsx diff --git a/.babelrc b/.babelrc index 1a12c35ef..36dd965cd 100644 --- a/.babelrc +++ b/.babelrc @@ -2,6 +2,8 @@ "presets": ["airbnb"], "plugins": [ ["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }], + "syntax-dynamic-import", + "dynamic-import-node" ], ignore: [ "packages/enzyme-test-suite/test/_helpers/untranspiled*", diff --git a/package.json b/package.json index 01c8446d4..874cf439c 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,8 @@ "babel-core": "^6.26.3", "babel-eslint": "^7.2.3", "babel-loader": "^6.4.1", + "babel-plugin-dynamic-import-node": "^2.2.0", + "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-replace-object-assign": "^1.0.0", "babel-preset-airbnb": "^2.6.0", "babel-register": "^6.26.0", diff --git a/packages/enzyme-test-suite/test/Adapter-spec.jsx b/packages/enzyme-test-suite/test/Adapter-spec.jsx index f5cd61975..3ab12ee2b 100644 --- a/packages/enzyme-test-suite/test/Adapter-spec.jsx +++ b/packages/enzyme-test-suite/test/Adapter-spec.jsx @@ -15,6 +15,7 @@ import { createContext, createPortal, forwardRef, + lazy, Fragment, StrictMode, AsyncMode, diff --git a/packages/enzyme-test-suite/test/_helpers/dynamicImportedComponent.jsx b/packages/enzyme-test-suite/test/_helpers/dynamicImportedComponent.jsx new file mode 100644 index 000000000..3afa41bb0 --- /dev/null +++ b/packages/enzyme-test-suite/test/_helpers/dynamicImportedComponent.jsx @@ -0,0 +1,11 @@ +import React from 'react' + +class DynamicComponent extends React.Component { + render() { + return ( +
Dynamic Component
+ ); + } +} + +module.exports = DynamicComponent; \ No newline at end of file