Comments (4)
Hey @vvision 👋
Good news. It's not a bug. It's a feature.
First of all, Liquid should not be external: You want to include the component code in your bundle. => You should remove the external config option.
Now, with Liquid 4.6.0, lots of chunks, which are actually never loaded in the browser, end up in your dist folder. So, why is the tree-shaking not working? Well, it kind of is working, because Rollup figures that all chunks are needed eventually, and the chunks are loaded in the browser only when needed. So why does Rollup "assume" that all chunks are needed? This is related to the includeDefineCustomElements
option of the react output target!
Since liquid v4.6.0 the includeDefineCustomElements
option set to true
. With the includeDefineCustomElements
option set to true
, you don't need to define the custom elements from liquid react yourself. The custom elements get registered with the Custom Elements Registry as soon as imported. We didn't see this as a breaking change, because calling the defineCustomElements
helper method manually would not break anything, even if the elements were already defined.
However things get tricky, when bundling liquid components into another library:
With the includeDefineCustomElements
option set to true
, the react.js and vue.js files within liquid import the defineCustomElements
helper and execute it. The defineCustomElements
helper imports the bootstrapLazy
helper which in turn includes dynamic import statements for all components. Now, a bundler cannot know, which component will be lazy loaded eventually, so it includes all components as chunks into the bundle. The app that consumes the library can load only what's needed, but the bundle is still unnecessary big, including all Liquid components, even if not used.
In order to solve this issue, we have added additional entry points to the output targets, which do not include the defineCustomElements
helper utility. This allows you to manually register custom elements on a as-needed basis, and fixes issues with the bundling, because dynamic imports are not used in the code. How to use this new feature is documented under Manually defining custom elements.
TLDR:
import { LdButton, LdTypo } from '@emdgroup-liquid/liquid/dist/react-define-excluded'
Please note that the feature is available in the newest version of Liquid. There is a major version bump which you need to take care of, but it should be really straight forward, as the breaking change in v5 is only relevant for a very special use case of liquid.
Let me know if something is still not working for you. 🤓
from liquid.
🎉 This issue has been resolved in version 5.5.0 🎉
The release is available on:
📦🚀
from liquid.
Hey @borisdiakur 👋,
Thanks for all the explanations and the great work.
I've implemented the proposed solution and it works flawlessly !
Many thanks from our team.
from liquid.
@vvision Thanks for submitting this issue and putting so much effort in it. 🙏
I'm looking into it. It's a tricky one. 😬
from liquid.
Related Issues (20)
- bug: some elements report a 0x0 bounding box in playwright / inspector HOT 1
- Placeholder of LdSelect HOT 1
- bug: table is not accessible via VoiceOver
- bug: Very long LdPagination size increases parents container width HOT 6
- bug: event handlers not called in ld-tooltip HOT 1
- bug: ld-tooltip causes "Failed to execute 'removeChild' on 'Node'" HOT 1
- bug: onClick handler not called on LdMenuitem HOT 2
- feat(ld-cookie-notice): apply requirements from legal HOT 1
- bug: LdTabs inside LdSidenav moves content on changing tab index HOT 1
- feat: ld-card without padding
- bug: LdSelect with filter doesn't always get focus HOT 1
- feat: add download attribute for LdLink HOT 2
- bug: https://downgit.github.io reports "harmful programs" HOT 1
- feat(ld-sidenav-navitem): add support for secondary label
- feat: grouping feature to the Select component HOT 2
- improvement: Refactor ld-select.tsx as it's almost 1,500 lines big now
- bug: ld-sidenav-navitem text overflows container in single line mode
- bug: Placeholder of ld-input is too dark HOT 1
- bug: LdInput readonly bind on boolean value are still editable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liquid.