@podium/utils
Advanced tools
Comparing version 4.5.0 to 4.5.1
@@ -0,1 +1,8 @@ | ||
## [4.5.1](https://github.com/podium-lib/utils/compare/v4.5.0...v4.5.1) (2023-11-19) | ||
### Bug Fixes | ||
* correctly build lazy load script tag html when asset strategy is lazy ([b1b2646](https://github.com/podium-lib/utils/commit/b1b264678fdd463eec009216a7119af1ea706ba1)) | ||
# [4.5.0](https://github.com/podium-lib/utils/compare/v4.4.42...v4.5.0) (2023-11-16) | ||
@@ -2,0 +9,0 @@ |
@@ -15,5 +15,9 @@ /* eslint-disable no-restricted-syntax */ | ||
const args = []; | ||
args.push({ key: 'src', value: obj.value }); | ||
// lazy uses dynamic import in the script body, everything else uses the src attribute | ||
if (obj.strategy !== 'lazy') { | ||
args.push({ key: 'src', value: obj.value }); | ||
} | ||
if (obj.type === 'esm' || obj.type === 'module') { | ||
// ESM and module are valid "module" types. Lazy requires type="module" so we set it here. | ||
if (obj.type === 'esm' || obj.type === 'module' || obj.strategy === 'lazy') { | ||
args.push({ key: 'type', value: 'module' }); | ||
@@ -47,3 +51,3 @@ } | ||
if (Array.isArray(obj.data) && (obj.data.length !== 0)) { | ||
if (Array.isArray(obj.data) && obj.data.length !== 0) { | ||
obj.data.forEach((item) => { | ||
@@ -74,3 +78,3 @@ args.push({ key: `data-${item.key}`, value: item.value }); | ||
}) | ||
return `<script ${attrs.join(' ')}></script>`; | ||
return `<script ${attrs.join(' ')}>${obj.strategy === 'lazy' ? `import("${obj.value}");` : ''}</script>`; | ||
}; | ||
@@ -77,0 +81,0 @@ |
{ | ||
"name": "@podium/utils", | ||
"version": "4.5.0", | ||
"version": "4.5.1", | ||
"description": "Common generic utility methods shared by @podium modules.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
54565
945