Skip to content

Commit

Permalink
feat: Added Backward compatibility for build
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Didenko committed Jul 15, 2024
1 parent 684c358 commit 341e5e5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 5 deletions.
16 changes: 13 additions & 3 deletions abstract/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { sharedConfigKey } from './sharedConfigKey.js';
import { A11y } from './a11y.js';

const TAG_PREFIX = 'uc-';
const LEGACY_TAG_PREFIX = 'lr-';

// @ts-ignore TODO: fix this
export class Block extends BaseComponent {
Expand Down Expand Up @@ -326,13 +327,22 @@ export class Block extends BaseComponent {
console.log(`[${this.ctxName}]`, ...consoleArgs);
}

/** @param {String} [name] */
static reg(name) {
/**
* @param {String} [name]
* @param {Boolean} [isAlias]
*/
static reg(name, isAlias = false) {
if (!name) {
super.reg();
return;
}
super.reg(name.startsWith(TAG_PREFIX) ? name : TAG_PREFIX + name);
if (name.startsWith(TAG_PREFIX)) {
super.reg(name.startsWith(TAG_PREFIX) ? name : TAG_PREFIX + name, isAlias);
}

if (name.startsWith(LEGACY_TAG_PREFIX)) {
super.reg(name.startsWith(LEGACY_TAG_PREFIX) ? name : LEGACY_TAG_PREFIX + name, isAlias);
}
}
}

Expand Down
15 changes: 13 additions & 2 deletions abstract/registerBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ export function registerBlocks(blockExports) {
if (tagName.startsWith('-')) {
tagName = tagName.replace('-', '');
}

let currentTagName = '';
if (!tagName.startsWith('uc-')) {
tagName = 'uc-' + tagName;
currentTagName = addPrefix('uc-', tagName);
}

let legacyTagName = '';
if (!tagName.startsWith('lr-')) {
legacyTagName = addPrefix('lr-', tagName);
}

if (blockExports[blockName].reg) {
blockExports[blockName].reg(tagName);
blockExports[blockName].reg(currentTagName);
blockExports[blockName].reg(legacyTagName, true);
}
}
}

const addPrefix = (prefix, name) => prefix + name;
67 changes: 67 additions & 0 deletions build-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,71 @@ export const buildItems = [
minify: true,
minifyHtml: true,
},

// @TODO eadidenko, Delete after a few releases
// Legacy
{
in: './blocks/themes/uc-basic/index.css',
out: './web/lr-basic.min.css',
minify: true,
},
// uc-cloud-image-editor
{
in: './solutions/cloud-image-editor/index.js',
out: './web/lr-cloud-image-editor.min.js',
minify: true,
minifyHtml: true,
},
{
in: './solutions/cloud-image-editor/index.css',
out: './web/lr-cloud-image-editor.min.css',
minify: true,
},

// file-uploader-regular
{
in: './solutions/file-uploader/regular/index.js',
out: './web/lr-file-uploader-regular.min.js',
minify: true,
minifyHtml: true,
},
{
in: './solutions/file-uploader/regular/index.css',
out: './web/lr-file-uploader-regular.min.css',
minify: true,
},

// file-uploader-inline
{
in: './solutions/file-uploader/inline/index.js',
out: './web/lr-file-uploader-inline.min.js',
minify: true,
minifyHtml: true,
},
{
in: './solutions/file-uploader/inline/index.css',
out: './web/lr-file-uploader-inline.min.css',
minify: true,
},

// file-uploader-minimal
{
in: './solutions/file-uploader/minimal/index.js',
out: './web/lr-file-uploader-minimal.min.js',
minify: true,
minifyHtml: true,
},
{
in: './solutions/file-uploader/minimal/index.css',
out: './web/lr-file-uploader-minimal.min.css',
minify: true,
},

// uc-img
{
in: './solutions/adaptive-image/index.js',
out: './web/lr-img.min.js',
minify: true,
minifyHtml: true,
},
];

0 comments on commit 341e5e5

Please sign in to comment.