forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
947 stars 404 forks source link

LWC Extension Autocompletion Leads to "LWC1526: Invalid module id" #2615

Closed KevSlashNull closed 2 years ago

KevSlashNull commented 3 years ago

Summary

In a Lightning Web Component, trying to auto-complete an Apex method inside a project with namespace, leads to the following auto-completion:

import someMethod from "@salesforce/apex/Namspace.Class.someMethod";

However, this leads to LWC1526: Invalid module id when deploying to a scratch org. It should actually be without the Namespace prefix:

import someMethod from "@salesforce/apex/Class.someMethod";

I assume that the namespace is relevant when not developing your own package but for non-managed packages, this results in an error.

Steps To Reproduce:

  1. Be in/create a project with namespace
  2. Create an Apex method (called whatever)
  3. Create an LWC (called whatever)
  4. type import methodName from "@salesforce
  5. See the auto-completion
  6. Apply the auto-completion
  7. Push the component to a scratch org
  8. See the error LWC1526

Expected result

Autocompletion result is:

import someMethod from "@salesforce/apex/Class.someMethod";

Actual result

Autocompletion result is:

import someMethod from "@salesforce/apex/Namspace.Class.someMethod";

Additional information

VS Code Version: 1.49.3

salesforce.salesforcedx-vscode-lwc: v49.13.0

SFDX CLI Version: sfdx-cli/7.75.0-5521f40d11 darwin-x64 node-v12.18.3

OS and version: macOS 10.14.6

smaddox-sf commented 3 years ago

Logged as a work item to investigate - W-8340576

AnanyaJha commented 2 years ago

Thanks for reporting this @KevSlashNull! This should have been addressed by #3568, feel free to reopen if you see other issues