Note: Checking this potential duplicate didn't help.
I have a project which uses SFDX and LWC and recently converted it to have a namespace (later it should become a Managed Package). I successfully recreated the scratch org and pushed my yet unprefixed code to it:
I then added the namespace to my import
statements
import { LightningElement, api, track } from "lwc";
import getAccounts from "@salesforce/apex/MyCtrl.getAccounts";
export default class AccountList extends LightningElement {
...
}
Now all Apex calls from LWC js are failing with:
apex://myns.MyCtrl: No apex action available for myns.MyCtrl.getAccounts
When I add the namespace to my import
statements:
import { LightningElement, api, track } from "lwc";
import getAccounts from "@salesforce/apex/myns.MyCtrl.getAccounts";
export default class AccountList extends LightningElement {
...
}
I get a compile-time error stating:
Error:(1, 1) LWC1504: Invalid module id "myns.MyCtrl.getAccounts" for type "apexMethod". Explicit use of namespace "myns" in file "accountList.js" is prohibited. Use default namespace "c" instead.
- Did something go wrong with my scratch org?
- I can see the namespace being active in there. It's on all the classes?
- I expected to not have to explicitly mention namespace in a namespace org!?