@ms-cloudpack/package-utilities
Advanced tools
Comparing version 0.10.0 to 0.11.0
@@ -5,3 +5,32 @@ { | ||
{ | ||
"date": "Tue, 06 Sep 2022 08:17:22 GMT", | ||
"date": "Wed, 21 Sep 2022 08:14:52 GMT", | ||
"tag": "@ms-cloudpack/package-utilities_v0.11.0", | ||
"version": "0.11.0", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"author": "dzearing@microsoft.com", | ||
"package": "@ms-cloudpack/package-utilities", | ||
"commit": "2a4b0a12d70f4314815226c1e3f552c484cfb350", | ||
"comment": "Modules with \"exports.foo =\" are now correctly detected as cjs." | ||
} | ||
], | ||
"minor": [ | ||
{ | ||
"author": "dzearing@microsoft.com", | ||
"package": "@ms-cloudpack/package-utilities", | ||
"commit": "c2c5d7663c6e19d3bc349173bf59671d37ef20ed", | ||
"comment": "Renaming `getExportsMap` to `getFlattenedExportsMap`." | ||
}, | ||
{ | ||
"author": "beachball", | ||
"package": "@ms-cloudpack/package-utilities", | ||
"comment": "Bump @ms-cloudpack/path-utilities to v0.5.0", | ||
"commit": "edaf39b3a641d469b5238c446b23e25399714ebd" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 06 Sep 2022 08:17:50 GMT", | ||
"tag": "@ms-cloudpack/package-utilities_v0.10.0", | ||
@@ -8,0 +37,0 @@ "version": "0.10.0", |
# Change Log - @ms-cloudpack/package-utilities | ||
This log was last generated on Tue, 06 Sep 2022 08:17:22 GMT and should not be manually modified. | ||
This log was last generated on Wed, 21 Sep 2022 08:14:52 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 0.11.0 | ||
Wed, 21 Sep 2022 08:14:52 GMT | ||
### Minor changes | ||
- Renaming `getExportsMap` to `getFlattenedExportsMap`. (dzearing@microsoft.com) | ||
- Bump @ms-cloudpack/path-utilities to v0.5.0 | ||
### Patches | ||
- Modules with "exports.foo =" are now correctly detected as cjs. (dzearing@microsoft.com) | ||
## 0.10.0 | ||
Tue, 06 Sep 2022 08:17:22 GMT | ||
Tue, 06 Sep 2022 08:17:50 GMT | ||
@@ -11,0 +24,0 @@ ### Minor changes |
import { PackageDefinitions } from './PackageDefinitions.js'; | ||
import { merge } from 'merge'; | ||
import { getExportsMap } from './getExportsMap.js'; | ||
import { getFlattenedExportsMap } from './getFlattenedExportsMap.js'; | ||
import fs from 'fs'; | ||
@@ -32,3 +32,3 @@ import path from 'path'; | ||
if (definition?.name && !definition.name.startsWith('@types/')) { | ||
const exportsMap = getExportsMap(definition); | ||
const exportsMap = getFlattenedExportsMap(definition); | ||
if (Object.keys(exportsMap).length === 0) { | ||
@@ -35,0 +35,0 @@ // Best effort exports map. |
@@ -17,3 +17,3 @@ import fs from 'fs'; | ||
} | ||
else if (content.match(/(module.exports[ =]+)|(require\(['"]+)/)) { | ||
else if (content.match(/module\.exports[ =]+|exports\.|require\(['"]+/)) { | ||
result = 'cjs'; | ||
@@ -20,0 +20,0 @@ } |
@@ -7,21 +7,24 @@ import { describe, it, expect } from '@jest/globals'; | ||
describe('detectModuleTypeFromSource', () => { | ||
it('can detect imports mean esm', async () => { | ||
it('can infer esm from the presence of "import"', async () => { | ||
expect(await detectModuleTypeFromSource(`import react from 'react';`)).toBe('esm'); | ||
}); | ||
it('can detect exports mean esm', async () => { | ||
it('can infer esm from the presence of "export"', async () => { | ||
expect(await detectModuleTypeFromSource(`export const foo = 'foo';`)).toBe('esm'); | ||
}); | ||
it('can detect requires mean cjs', async () => { | ||
it('can infer cjs from the presence of "require"', async () => { | ||
expect(await detectModuleTypeFromSource(`const path = require('path')`)).toBe('cjs'); | ||
}); | ||
it('can detect exports mean cjs', async () => { | ||
it('can infer cjs from the presence of "module.exports"', async () => { | ||
expect(await detectModuleTypeFromSource(`module.exports = 'foo';`)).toBe('cjs'); | ||
}); | ||
it('can detect cjs with imports in comments.', async () => { | ||
it('can infer cjs from the presence of "exports."', async () => { | ||
expect(await detectModuleTypeFromSource(`exports.Emitter = 'foo';`)).toBe('cjs'); | ||
}); | ||
it('can infer cjs even if esm "import" exists in comments.', async () => { | ||
expect(await detectModuleTypeFromSource(`/* import react from 'react'; */ module.exports = 'foo';`)).toBe('cjs'); | ||
}); | ||
it('can detect no modules', async () => { | ||
it('resolves to undefined if no patterns are detected', async () => { | ||
expect(await detectModuleTypeFromSource(`const hello = 'hello';`)).toBeUndefined(); | ||
}); | ||
it('can return undefined for missing source', async () => { | ||
it('resolves to undefined for missing source', async () => { | ||
expect(await detectModuleType(path.join(currentPath, 'does-not-exist.js'))).toBeUndefined(); | ||
@@ -28,0 +31,0 @@ }); |
export { createResolveMap } from './createResolveMap.js'; | ||
export { evaluateImportsFromEntries } from './evaluateImportsFromEntries.js'; | ||
export { PackageDefinitions, type PackageDefinitionTransform } from './PackageDefinitions.js'; | ||
export { getExportsMap } from './getExportsMap.js'; | ||
export { getFlattenedExportsMap } from './getFlattenedExportsMap.js'; | ||
export { resolve } from './resolve.js'; | ||
@@ -6,0 +6,0 @@ export { resolveImportFromPackage, resolveImportFromPackagePath, type ResolveImportFromPackageOptions, } from './resolveImportFromPackagePath.js'; |
export { createResolveMap } from './createResolveMap.js'; | ||
export { evaluateImportsFromEntries } from './evaluateImportsFromEntries.js'; | ||
export { PackageDefinitions } from './PackageDefinitions.js'; | ||
export { getExportsMap } from './getExportsMap.js'; | ||
export { getFlattenedExportsMap } from './getFlattenedExportsMap.js'; | ||
export { resolve } from './resolve.js'; | ||
@@ -6,0 +6,0 @@ export { resolveImportFromPackage, resolveImportFromPackagePath, } from './resolveImportFromPackagePath.js'; |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.30.0" | ||
"packageVersion": "7.31.1" | ||
} | ||
] | ||
} |
{ | ||
"name": "@ms-cloudpack/package-utilities", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Utilities for resolving/parsing packages and their imports.", | ||
@@ -20,3 +20,3 @@ "license": "MIT", | ||
"@ms-cloudpack/package-overrides": "^0.1.0", | ||
"@ms-cloudpack/path-utilities": "^0.4.0", | ||
"@ms-cloudpack/path-utilities": "^0.5.0", | ||
"resolve": "^1.22.0" | ||
@@ -23,0 +23,0 @@ }, |
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
164580
2673
+ Added@ms-cloudpack/path-utilities@0.5.0(transitive)
- Removed@ms-cloudpack/path-utilities@0.4.0(transitive)