0

getting these 2 errors while deploying boatSearchResult component of lwc superbadge.

LWC1002: Error in module resolution: Error when using sourcemap for reporting an error: Can't resolve original location of error. (7:9) LWC1001: Unexpected compilation error: Unexpected token (Note that you need plugins to import files that are not JavaScript) (7:9)

any help where am doing wrong.

import { LightningElement, wire,track, api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';
import getBoats from '@salesforce/apex/BoatDataService.getBoats';
import updateBoatList from '@salesforce/apex/BoatDataService.updateBoatList';
import { publish, MessageContext } from 'lightning/messageService';
import BoatMC from '@salesforce/messageChannel/BoatMessageChannel__c';


const SUCCESS_TITLE = 'Success';
const MESSAGE_SHIP_IT = 'Ship it!';
const SUCCESS_VARIANT = 'success';
const ERROR_TITLE = 'Error';
const ERROR_VARIANT = 'error';
const columns = [
  {label:'Name', fieldName:'Name', type:'text', editable:'true'},
  {label:'Length', fieldName :'Length__c', type:'number', editable:'true'},
  {label:'Price', fieldName:'Price__c', type:'currecny', editable:'true'},
  {label:'Description', fieldName:'Description__c', type:'text', editable:'true'}
];

export default class BoatSearchResults extends LightningElement {
  
  selectedBoatId = '';
  boatTypeId = '';
  @track boats;
  isLoading = false;

  boatColumns = columns;
  @track boatDraftValues = [];
  
  // wired message context
  @wire(MessageContext)
  messageContext;

  // wired getBoats method
  @wire(getBoats, {boatTypeId : '$boatTypeId'})
  wiredBoats(result){
    if(result.data){
        this.boats = result;
    }
    this.isLoading = false;
    this.notifyLoading(this.isLoading);
   }
  
  // public function that updates the existing boatTypeId property
  // uses notifyLoading
  @api 
  searchBoats(boatTypeId){
    this.isLoading = true;
    this.notifyLoading(this.isLoading);
    this.boatTypeId = boatTypeId;
  }
  
  // this public function must refresh the boats asynchronously
  // uses notifyLoading
  async refresh(){ 
    this.isLoading = true;
    this.notifyLoading(this.isLoading);

    await refreshApex(this.boats);

    this.isLoading = false;
    this.notifyLoading(this.isLoading);
  }
  
  // this function must update selectedBoatId and call sendMessageService
  updateSelectedTile(event){
    this.selectedBoatId = event.boatId;
    this.sendMessageService(this.selectedBoatId);
  }
  
  // Publishes the selected boat Id on the BoatMC.
  sendMessageService(boatId){ 
    // explicitly pass boatId to the parameter recordId
    const payload = {recordId : boatId};
    publish(this.messageContext, BoatMC, payload);
  }
  
  // The handleSave method must save the changes in the Boat Editor
  // passing the updated fields from draftValues to the 
  // Apex method updateBoatList(Object data).
  // Show a toast message with the title
  // clear lightning-datatable draft values
  handleSave(event){
    // notify loading
    this.boatDraftValues = event.detail.draftValues;
    const updatedFields = event.detail.draftValues;
    // Update the records via Apex
    updateBoatList({data: updatedFields})
    .then(() => {
      this.dispatchEvent(
        new ShowToastEvent({title : SUCCESS_TITLE, message : MESSAGE_SHIP_IT, variant : SUCCESS_VARIANT})
      );
      this.boatDraftValues = [];
      return this.refresh();
    })
    .catch(error => {
      this.dispatchEvent(
        new ShowToastEvent({title : ERROR_TITLE, message : error.body.message, variant : ERROR_VARIANT})
      );  
    })
    .finally(() => {
      this.boatDraftValues = [];
    });
  }
  
  // Check the current value of isLoading before dispatching the doneloading or loading custom event
  notifyLoading(isLoading){ 
    if(isLoading){
      this.dispatchEvent(new CustomEvent('loading'));
    }else{
      this.dispatchEvent(new CustomEvent('doneloading'));
    }
  }
}
2
  • 1
    This complains about line number 7 where you import @salesforce/messageChannel/BoatMessageChannel__c, I think the messaging channel (BoatMessageChannel__c) is not deployed correctly. Please verify that.
    – Raul
    Commented Jul 30, 2021 at 13:39
  • 1
    @Raul, MessageChannel got deployed successfully...but when i deploy package.xml file, getting same error again. Commented Jul 30, 2021 at 14:10

1 Answer 1

0

I took your code and tried to deploy to a dev org. It got deployed. I deployed the message channel and apex class first and then the lwc folder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .