salesforcecli / plugin-lightning-dev

Local development tools for LEX, Mobile, and Experience Sites
BSD 3-Clause "New" or "Revised" License
7 stars 8 forks source link

Live-Reload Fails to Update Child Components with Dynamic Imports in Salesforce LocalDev for Experience Sites #231

Open BradyNadeau opened 3 weeks ago

BradyNadeau commented 3 weeks ago

Summary

Live-reload functionality in Salesforce LocalDev does not refresh child components when the main component published to an Experience Website uses dynamic imports. Specifically, if a component is dynamically imported (e.g., import('c/dynamicComponent')), any changes made to the dynamically imported child component (or any other non-dynamically imported child component) are not recompiled or published as expected during live-reload.

Steps To Reproduce:

  1. Set up a main component (WebsiteMain) that dynamically imports child components using import('c/childComponent').

  2. Publish the main component to an Experience Website and initiate live reload using the command: sf lightning dev site --target-org dev --name "MyWebsite"

  3. Make a change to the dynamically imported child component, or any other child component (e.g., childComponent).

  4. Observe that live reload does not pick up changes made to any child component.

Expected Result

When a change is made to any child component and the parent utilizes a dynamically imported component, live-reload should refresh and apply the changes across all relevant components, including any dynamically imported child components.

Actual Result

Live-reload does not detect or apply changes made to any child components other than the main component that utilizes the main site. All child components (even those that are not dynamically imported) appear to remain unaffected by these changes during live-reload.

Additional Information

Code Sample Here’s an example of the WebsiteMain component, illustrating the dynamic import setup:

import { CurrentPageReference } from 'lightning/navigation';
import { LightningElement, track, wire } from 'lwc';

export default class WebsiteMain extends LightningElement {
    @track currentPage = null; // Current page's object
    @track dynamicComponent = null; // Holds the dynamically imported component constructor

    myDynamicPages = [
        {
            id: 1,
            name: "Basic Information",
            path: "BasicInformation",
            component: () => import('c/childComponent'),
            showPageNavbar: false
        }, ...
    ];
}

    async loadComponent(page) {
        const componentModule = await page.component();
        this.dynamicComponent = componentModule.default;
    }

Screenshots:

None

Logs:

No logs are created (even when DEBUG=* is set) when modifying a child component with dynamic imports utilized.

System Information

SF CLI:

{
  "architecture": "win32-x64",
  "cliVersion": "@salesforce/cli/2.63.8",
  "nodeVersion": "node-v20.17.0",
  "osVersion": "Windows_NT 10.0.22635",
  "rootPath": "C:\\Users\\BradyNadeau\\AppData\\Local\\sf\\client\\2.63.8-fbf82e0",
  "shell": "cmd.exe",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.6 (core)",
    "@oclif/plugin-commands 4.1.3 (core)",
    "@oclif/plugin-help 6.2.15 (core)",
    "@oclif/plugin-not-found 3.2.22 (core)",
    "@oclif/plugin-plugins 5.4.15 (core)",
    "@oclif/plugin-search 1.2.12 (core)",
    "@oclif/plugin-update 4.6.4 (core)",
    "@oclif/plugin-version 2.2.15 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.19 (core)",
    "@oclif/plugin-which 3.2.16 (core)",
    "@salesforce/cli 2.63.8 (core)",
    "apex 3.5.4 (core)",
    "api 1.3.1 (core)",
    "auth 3.6.68 (core)",
    "data 3.7.1 (core)",
    "deploy-retrieve 3.15.3 (core)",
    "info 3.4.12 (core)",
    "lightning-dev 1.9.0 (user) published 19 days ago (Fri Oct 11 2024)",
    "limits 3.3.33 (core)",
    "marketplace 1.2.26 (core)",
    "org 4.7.0 (core)",
    "packaging 2.8.12 (core)",
    "schema 3.3.36 (core)",
    "settings 2.3.24 (core)",
    "signups 2.5.23 (user) published 17 days ago (Sat Oct 12 2024)",
    "sobject 1.4.42 (core)",
    "source 3.5.21 (core)",
    "telemetry 3.6.16 (core)",
    "templates 56.3.24 (core)",
    "trust 3.7.34 (core)",
    "user 3.5.33 (core)"
  ]
}

OS:

Experience Sites Only:

{
  "orgId": "00D7X000000URjZ",
  "siteId": "0DMOt0000004igo",
  "clwrVersion": "252.131",
  "coreVersion": "252.11",
  "coreChangelist": "49784824",
  "bundleGenerationDate": "Oct 30, 2024 10:47:36 PM",
  "siteTemplateName": "talon-template-byo",
  "deployTarget": "CORE"
}
git2gus[bot] commented 2 weeks ago

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