@ms-cloudpack/package-utilities
Advanced tools
Comparing version 5.1.8 to 5.1.9
@@ -13,3 +13,3 @@ import fsPromises from 'fs/promises'; | ||
const content = removeComments(source); | ||
if (content.match(/(import *)|(import {)|(export {)|(export \*)|(export (default )?[_a-zA-Z0-9]+)|(export [a-zA-Z]+ from)/)) { | ||
if (content.match(/\b(?:import|export)\s+[*{_$a-zA-Z]/)) { | ||
result = 'esm'; | ||
@@ -34,4 +34,4 @@ } | ||
} | ||
return detectModuleTypeFromSource(removeComments(source)); | ||
return detectModuleTypeFromSource(source); | ||
} | ||
//# sourceMappingURL=detectModuleType.js.map |
@@ -12,3 +12,3 @@ import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types'; | ||
/** | ||
* Given a requested partial filePath, resolves the relative path intermediate path if the file exists, with special | ||
* Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special | ||
* consideration for internal packages, which may not have intermediate files but only source files. Paths returned | ||
@@ -15,0 +15,0 @@ * are always relative and start with `./`. |
@@ -7,4 +7,5 @@ import path from 'path'; | ||
import { flattenExportsMap } from './flattenExportsMap.js'; | ||
const typescriptExtensions = ['.ts', '.tsx', '.cts', '.mts']; | ||
/** | ||
* Given a requested partial filePath, resolves the relative path intermediate path if the file exists, with special | ||
* Given a requested partial filePath, resolves the relative intermediate path if the file exists, with special | ||
* consideration for internal packages, which may not have intermediate files but only source files. Paths returned | ||
@@ -27,2 +28,4 @@ * are always relative and start with `./`. | ||
filePath + '.js', | ||
filePath + '.mjs', | ||
filePath + '.cjs', | ||
safeRelativePath(path.join(filePath, 'index.js')), | ||
@@ -41,14 +44,17 @@ safeRelativePath(path.join(filePath, 'package.json')), | ||
for (const candidate of candidates) { | ||
const intermediateCandidate = intermediateToSourcePath(candidate, packagePath); | ||
if (intermediateCandidate && (await isFile(path.join(packagePath, intermediateCandidate)))) { | ||
sourcePath = intermediateCandidate; | ||
sourcePath = intermediateToSourcePath(candidate, packagePath); | ||
if (sourcePath) { | ||
break; | ||
} | ||
} | ||
// If we couldn't find a unique source file, stick with the resolved intermediate file as the only known truth. | ||
if (filePath && sourcePath === filePath) { | ||
// If the discovered source file is the same as the provided file, resolve the intermediate path. | ||
if (sourcePath && (!filePath || sourcePath === filePath)) { | ||
filePath = sourceToIntermediatePath(sourcePath); | ||
} | ||
// If the sourcePath is the same as the filePath, clear it. By this point we should have resolved | ||
// the true intermediate path. | ||
if (sourcePath === filePath) { | ||
sourcePath = undefined; | ||
} | ||
if (sourcePath) { | ||
filePath ??= sourceToIntermediatePath(sourcePath); | ||
if (sourcePath && typescriptExtensions.includes(path.extname(sourcePath))) { | ||
typesPath = filePath && path.extname(filePath) === '.js' ? filePath.replace(/\.js$/, '.d.ts') : undefined; | ||
@@ -55,0 +61,0 @@ } |
{ | ||
"name": "@ms-cloudpack/package-utilities", | ||
"version": "5.1.8", | ||
"version": "5.1.9", | ||
"description": "Utilities for resolving/parsing packages and their imports.", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"@ms-cloudpack/package-overrides": "^0.4.4", | ||
"@ms-cloudpack/path-utilities": "^2.3.3", | ||
"@ms-cloudpack/path-utilities": "^2.3.4", | ||
"@ms-cloudpack/path-string-parsing": "^1.1.0", | ||
@@ -26,3 +26,3 @@ "fast-glob": "^3.2.12", | ||
"semver": "^7.3.7", | ||
"workspace-tools": "^0.35.1" | ||
"workspace-tools": "^0.35.2" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
182595
1542