@ms-cloudpack/package-utilities
Advanced tools
Comparing version 7.6.1 to 7.7.0
@@ -1,5 +0,2 @@ | ||
/** | ||
* Module type of a source file. Undefined implies that we can not determine the module type. | ||
*/ | ||
export type ModuleType = 'esm' | 'cjs' | undefined; | ||
import type { ModuleType } from '@ms-cloudpack/common-types'; | ||
export declare function detectModuleTypeFromSource(source: string): ModuleType; | ||
@@ -6,0 +3,0 @@ /** |
import fsPromises from 'fs/promises'; | ||
import { parse } from 'acorn'; | ||
import { simple } from 'acorn-walk'; | ||
import { simple as simpleWalk } from 'acorn-walk'; | ||
import path from 'path'; | ||
@@ -29,2 +29,11 @@ import { javascriptExtensions, typescriptExtensions } from '@ms-cloudpack/path-utilities'; | ||
} | ||
// Basic check for AMD-style modules. | ||
const firstNode = ast.body[0]; | ||
if (firstNode && | ||
firstNode.type === 'ExpressionStatement' && | ||
firstNode.expression.type === 'CallExpression' && | ||
firstNode.expression.callee.type === 'Identifier' && | ||
firstNode.expression.callee.name === 'define') { | ||
return 'amd'; | ||
} | ||
let isCJS = false; | ||
@@ -42,3 +51,3 @@ let isESM = false; | ||
try { | ||
simple(ast, { | ||
simpleWalk(ast, { | ||
// ESM checks | ||
@@ -45,0 +54,0 @@ ImportDeclaration: returnESM, |
@@ -15,3 +15,3 @@ export { PackageDefinitions } from './PackageDefinitions.js'; | ||
export { resolve } from './resolve.js'; | ||
export { detectModuleType, type ModuleType } from './detectModuleType.js'; | ||
export { detectModuleType } from './detectModuleType.js'; | ||
export { isExternalPackage } from './isExternalPackage.js'; | ||
@@ -18,0 +18,0 @@ export { findFileInPackage, type FindFileInPackageOptions, type FindFileInPackageResult } from './findFileInPackage.js'; |
{ | ||
"name": "@ms-cloudpack/package-utilities", | ||
"version": "7.6.1", | ||
"version": "7.7.0", | ||
"description": "Utilities for resolving/parsing packages and their imports.", | ||
@@ -17,7 +17,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/common-types": "^0.8.1", | ||
"@ms-cloudpack/common-types": "^0.8.2", | ||
"@ms-cloudpack/json-utilities": "^0.1.4", | ||
"@ms-cloudpack/package-overrides": "^0.9.4", | ||
"@ms-cloudpack/package-overrides": "^0.9.5", | ||
"@ms-cloudpack/path-string-parsing": "^1.2.3", | ||
"@ms-cloudpack/path-utilities": "^2.7.19", | ||
"@ms-cloudpack/path-utilities": "^2.7.20", | ||
"@ms-cloudpack/task-reporter": "^0.14.1", | ||
@@ -24,0 +24,0 @@ "acorn": "^8.11.2", |
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
307534
2577
211
17
2
108