@stencil/angular-output-target
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -1,3 +0,2 @@ | ||
import path from 'path'; | ||
import { dashToPascalCase, isRelativePath, normalizePath } from './utils'; | ||
import { dashToPascalCase } from './utils'; | ||
export const createComponentDefinition = (componentCorePackage, distTypesDir, rootDir) => (cmpMeta) => { | ||
@@ -26,4 +25,2 @@ // Collect component meta | ||
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName); | ||
const typePath = path.parse(path.join(componentCorePackage, path.join(cmpMeta.sourceFilePath, '').replace(path.join(rootDir, 'src'), distTypesDir))); | ||
const importPath = normalizePath(path.join(typePath.dir, typePath.name)); | ||
const outputsInterface = new Set(); | ||
@@ -33,15 +30,10 @@ const outputReferenceRemap = {}; | ||
Object.entries(output.complexType.references).forEach(([reference, refObject]) => { | ||
// Add import line for each local/import reference, and add new mapping name | ||
// outputReferenceRemap should be updated only if the import interface is set in outputsInterface | ||
// This will prevent global types to be remapped | ||
// Add import line for each local/import reference, and add new mapping name. | ||
// `outputReferenceRemap` should be updated only if the import interface is set in outputsInterface, | ||
// this will prevent global types to be remapped. | ||
const remappedReference = `I${cmpMeta.componentClassName}${reference}`; | ||
if (refObject.location === 'local') { | ||
if (refObject.location === 'local' || refObject.location === 'import') { | ||
outputReferenceRemap[reference] = remappedReference; | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${importPath}';`); | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${componentCorePackage}';`); | ||
} | ||
else if (refObject.location === 'import') { | ||
outputReferenceRemap[reference] = remappedReference; | ||
const interfacePath = normalizePath(isRelativePath(refObject.path) ? path.join(typePath.dir, refObject.path) : refObject.path); | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${interfacePath}';`); | ||
} | ||
}); | ||
@@ -48,0 +40,0 @@ }); |
@@ -69,5 +69,2 @@ 'use strict'; | ||
} | ||
function isRelativePath(path) { | ||
return path && path.startsWith('.'); | ||
} | ||
async function readPackageJson(rootDir) { | ||
@@ -118,4 +115,2 @@ const pkgJsonPath = path__default['default'].join(rootDir, 'package.json'); | ||
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName); | ||
const typePath = path__default['default'].parse(path__default['default'].join(componentCorePackage, path__default['default'].join(cmpMeta.sourceFilePath, '').replace(path__default['default'].join(rootDir, 'src'), distTypesDir))); | ||
const importPath = normalizePath(path__default['default'].join(typePath.dir, typePath.name)); | ||
const outputsInterface = new Set(); | ||
@@ -125,15 +120,10 @@ const outputReferenceRemap = {}; | ||
Object.entries(output.complexType.references).forEach(([reference, refObject]) => { | ||
// Add import line for each local/import reference, and add new mapping name | ||
// outputReferenceRemap should be updated only if the import interface is set in outputsInterface | ||
// This will prevent global types to be remapped | ||
// Add import line for each local/import reference, and add new mapping name. | ||
// `outputReferenceRemap` should be updated only if the import interface is set in outputsInterface, | ||
// this will prevent global types to be remapped. | ||
const remappedReference = `I${cmpMeta.componentClassName}${reference}`; | ||
if (refObject.location === 'local') { | ||
if (refObject.location === 'local' || refObject.location === 'import') { | ||
outputReferenceRemap[reference] = remappedReference; | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${importPath}';`); | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${componentCorePackage}';`); | ||
} | ||
else if (refObject.location === 'import') { | ||
outputReferenceRemap[reference] = remappedReference; | ||
const interfacePath = normalizePath(isRelativePath(refObject.path) ? path__default['default'].join(typePath.dir, refObject.path) : refObject.path); | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${interfacePath}';`); | ||
} | ||
}); | ||
@@ -317,3 +307,3 @@ }); | ||
components | ||
.map(createComponentDefinition(outputTarget.componentCorePackage, distTypesDir, rootDir)) | ||
.map(createComponentDefinition(outputTarget.componentCorePackage)) | ||
.join('\n'), | ||
@@ -320,0 +310,0 @@ ]; |
@@ -60,5 +60,2 @@ import path from 'path'; | ||
} | ||
function isRelativePath(path) { | ||
return path && path.startsWith('.'); | ||
} | ||
async function readPackageJson(rootDir) { | ||
@@ -109,4 +106,2 @@ const pkgJsonPath = path.join(rootDir, 'package.json'); | ||
const tagNameAsPascal = dashToPascalCase(cmpMeta.tagName); | ||
const typePath = path.parse(path.join(componentCorePackage, path.join(cmpMeta.sourceFilePath, '').replace(path.join(rootDir, 'src'), distTypesDir))); | ||
const importPath = normalizePath(path.join(typePath.dir, typePath.name)); | ||
const outputsInterface = new Set(); | ||
@@ -116,15 +111,10 @@ const outputReferenceRemap = {}; | ||
Object.entries(output.complexType.references).forEach(([reference, refObject]) => { | ||
// Add import line for each local/import reference, and add new mapping name | ||
// outputReferenceRemap should be updated only if the import interface is set in outputsInterface | ||
// This will prevent global types to be remapped | ||
// Add import line for each local/import reference, and add new mapping name. | ||
// `outputReferenceRemap` should be updated only if the import interface is set in outputsInterface, | ||
// this will prevent global types to be remapped. | ||
const remappedReference = `I${cmpMeta.componentClassName}${reference}`; | ||
if (refObject.location === 'local') { | ||
if (refObject.location === 'local' || refObject.location === 'import') { | ||
outputReferenceRemap[reference] = remappedReference; | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${importPath}';`); | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${componentCorePackage}';`); | ||
} | ||
else if (refObject.location === 'import') { | ||
outputReferenceRemap[reference] = remappedReference; | ||
const interfacePath = normalizePath(isRelativePath(refObject.path) ? path.join(typePath.dir, refObject.path) : refObject.path); | ||
outputsInterface.add(`import { ${reference} as ${remappedReference} } from '${interfacePath}';`); | ||
} | ||
}); | ||
@@ -308,3 +298,3 @@ }); | ||
components | ||
.map(createComponentDefinition(outputTarget.componentCorePackage, distTypesDir, rootDir)) | ||
.map(createComponentDefinition(outputTarget.componentCorePackage)) | ||
.join('\n'), | ||
@@ -311,0 +301,0 @@ ]; |
{ | ||
"name": "@stencil/angular-output-target", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Angular output target for @stencil/core components.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
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
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
0
56863
1239