Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-import

Package Overview
Dependencies
Maintainers
4
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-import - npm Package Compare versions

Comparing version 1.12.2 to 1.13.0

6

lib/index.js

@@ -63,2 +63,4 @@ "use strict";

style,
styleLibraryDirectory,
customStyleName,
camel2DashComponentName,

@@ -71,7 +73,7 @@ camel2UnderlineComponentName,

(0, _assert.default)(libraryName, 'libraryName should be provided');
return new _Plugin.default(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index);
return new _Plugin.default(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index);
});
} 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, opts.transformToDefaultImport, types)];
plugins = [new _Plugin.default(opts.libraryName, opts.libraryDirectory, opts.style, opts.styleLibraryDirectory, opts.customStyleName, opts.camel2DashComponentName, opts.camel2UnderlineComponentName, opts.fileName, opts.customName, opts.transformToDefaultImport, types)];
}

@@ -78,0 +80,0 @@ }

@@ -34,3 +34,3 @@ "use strict";

class Plugin {
constructor(libraryName, libraryDirectory, style, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index = 0) {
constructor(libraryName, libraryDirectory, style, styleLibraryDirectory, customStyleName, camel2DashComponentName, camel2UnderlineComponentName, fileName, customName, transformToDefaultImport, types, index = 0) {
this.libraryName = libraryName;

@@ -41,2 +41,4 @@ this.libraryDirectory = typeof libraryDirectory === 'undefined' ? 'lib' : libraryDirectory;

this.style = style || false;
this.styleLibraryDirectory = styleLibraryDirectory;
this.customStyleName = normalizeCustomName(customStyleName);
this.fileName = fileName || '';

@@ -70,3 +72,9 @@ this.customName = normalizeCustomName(customName);

if (style === true) {
if (this.customStyleName) {
const stylePath = winPath(this.customStyleName(transformedMethodName));
(0, _helperModuleImports.addSideEffect)(file.path, `${stylePath}`);
} else if (this.styleLibraryDirectory) {
const stylePath = winPath((0, _path.join)(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName));
(0, _helperModuleImports.addSideEffect)(file.path, `${stylePath}`);
} else if (style === true) {
(0, _helperModuleImports.addSideEffect)(file.path, `${path}/style`);

@@ -73,0 +81,0 @@ } else if (style === 'css') {

{
"name": "babel-plugin-import",
"version": "1.12.2",
"version": "1.13.0",
"description": "Component modular import plugin for babel.",

@@ -5,0 +5,0 @@ "repository": {

@@ -162,2 +162,23 @@ # babel-plugin-import

#### styleLibraryDirectory
- `["import", { "libraryName": "element-ui", "styleLibraryDirectory": "lib/theme-chalk" }]`: import js and css modularly
If `styleLibraryDirectory` is provided (default `null`), it will be used to form style file path,
`style` will be ignored then. e.g.
```javascript
{
"libraryName": "element-ui",
"styleLibraryDirectory": "lib/theme-chalk",
}
import { Button } from 'element-ui';
↓ ↓ ↓ ↓ ↓ ↓
var _button = require('element-ui/lib/button');
require('element-ui/lib/theme-chalk/button');
```
#### customName

@@ -230,2 +251,6 @@

#### customStyleName
`customStyleName` works exactly the same as customName, except that it deals with style file path.
#### transformToDefaultImport

@@ -237,2 +262,2 @@

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).
babel-plugin-import will not work properly if you add the library to the webpack config [vendor](https://webpack.js.org/concepts/entry-points/#separate-app-and-vendor-entries).

@@ -29,2 +29,4 @@ import assert from 'assert';

style,
styleLibraryDirectory,
customStyleName,
camel2DashComponentName,

@@ -41,2 +43,4 @@ camel2UnderlineComponentName,

style,
styleLibraryDirectory,
customStyleName,
camel2DashComponentName,

@@ -58,2 +62,4 @@ camel2UnderlineComponentName,

opts.style,
opts.styleLibraryDirectory,
opts.customStyleName,
opts.camel2DashComponentName,

@@ -60,0 +66,0 @@ opts.camel2UnderlineComponentName,

@@ -29,2 +29,4 @@ import { join } from 'path';

style,
styleLibraryDirectory,
customStyleName,
camel2DashComponentName,

@@ -47,2 +49,4 @@ camel2UnderlineComponentName,

this.style = style || false;
this.styleLibraryDirectory = styleLibraryDirectory;
this.customStyleName = normalizeCustomName(customStyleName);
this.fileName = fileName || '';

@@ -79,3 +83,11 @@ this.customName = normalizeCustomName(customName);

: addNamed(file.path, methodName, path);
if (style === true) {
if (this.customStyleName) {
const stylePath = winPath(this.customStyleName(transformedMethodName));
addSideEffect(file.path, `${stylePath}`);
} else if (this.styleLibraryDirectory) {
const stylePath = winPath(
join(this.libraryName, this.styleLibraryDirectory, transformedMethodName, this.fileName)
);
addSideEffect(file.path, `${stylePath}`);
} else if (style === true) {
addSideEffect(file.path, `${path}/style`);

@@ -82,0 +94,0 @@ } else if (style === 'css') {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc