@ms-cloudpack/package-utilities
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Tue, 18 Oct 2022 08:15:52 GMT", | ||
"date": "Thu, 20 Oct 2022 08:11:43 GMT", | ||
"tag": "@ms-cloudpack/package-utilities_v1.1.0", | ||
"version": "1.1.0", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"author": "dake.3601@gmail.com", | ||
"package": "@ms-cloudpack/package-utilities", | ||
"commit": "083f3df03f5eac33570c4bf54d234b8a6c567191", | ||
"comment": "Import map now has a refresh version in its path to allow cache busting." | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Tue, 18 Oct 2022 08:16:24 GMT", | ||
"tag": "@ms-cloudpack/package-utilities_v1.0.1", | ||
@@ -8,0 +23,0 @@ "version": "1.0.1", |
# Change Log - @ms-cloudpack/package-utilities | ||
This log was last generated on Tue, 18 Oct 2022 08:15:52 GMT and should not be manually modified. | ||
This log was last generated on Thu, 20 Oct 2022 08:11:43 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 1.1.0 | ||
Thu, 20 Oct 2022 08:11:43 GMT | ||
### Minor changes | ||
- Import map now has a refresh version in its path to allow cache busting. (dake.3601@gmail.com) | ||
## 1.0.1 | ||
Tue, 18 Oct 2022 08:15:52 GMT | ||
Tue, 18 Oct 2022 08:16:24 GMT | ||
@@ -11,0 +19,0 @@ ### Patches |
@@ -11,3 +11,4 @@ import type { ResolveMap } from './createResolveMap.js'; | ||
export declare function createImportMap(resolveMap: ResolveMap, bundleServerUrl: string, options?: { | ||
refreshVersion?: number; | ||
packages?: PackageDefinitions; | ||
}): Promise<ImportMap>; |
@@ -12,3 +12,3 @@ import { PackageDefinitions } from './PackageDefinitions.js'; | ||
var _a, _b; | ||
const { packages = PackageDefinitions.getInstance() } = options; | ||
const { packages = PackageDefinitions.getInstance(), refreshVersion } = options; | ||
const importMap = { | ||
@@ -18,3 +18,3 @@ imports: {}, | ||
for (const resolveEntry of Object.values(resolveMap)) { | ||
merge(importMap.imports, await getImportMapFromEntry(resolveEntry, bundleServerUrl, packages)); | ||
merge(importMap.imports, await getImportMapFromEntry(resolveEntry, bundleServerUrl, packages, refreshVersion)); | ||
if (resolveEntry.scopedVersions) { | ||
@@ -24,3 +24,3 @@ // Initialize scopes | ||
for (const scopedEntry of Object.values(resolveEntry.scopedVersions)) { | ||
const importMapForEntry = await getImportMapFromEntry(scopedEntry, bundleServerUrl, packages); | ||
const importMapForEntry = await getImportMapFromEntry(scopedEntry, bundleServerUrl, packages, refreshVersion); | ||
for (const requiredById of Object.keys(scopedEntry.requiredBy)) { | ||
@@ -35,3 +35,3 @@ const scopes = ((_a = importMap.scopes)[_b = `${bundleServerUrl}/${requiredById}/`] ?? (_a[_b] = {})); | ||
} | ||
async function getImportMapFromEntry(entry, bundleServerUrl, packages) { | ||
async function getImportMapFromEntry(entry, bundleServerUrl, packages, refreshVersion) { | ||
const importMap = {}; | ||
@@ -61,2 +61,5 @@ const definition = await packages.get(entry.path); | ||
let resolvedFilePath = unbundledFilePath ? `unbundled/${unbundledFilePath}` : `bundled/${bundledFilePath}`; | ||
if (refreshVersion !== undefined) { | ||
resolvedFilePath = `v${refreshVersion}/${resolvedFilePath}`; | ||
} | ||
const ext = path.extname(resolvedFilePath); | ||
@@ -63,0 +66,0 @@ // For bundled files: |
@@ -90,3 +90,28 @@ import { describe, it, expect } from '@jest/globals'; | ||
}); | ||
it('can generate an import map for a package and append a refresh version', async () => { | ||
const resolveMap = { | ||
foo: { | ||
name: 'foo', | ||
version: '1.0.0', | ||
path: '/foo', | ||
requiredBy: {}, | ||
}, | ||
}; | ||
const packages = new PackageDefinitions({ | ||
'/foo': { | ||
name: 'foo', | ||
version: '1.0.0', | ||
main: './index.js', | ||
}, | ||
}); | ||
const refreshVersion = 3; | ||
expect(await createImportMap(resolveMap, defaultServer, { packages, refreshVersion })).toMatchInlineSnapshot(` | ||
{ | ||
"imports": { | ||
"foo": "http://localhost:8080/foo@1.0.0/v3/bundled/index.js", | ||
}, | ||
} | ||
`); | ||
}); | ||
}); | ||
//# sourceMappingURL=createImportMap.test.js.map |
{ | ||
"name": "@ms-cloudpack/package-utilities", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Utilities for resolving/parsing packages and their imports.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
188407
3085