Migration guide for @uploadcare/file-uploader v1.0.0 to v1.2.0
Migrate to v1.2.0 with one prompt
BREAKING CHANGES
- The package name
@uploadcare/blockshas been renamed to@uploadcare/file-uploader. - The prefix
lr-has been replaced withuc-in all custom elements. - The prefix
lr-has been replaced withuc-in all attributes. - The key
LR_WINDOW_KEYhas been renamed toUC_WINDOW_KEY, and the global name of the IIFE bundle isUCinstead ofLR. - The path
./blocks/themes/lr-basic/*has been changed to./blocks/themes/uc-basic/*. - Bundle
blocks.min.jsis renamed tofile-uploader.min.js. - Bundle
blocks.iife.min.jsis renamed tofile-uploader.iife.min.js. - The method
registerBlockshas been renamed todefineComponents. - The method
connectBlocksFromhas been renamed toloadFileUploaderFrom. - The adaptive image tag
lr-imgis renamed touc-img, and its CSS properties--lr-img-*to--uc-img-*.
Note: Four of these renames shipped in v1.2.0: file-uploader.min.js,
file-uploader.iife.min.js, defineComponents and loadFileUploaderFrom. If you
pin v1.0.x or v1.1.x, keep the old names: blocks.min.js, blocks.iife.min.js,
registerBlocks and connectBlocksFrom.
How to migrate
Rename npm package
First, uninstall the old package:
Next, install the new package:
Rename imported JS and CSS bundles
Rename all the imports according to the following table:
For example:
Rename lr to uc in every custom element
Update all instances of lr- to uc- in your custom elements. For example:
Rename lr to uc in every HTML attribute
All attributes that used to be rendered with the LR prefix are now UC.
The uc-* attribute will always be added to the tag itself.
We’ve started using attribute selectors instead of tag selectors to enable styles to
be attached to custom extended elements.
For example:
Before:
After:
Update Global Name in IIFE
If you have been using an IIFE, the window object must now be accessed with the key UC instead of LR.
Rename blocks.min.js to file-uploader.min.js
If you used the blocks.min.js bundle, rename it to
file-uploader.min.js as follows:
Rename blocks.iife.min.js to file-uploader.iife.min.js
If you used the blocks.iife.min.js bundle, rename it to
file-uploader.iife.min.js as follows:
Rename registerBlocks to defineComponents
If you have installed the File Uploader using *.min.js bundles, you will need to manually call defineComponents as follows:
Rename connectBlocksFrom to loadFileUploaderFrom
The method connectBlocksFrom was renamed to loadFileUploaderFrom: