@veloceapps/sdk 8.0.0-175 → 8.0.0-177
Sign up to get free protection for your applications and to get access to all the features.
@@ -1668,22 +1668,26 @@ const vendorMap = {
|
|
1668
1668
|
lodash: lodash,
|
1669
1669
|
};
|
1670
1670
|
|
1671
|
-
const importRegexp = new RegExp(`import
|
1671
|
+
const importRegexp = new RegExp(`import\\s+(?:{[^{}]+}|.*?)\\s*(?:from)?\\s*['"].*?['"]|import\\(.*?\\)`, 'g');
|
1672
|
+
const importPartsRegexp = new RegExp(`import ([\\n\\t]*(?:[^ \\n\\t\\{\\}]+[ \\n\\t]*,?)?(?:[ \\n\\t]*\\{(?:[ \\n\\t]*[^ \\n\\t"'\\{\\}]+[ \\n\\t]*,?)+\\})?[\\n\\t]*) from[ \\n\\t]*(['"])([^'"\\n]+)(?:['"])`, 'g');
|
1672
1673
|
const normalizeImports = (script, elementPath) => {
|
1673
|
-
|
1674
|
-
|
1675
|
-
.trim()
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1674
|
+
return script.replace(importRegexp, match => {
|
1675
|
+
return match.replace(importPartsRegexp, (_, g1, __, src) => {
|
1676
|
+
const strObj = g1.replace(/ as /g, ': ').trim();
|
1677
|
+
const imports = strObj
|
1678
|
+
.slice(1, -1)
|
1679
|
+
.split(',')
|
1680
|
+
.map(item => item.split(':')[0])
|
1681
|
+
.filter(isDefined)
|
1682
|
+
.map(item => item.trim());
|
1683
|
+
imports.forEach(item => {
|
1684
|
+
if (!vendorMap[src]?.[item]) {
|
1685
|
+
throw new Error(`Failed to import ${item} from '${src}' in ${elementPath}/script.ts`);
|
1686
|
+
}
|
1687
|
+
});
|
1688
|
+
return `const ${strObj} = vendor['${src}'];`;
|
1683
1689
|
});
|
1684
|
-
return `const ${g1} = vendor['${src}'];`;
|
1685
1690
|
});
|
1686
|
-
return result;
|
1687
1691
|
};
|
1688
1692
|
const getScriptClass = (metadata) => {
|
1689
1693
|
if (!metadata?.script) {
|