Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cshawaus committed Nov 30, 2022
2 parents 7262b8e + 4fe9015 commit 9c7043f
Show file tree
Hide file tree
Showing 4 changed files with 497 additions and 270 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,32 @@
},
"dependencies": {
"debug": "^4.3.4",
"es-module-lexer": "^0.10.5",
"magic-string": "^0.26.2",
"es-module-lexer": "^1.1.0",
"magic-string": "^0.26.7",
"rollup-pluginutils": "^2.8.2",
"vite": "2.9.13"
"vite": "^2.9.15"
},
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@semantic-release/changelog": "^6.0.1",
"@commitlint/cli": "^17.3.0",
"@commitlint/config-conventional": "^17.3.0",
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"@types/debug": "^4.1.7",
"@types/node": "^14.18.21",
"@typescript-eslint/eslint-plugin": "^5.30.3",
"@typescript-eslint/parser": "^5.30.3",
"eslint": "^8.19.0",
"@types/node": "^14.18.33",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"prettier": "^2.7.1",
"semantic-release": "^19.0.3",
"tsup": "^6.1.2",
"typescript": "^4.7.4"
"husky": "^8.0.2",
"prettier": "^2.8.0",
"semantic-release": "^19.0.5",
"tsup": "^6.5.0",
"typescript": "^4.9.3"
},
"peerDependencies": {
"vite": ">2.6.0"
"vite": "^2.6.0 || ^3.0.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
Expand Down
19 changes: 15 additions & 4 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@ export function generateChecksum(source: string): string {
* @returns a unqiue cache key for the provided `path`
*/
export function getCacheKey(entryPath: string, keyFormat: AEMLongCacheConfiguration['keyFormat']): string {
const keyFormatString = keyFormat === undefined ? 'lc-%s-lc' : typeof keyFormat === 'string' ? keyFormat : '%s'
let keyFormatString = ''

switch (keyFormat) {
case 'cloud':
keyFormatString = 'lc-%s-lc.%m'
break
case 'acs-classic':
keyFormatString = '%s.%m'
break
case 'acs-modern':
keyFormatString = '%m.ACSHASH%s'
break
}

const combinedContents = [...entryPaths].map((entry) => {
const path = join(entryPath, entry)
Expand Down Expand Up @@ -94,10 +106,9 @@ export function getAemClientLibPath(
if (withChecksum && options.caching && options.caching.enabled && rollupOptions !== undefined) {
const entryPath = rollupOptions.dir as string

// Append the md5 checksum to the path
// Append the MD5 checksum and minified extension to the path
path = `${path}.${getCacheKey(entryPath, options.caching.keyFormat)}`

return `${path}${options.minify === true ? '.min' : ''}.js`
path = path.replace('.%m', options.minify === true ? '.min' : '')
}

return `${path}.js`
Expand Down
14 changes: 8 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ export interface AEMLongCacheConfiguration {
/**
* Define the long cache key format that will be injected into the entry paths.
*
* Ensure you set this correctly for your particular AEM configuration as it will change
* when using the AEM SDK (AEMaaCS) vs using ACS Commons Versioned ClientLibs. When using
* ACS Commons Versioned ClientLibs you will need to set this to `false` as it only uses
* an MD5 checksum.
* Ensure you choose the correct format for your AEM version and ACS Commons. Newer versions
* of ACS Commons use a different format so it is vital to ensure you are using the correct
* one. Choose 'acs-modern' for ACS Commons when ACSHASH is present in ClientLib URLs, otherwise
* choose 'acs-classic'.
*
* @default lc-%s-lc
* Set to `false` to disable this functionality completely.
*
* @default cloud
*/
keyFormat?: string | false
keyFormat?: 'cloud' | 'acs-modern' | 'acs-classic' | false
}

export interface BaseImportRewriterOptions {
Expand Down
Loading

0 comments on commit 9c7043f

Please sign in to comment.