babel-plugin-import
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -68,9 +68,10 @@ "use strict"; | ||
fileName = _ref3.fileName, | ||
customName = _ref3.customName; | ||
customName = _ref3.customName, | ||
transformToDefaultImport = _ref3.transformToDefaultImport; | ||
(0, _assert.default)(libraryName, 'libraryName should be provided'); | ||
return new _Plugin.default(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, types); | ||
return new _Plugin.default(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types); | ||
}); | ||
} else { | ||
(0, _assert.default)(opts.libraryName, 'libraryName should be provided'); | ||
plugins = [new _Plugin.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, types)]; | ||
plugins = [new _Plugin.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, opts.transformToDefaultImport, types)]; | ||
} | ||
@@ -77,0 +78,0 @@ } |
@@ -41,3 +41,3 @@ "use strict"; | ||
function () { | ||
function Plugin(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, types) { | ||
function Plugin(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types) { | ||
(0, _classCallCheck2.default)(this, Plugin); | ||
@@ -54,2 +54,3 @@ this.specified = null; | ||
this.customName = customName; | ||
this.transformToDefaultImport = typeof transformToDefaultImport === 'undefined' ? true : transformToDefaultImport; | ||
this.types = types; | ||
@@ -78,5 +79,5 @@ } | ||
); | ||
this.selectedMethods[methodName] = (0, _helperModuleImports.addDefault)(file.path, path, { | ||
this.selectedMethods[methodName] = this.transformToDefaultImport ? (0, _helperModuleImports.addDefault)(file.path, path, { | ||
nameHint: methodName | ||
}); | ||
}) : (0, _helperModuleImports.addNamed)(file.path, methodName, path); | ||
@@ -83,0 +84,0 @@ if (style === true) { |
{ | ||
"name": "babel-plugin-import", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"description": "Component modular import plugin for babel.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -133,3 +133,3 @@ # babel-plugin-import | ||
### style | ||
#### style | ||
@@ -163,3 +163,3 @@ - `["import", { "libraryName": "antd" }]`: import js modularly | ||
### customName | ||
#### customName | ||
@@ -209,4 +209,8 @@ We can use `customName` to customize import file path. | ||
#### transformToDefaultImport | ||
Set this option to `false` if your module does not have a `default` export. | ||
### Note | ||
babel-plugin-import will not work properly if you add the library to the webpack config [vendor](https://webpack.github.io/docs/code-splitting.html#split-app-and-vendor-code). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20218
339
214