@aem-vite/import-rewriter
Advanced tools
Comparing version 6.0.1 to 7.0.0
@@ -18,10 +18,12 @@ import { PluginOption } from 'vite'; | ||
* | ||
* 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; | ||
} | ||
@@ -28,0 +30,0 @@ interface BaseImportRewriterOptions { |
@@ -20,3 +20,6 @@ "use strict"; | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -58,3 +61,14 @@ | ||
function getCacheKey(entryPath, keyFormat) { | ||
const keyFormatString = keyFormat === void 0 ? "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) => { | ||
@@ -74,3 +88,3 @@ const path = (0, import_path.join)(entryPath, entry); | ||
path = `${path}.${getCacheKey(entryPath, options.caching.keyFormat)}`; | ||
return `${path}${options.minify === true ? ".min" : ""}.js`; | ||
path = path.replace(".%m", options.minify === true ? ".min" : ""); | ||
} | ||
@@ -84,3 +98,6 @@ return `${path}.js`; | ||
} | ||
return isInputAnEntryAlias(path, entryAliases) ? path.replace(new RegExp(`${relativePathPattern.source}${path.replace(relativePathPattern, "")}`), getAemClientLibPath(options)) : path; | ||
return isInputAnEntryAlias(path, entryAliases) ? path.replace( | ||
new RegExp(`${relativePathPattern.source}${path.replace(relativePathPattern, "")}`), | ||
getAemClientLibPath(options) | ||
) : path; | ||
} | ||
@@ -103,3 +120,5 @@ function isInputAnEntryAlias(input, entryAliases) { | ||
if (!inputs || typeof inputs !== "object" || Array.isArray(inputs)) { | ||
throw new Error("Missing valid input aliases which are required to map to an AEM ClientLib path, see https://www.aemvite.dev/guide/front-end/vite/#source-structure for more information."); | ||
throw new Error( | ||
"Missing valid input aliases which are required to map to an AEM ClientLib path, see https://www.aemvite.dev/guide/front-end/vite/#source-structure for more information." | ||
); | ||
} | ||
@@ -112,3 +131,5 @@ for (const [key, value] of Object.entries(inputs)) { | ||
if (Object.keys(entryAliases).length > 1) { | ||
throw new Error("Invalid number of JavaScript inputs provided. Only a single input is currently supported which is a limitation of AEM ClientLibs. It is recommended to create a second ClientLib and Vite config if you need to meet this need."); | ||
throw new Error( | ||
"Invalid number of JavaScript inputs provided. Only a single input is currently supported which is a limitation of AEM ClientLibs. It is recommended to create a second ClientLib and Vite config if you need to meet this need." | ||
); | ||
} | ||
@@ -121,3 +142,5 @@ }, | ||
if (!options.publicPath || !options.publicPath.length) { | ||
this.error(`'publicPath' doesn't appear to be defined, see https://aemvite.dev/guide/faqs/#vite-errors for more information.`); | ||
this.error( | ||
`'publicPath' doesn't appear to be defined, see https://aemvite.dev/guide/faqs/#vite-errors for more information.` | ||
); | ||
} | ||
@@ -190,3 +213,6 @@ if (chunk.isEntry && chunk.facadeModuleId && /(ts|js)x?$/.test(chunk.facadeModuleId)) { | ||
const original = source.slice(dynamicIndex + 8, dynamicEnd - 2); | ||
debug("write bundle (dynamic import) replacement:", getReplacementPath(chunk.fileName, importPath, options, entryAliases)); | ||
debug( | ||
"write bundle (dynamic import) replacement:", | ||
getReplacementPath(chunk.fileName, importPath, options, entryAliases) | ||
); | ||
if (!original.startsWith("/")) { | ||
@@ -193,0 +219,0 @@ str().overwrite(start + 1, end - 1, getReplacementPath(chunk.fileName, importPath, options, entryAliases)); |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "6.0.1", | ||
"version": "7.0.0", | ||
"engines": { | ||
@@ -66,28 +66,28 @@ "node": ">= 14" | ||
"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" | ||
}, | ||
@@ -94,0 +94,0 @@ "optionalDependencies": { |
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
67056
490
+ Addedes-module-lexer@1.5.4(transitive)
+ Addedrollup@2.77.3(transitive)
+ Addedvite@2.9.18(transitive)
- Removedes-module-lexer@0.10.5(transitive)
- Removedrollup@2.79.2(transitive)
- Removedvite@2.9.13(transitive)
Updatedes-module-lexer@^1.1.0
Updatedmagic-string@^0.26.7
Updatedvite@^2.9.15