forcedotcom / lwc-dev-server-feedback

LWC Local Development
BSD 3-Clause "New" or "Revised" License
45 stars 10 forks source link

Custom Labels don't resolve. #62

Closed daden closed 4 years ago

daden commented 4 years ago

I love the local dev server and have found it very helpful.

But I've never been able to get my custom labels to work. Here's my setup, n localdevserver.config.json:

"customLabelsFile": "labels/CustomLabels.labels-meta.xml"

In the root of the project, I created a "labels" folder and added the file "CustomLabels.labels-meta.xml." (LocalDev server does seem to be trying to read it because when I the file isn't there, it throws an error that the labels file doesn't exist.)

In that file I put the contents of a label file used internally at SF.

But when I load my components, I get a series of messages like this:

"[2K[0] [rollup] '@salesforce/label/leftNav.section_pipeline' is imported by force-app/main/default/lwc/config/leftNavConfig.js, but could not be resolved – treating it as an external dependency"

And the component throws an error like this "Unknown scope, cannot resolve dependency 'label/EssentialsListView.SortByNameAsc'"

mysticflute commented 4 years ago

Hi @daden, please check and see if the label file format matches the one for Custom Labels.

If it does match, I believe the other issue may be that custom labels resolution currently only supports the c namespace like you see here https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.create_labels. In your error message, instead of c.ref it's leftNav.ref, so it won't look to resolve that reference from the custom labels file.

no-response[bot] commented 4 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. Currently, there is not enough information provided for us to take action. Please reply and reopen this issue if you need additional assistance.

daden commented 4 years ago

@mysticflute Sorry I missed the request for more info earlier. Whether you re-open this or not, I wanted to provide a little more data.

First, oddly, the example Custom Label files in the link you sent me has a mistake. It shows a element that is closed with . I believe it is supposed to be but because of that error, I do wonder about the element (plural) that encloses a single label. Is that right?

Second, thank you for the reference to the CustomLabel format. I assume this means that SF developers are out of luck because this is not the format I use for Custom Labels. I was trying to use that format as I missed that a different format is needed.

I may play with this a little bit more and will try to let you know if I make any progress.

mysticflute commented 4 years ago

Sorry, I'm a little unclear on the mistake that you are pointing out. Can you clarify?

Support for other label file formats is not currently on the roadmap, but in any case with a little massaging of your existing files you should be able to get it to work locally. You could write a little script to convert the format if you are dealing with a lot of different files.