ts-import-plugin
Advanced tools
Comparing version 1.5.2 to 1.5.3
@@ -58,3 +58,3 @@ "use strict"; | ||
importName: importSpecifier.propertyName.text, | ||
variableName: importSpecifier.name.text | ||
variableName: importSpecifier.name.text, | ||
}); | ||
@@ -69,10 +69,10 @@ }); | ||
var _importName = struct.importName; | ||
var importName = options.camel2UnderlineComponentName ? | ||
camel2Underline(_importName) : | ||
options.camel2DashComponentName ? | ||
camel2Dash(_importName) : | ||
_importName; | ||
var libraryDirectory = typeof options.libraryDirectory === 'function' ? | ||
options.libraryDirectory(_importName) : | ||
join((options.libraryDirectory || ''), importName); | ||
var importName = options.camel2UnderlineComponentName | ||
? camel2Underline(_importName) | ||
: options.camel2DashComponentName | ||
? camel2Dash(_importName) | ||
: _importName; | ||
var libraryDirectory = typeof options.libraryDirectory === 'function' | ||
? options.libraryDirectory(_importName) | ||
: join(options.libraryDirectory || '', importName); | ||
/* istanbul ignore next */ | ||
@@ -86,14 +86,16 @@ if (process.env.NODE_ENV !== 'production') { | ||
try { | ||
require.resolve(path_1.join(process.cwd(), 'node_modules', importPath)); | ||
var scriptNode = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(struct.variableName || !options.transformToDefaultImport ? undefined : ts.createIdentifier(struct.importName), struct.variableName ? ts.createNamedImports([ | ||
ts.createImportSpecifier(options.transformToDefaultImport ? ts.createIdentifier('default') : ts.createIdentifier(struct.importName), ts.createIdentifier(struct.variableName)) | ||
]) : options.transformToDefaultImport ? undefined : ts.createNamedImports([ | ||
ts.createImportSpecifier(undefined, ts.createIdentifier(struct.importName)) | ||
])), ts.createLiteral(importPath)); | ||
require.resolve(importPath); | ||
var scriptNode = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(struct.variableName || !options.transformToDefaultImport ? undefined : ts.createIdentifier(struct.importName), struct.variableName | ||
? ts.createNamedImports([ | ||
ts.createImportSpecifier(options.transformToDefaultImport | ||
? ts.createIdentifier('default') | ||
: ts.createIdentifier(struct.importName), ts.createIdentifier(struct.variableName)), | ||
]) | ||
: options.transformToDefaultImport | ||
? undefined | ||
: ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(struct.importName))])), ts.createLiteral(importPath)); | ||
astNodes.push(scriptNode); | ||
if (options.style) { | ||
var style = options.style; | ||
var stylePath = (typeof style === 'function') | ||
? style(importPath) | ||
: importPath + "/style/" + (style === true ? 'index' : style) + ".js"; | ||
var stylePath = typeof style === 'function' ? style(importPath) : importPath + "/style/" + (style === true ? 'index' : style) + ".js"; | ||
var styleNode = ts.createImportDeclaration(undefined, undefined, undefined, ts.createLiteral(stylePath)); | ||
@@ -105,5 +107,3 @@ astNodes.push(styleNode); | ||
catch (e) { | ||
astNodes.push(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([ | ||
ts.createImportSpecifier(undefined, ts.createIdentifier(_importName)) | ||
])), ts.createLiteral(libraryName))); | ||
astNodes.push(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(_importName))])), ts.createLiteral(libraryName))); | ||
} | ||
@@ -117,3 +117,3 @@ return astNodes; | ||
camel2DashComponentName: true, | ||
transformToDefaultImport: true | ||
transformToDefaultImport: true, | ||
}; | ||
@@ -123,3 +123,5 @@ function createTransformer(_options) { | ||
var mergeDefault = function (options) { return (tslib_1.__assign({}, defaultOptions, options)); }; | ||
var optionsArray = Array.isArray(_options) ? _options.map(function (options) { return mergeDefault(options); }) : [mergeDefault(_options)]; | ||
var optionsArray = Array.isArray(_options) | ||
? _options.map(function (options) { return mergeDefault(options); }) | ||
: [mergeDefault(_options)]; | ||
var transformer = function (context) { | ||
@@ -142,5 +144,3 @@ var visitor = function (node) { | ||
} | ||
return Array | ||
.from(structs) | ||
.reduce(function (acc, struct) { | ||
return Array.from(structs).reduce(function (acc, struct) { | ||
var nodes = createDistAst(struct, options); | ||
@@ -147,0 +147,0 @@ return acc.concat(nodes); |
{ | ||
"name": "ts-import-plugin", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "babel-plugin-import TypeScript version", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"cover": "rm -rf ./coverage ./.nyc_output && nyc --reporter=html --reporter=lcov --exclude=node_modules --exclude=test mocha && nyc report", | ||
"lint": "tslint -c ./tslint.json -p ./src/tsconfig.json && standard \"test/*.js\" \"./*.js\"", | ||
"lint": "tslint -c ./tslint.json -p ./src/tsconfig.json", | ||
"precommit": "lint-staged", | ||
@@ -34,35 +34,36 @@ "prepare": "npm run build", | ||
"devDependencies": { | ||
"@types/chai": "^4.1.2", | ||
"@types/lodash": "^4.14.104", | ||
"@types/chai": "^4.1.3", | ||
"@types/lodash": "^4.14.109", | ||
"@types/material-ui": "^0.21.1", | ||
"@types/mocha": "^5.0.0", | ||
"@types/node": "^10.0.3", | ||
"@types/react": "^16.0.40", | ||
"@types/react-dom": "^16.0.4", | ||
"antd": "^3.2.3", | ||
"@types/mocha": "^5.2.1", | ||
"@types/node": "^10.3.1", | ||
"@types/react": "^16.3.16", | ||
"@types/react-dom": "^16.0.6", | ||
"antd": "^3.6.1", | ||
"chai": "^4.1.2", | ||
"coveralls": "^3.0.0", | ||
"css-loader": "^0.28.10", | ||
"extract-text-webpack-plugin": "^3.0.2", | ||
"coveralls": "^3.0.1", | ||
"css-loader": "^0.28.11", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^7.1.2", | ||
"lodash": "^4.17.5", | ||
"material-ui": "^0.20.0", | ||
"mocha": "^5.0.4", | ||
"nyc": "^12.0.1", | ||
"react": "^16.2.0", | ||
"react-dom": "^16.2.0", | ||
"rxjs": "^5.5.6", | ||
"standard": "^11.0.0", | ||
"lint-staged": "^7.1.3", | ||
"lodash": "^4.17.10", | ||
"material-ui": "^0.20.1", | ||
"mini-css-extract-plugin": "^0.4.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^12.0.2", | ||
"prettier": "^1.13.4", | ||
"react": "^16.4.0", | ||
"react-dom": "^16.4.0", | ||
"rxjs": "^6.2.0", | ||
"style-loader": "^0.21.0", | ||
"ts-loader": "^4.0.1", | ||
"ts-node": "^6.0.0", | ||
"tslint": "^5.9.1", | ||
"tslint-eslint-rules": "^5.1.0", | ||
"typescript": "^2.7.2", | ||
"webpack": "^4.1.1", | ||
"webpack-bundle-analyzer": "^2.11.1" | ||
"ts-loader": "^4.3.1", | ||
"ts-node": "^6.1.0", | ||
"tslint": "^5.10.0", | ||
"tslint-eslint-rules": "^5.3.1", | ||
"typescript": "^2.9.1", | ||
"webpack": "^4.10.2", | ||
"webpack-bundle-analyzer": "^2.13.1", | ||
"webpack-cli": "^3.0.2" | ||
}, | ||
"dependencies": { | ||
"tslib": "^1.9.0" | ||
"tslib": "^1.9.2" | ||
}, | ||
@@ -75,4 +76,13 @@ "standard": { | ||
}, | ||
"prettier": { | ||
"printWidth": 120, | ||
"semi": false, | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"arrowParens": "always", | ||
"parser": "typescript" | ||
}, | ||
"lint-staged": { | ||
"*.ts": [ | ||
"prettier --write", | ||
"tslint -c tslint.json -p tsconfig.json --fix -e \"**/test/expect/**\"", | ||
@@ -79,0 +89,0 @@ "git add" |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
19742
31
Updatedtslib@^1.9.2