Today when deploying our code base we've run into the following error:

lwc/orderGrid/orderGrid.js-meta.xml -- Error: Failed to save Lightning Component Resource 
[lwc/orderGrid/orderGrid.js] of Lightning Component Bundle [orderGrid]. 
Error: Value too long for field: Source maximum length is:131072

Looking at the size of file in question it is really bigger than 131,072 bytes. But we cannot find in documentation anything regarding limit for js file as a part of lwc component.

Can anyone point us in the right direction? Is it a real restriction or just some SF bug?

  • 1
    Are you using any rich text or long text field in your code? Oct 28 '19 at 10:03
  • @sanketkumar Yes, we are using bunch of such fields, but error is not because of them. 'Source' field mentioned in error message refers to internal SF object which is used to hold lwc code, similar to ApexClass etc. When we removed ~50 lines of code to decrease size of js file below mentioned max, it has been deployed successfully. So, definitely size limit problem, just not documented.
    – wesaw
    Oct 28 '19 at 12:49

I don't know where this is documented, but it is true that each file may not exceed 131072 characters of data; this is a limitation that a lot of people have experienced, here and elsewhere on the Internet (e.g. this git repo makes mention of it).

This is presumably because the maximum length of the database row the source is stored in is 131072 characters long. You will need to split your component into multiple, smaller components to get under this maximum limit. The design principles of LWC is that you have many smaller components that make up the large components, so this limitation makes sense from that design philosophy.

This is a per-file limit, as demonstrated in this question where the metadata file was too large. No one component should be trying to do "too much", as composition is the intended design philosophy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.