babel-plugin-grommet
Advanced tools
Comparing version 0.5.0 to 0.5.1
13
index.js
const types = require('babel-types'); | ||
const find = require('find'); | ||
const pathUtils = require('path'); | ||
@@ -12,3 +13,3 @@ module.exports = () => ( | ||
const dependencyPathRegexp = new RegExp( | ||
`(${dependencies.join('|')})(\/(components|themes|utils))?$` | ||
`(${dependencies.join('|')})(\\${pathUtils.sep}(components|themes|utils))?$` | ||
); | ||
@@ -19,8 +20,8 @@ const matches = dependencyPathRegexp.exec(source); | ||
const modulesInContext = find.fileSync( | ||
/\.js$/, `./node_modules/${context}` | ||
/\.js$/, pathUtils.join('.', 'node_modules', context) | ||
).map( | ||
file => file.replace(/node_modules\/|\.js/g, '') | ||
file => file.replace(new RegExp(`node_modules\\${pathUtils.sep}|\.js`, 'g'), '') | ||
).filter( | ||
// remove grommet-icons inside grommet node_modules | ||
file => file.indexOf(`${dependency}/grommet-icons`) === -1 | ||
file => file.indexOf(pathUtils.join(dependency, 'grommet-icons')) === -1 | ||
).reverse(); // reverse so es6 modules have higher priority | ||
@@ -37,3 +38,3 @@ const memberImports = path.node.specifiers.filter( | ||
// if webpack alias is enabled the es6 path does not exist. | ||
if (module.endsWith(`/${componentName}`)) { | ||
if (module.endsWith(`${pathUtils.sep}${componentName}`)) { | ||
if (process.env.NODE_ENV === 'development') { | ||
@@ -43,3 +44,3 @@ // in development webpack alias may be enabled | ||
// we need to remove it and use commonjs structure. | ||
newPath = module.replace('es6/', ''); | ||
newPath = module.replace(`es6${pathUtils.sep}`, ''); | ||
} else { | ||
@@ -46,0 +47,0 @@ newPath = module; |
{ | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"name": "babel-plugin-grommet", | ||
@@ -4,0 +4,0 @@ "description": "Babel plugin to transform member style imports into default imports", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
15451
61
1