salesforce / lwc

⚡️ LWC - A Blazing Fast, Enterprise-Grade Web Components Foundation
https://lwc.dev
Other
1.6k stars 387 forks source link

Non-Function members exported in LWC module get converted to non-executable functions in Aura context #2397

Open hgebker opened 3 years ago

hgebker commented 3 years ago

Description

If you export a non-function member from an LWC-ES6-Module and then use the module in an Aura context, it gets converted into a function, which is not executable. It doesn't have its intended value and you cannot execute the "function" to get the value.

This also makes aggregation of modules to object members impossible.

If you use the module in another LWC and import it normally through the name of the named export, it works. Only the Aura context wont work due to the conversion

Steps to Reproduce

  1. Build a LWC module (base) and an extra file (specific utils) and populate it with any named exports
  2. In the base file, try to export everything from the extra file

HINT: You may also export a basic const member from the main file to view the issue

// Appears as non-executable function in Aura context
export const testMember = 'Lel';

// Both this way...
import * as sortUtils from './sortUtils';
export { sortUtils };

// ...as well as this way converts to function
export * as sortUtils from './sortUtils';

// This way works for functions, but no other member types
export * from './sortUtils';

Expected Results

The exported members have their respective values and are useable in Aura context

Actual Results

Variables or objects get converted into these strange functions and values are lost.

Browsers Affected

Tested with Chrome

Version

Additional context/Screenshots Console logging the imported LWC module in Aura (by component.find('utils')) gives: image

Console logging the sortUtils member in another LWC gives the correct output: image

uip-robot-zz commented 3 years ago

This issue has been linked to a new work item: W-9555200