Skip to main content Join the Agentforce Virtual Hackathon to build innovative solutions and compete for a $50k Grand Prize. Sign up now. Terms apply.

#LWR Node0 debatiendo

This topic is for discussing LWR running on Node.js

Im getting this error on heroku when a deploy the app, but in localhost is work fine, this is my lwr.config.json

 

{

    "lwc": { "modules": [{ "dir": "$rootDir/src/modules" },{ "npm": "lightning-base-components" }] },

    "bundleConfig": { "exclude": ["lwc"] },

    "routes": [

        {

            "id": "home",

            "path": "/",

            "rootComponent": "example/app",

            "layoutTemplate": "$layoutsDir/main.html",

            "bootstrap": {

                "syntheticShadow": true

            }

        }

    ]

}

4 respuestas
0/9000

I'd like to use the lwc:spread directive for a component in an LWR project (not in Communities, just an off-platform site). The doc says that this feature needs to be enabled using the enableLwcSpread compiler option.

 

I have added this option to the lwc section in lwr.config.js but when I run the site it throws an error "CompilerError: LWC1154: Invalid lwc:spread usage. The `lwc:spread` directive must be enabled in order to use this feature."

 

Is this feature supported in LWR? If so, then how do I enable it?

 

#LWR #LWR Node

3 respuestas
0/9000

Hello there!

 

One of our projects is a single page app, which we decided to build with LWR. The app has two levels of navigation, for simplicity let's call them "objects" and "records". Following the guidance in the LWR docs, I created a top level (outer) router for navigating between different objects, and a nested (inner) router for opening records within those objects. The inner page handler is configured with `exact: false` in the outer router for dynamic URL matching (record ids). Client-side navigation is also backed-up by server-side navigation to support reloads, but that is beside the point.

 

The URI format looks like this: /objectName/:recordId, with the recordId being passed via page reference attributes.

 

The issue is that I cannot get past the inner route handler in production mode, even though it works in development mode. The inner router is instantiated but does not open the inner view page.

 

I was able to replicate this issue using the example app described in the LWR documentation. I added navigation buttons to all example pages and logged class constructions and navigation attempts. The last log entry was "Constructed example/animalPageHandler".

 

I enabled stopping on all errors and got an exception navigating from the Home page to the Animal Home page: "Error: Adapter already has a context provider." thrown inside bundle_lwc.js module. This does not happen in development mode! I tried debugging the minified code but to no success.

 

Is that a known issue? Am I doing anything wrong? Is this even the right group to ask such questions?

 

Thank you!

9 respuestas
  1. 25 ene 2023, 9:18 p.m.

    @Aleksei Murashin

     

    I tracked this down to a new bug (thank you!)

     

    For now you can workaround it by adding this to your `lwr.config.json`:

     

        "bundleConfig": {

            "exclude": ["lwr/domRouter"]

        },

0/9000

For example, can I reuse media-chrome in LWC ?

https://github.com/muxinc/media-chrome : look for "Bundled with npm"

 

 Here is my failing example in an LWR Node app :

<!-- player.html -->

<template>

<media-controller>

<video

slot="media"

src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/high.mp4"

></video>

</media-controller>

</template>

 

// player.js

import { LightningElement,api } from 'lwc'

import 'media-chrome'

export default class Player extends LightningElement {}

 

yarn add media-chrome

yarn dev

 

Error :

[ERROR]resolveNpmModules(esbuild): {

specifier: 'media/controller',

dest: '/Users/rupert/.../myapp/__lwr_cache__/web_modules'

}

LwrUnresolvableError [DiagnosticsError]: 404: Could not find module entry with specifier "media/controller"

at createSingleDiagnosticError (file:///Users/rupert/.../myapp/node_modules/@lwrjs/diagnostics/build/es/errors.js:6:12)

at LwrModuleRegistry.delegateGetModuleEntryOnServices (file:///Users/rupert/.../myapp/node_modules/@lwrjs/module-registry/build/es/index.js:217:15)

at runMicrotasks (<anonymous>)

at processTicksAndRejections (internal/process/task_queues.js:93:5)

at async resolveExternalImport (file:///Users/rupert/.../myapp/node_modules/@lwrjs/module-registry/build/es/module-record.js:39:35)

at async getModuleRecord (file:///Users/rupert/.../myapp/node_modules/@lwrjs/module-registry/build/es/module-record.js:80:44)

at async LwrModuleRegistry.createModuleDefinition (file:///Users/rupert/.../myapp/node_modules/@lwrjs/module-registry/build/es/index.js:106:30)

at async LwrModuleRegistry.getLinkedModule (file:///Users/rupert/.../myapp/node_modules/@lwrjs/module-registry/build/es/index.js:134:27)

at async file:///Users/rupert/.../myapp/node_modules/@lwrjs/core/build/es/middlewares/api-middleware.js:206:31

at async file:///Users/rupert/.../myapp/node_modules/@lwrjs/server/build/es/express/express-server.js:59:13 {

_memoMessage: undefined,

_message: '404: Could not find module entry with specifier "media/controller"',

diagnostics: [ { description: [Object] } ]

}

Watching: /Users/rupert/.../myapp/src/modules/my/player/player.html

 

It's obvious : LWC/LWR does not know how to load the media-controller component.

How do I achieve this ?

 

#LWR Node

#LWC

2 respuestas
  1. 27 abr 2022, 12:47 p.m.

    If it's an LWC package, you need to add it as a module in your lwr.config,json config file if you want to use the components, as shown in the doc:

    // lwr.config.json

    {

    "lwc": {

    "modules": [

    { "dir": "$rootDir/src/modules" },

    { "npm": "media-chrome" }

    ]

    }

    }

0/9000

It would be great to manage push notifications, offline, etc. with LWR (Lightning Web Runtime) Node.

 

How are we meant to use Service Workers with LWR Node ? 

Anything special ?

 

@Lightning Web Components

#LWR Node

1 respuesta
0/9000

I initially posted my question in the Lightning Components Development group. The issue I have is that in a single-page app with two levels of client-side navigation (outer router and inner router) I can't get past the inner route handler because of an exception: "Error: Adapter already has a context provider.".

 

I followed the example in LWR docs to create a simplified reproduction of the problem. In that app, I could not get past the `example/animalPageHandler` to render the inner view.

 

As suggested in the other thread, I added "lwc" and "lwr/navigation" modules to the exclude list in the build config, and yet I still stuck.

 

What else am I missing?

 

Thank you!

 

#LWR Node

2 respuestas
  1. 20 ene 2023, 3:11 p.m.

    @Trevor Krieg, I'm using "lwr/router" to handle client-side navigation. The "Lightning Component Router" third-party library you mentioned seems to be made for Aura component. Or is there another router I'm not aware of?

0/9000
4 respuestas
  1. 18 nov 2022, 9:06 a.m.

    For future reference, here is the answer :

    nunjucks '**/*.xml'  -p templatesdir -e xml configdata.json -o outputdir

    This transforms all the XML template files in the templatesdir folder hierarchy, using json parameters stored in configdata.json, into the same files in the outputdir folder.

0/9000

When using LWR OSS, I'm running npm run dev as stated in the doc, however I don't see any built files.

When I was using create-lwc-app (deprecated), I could see all file under dist folder.

Is there any build command or build folder where files would be created ?

 

#LWR #LWR Node #LWR Node.js

4 respuestas
  1. 19 sep 2022, 12:47 p.m.

    For anyone interested, have a look to the answers here and here

0/9000

In the Lightning Web Runtime OSS documentation, in the "Use Module Providers" section, I can see "Your application components can now statically import labels sourced from JSON files in your project’s $rootDir/src/labels directory".

 

I wasn't able to find which format is expected. Is there a more detailed documentation somewhere (like, should I care about namespace or language), or anyone has a sample JSON file so that I know what's expected ? 

 

Thanks !

2 comentarios
  1. 12 sep 2022, 8:47 p.m.

    Answering to myself, here is what seems to works. But I don't really know if it's supposed to work like this or could break at anytime as it's not really documented (especially language support).

    Put another way, I don't know if LWR OSS documentation is not enough documented and should explain how it works (just missing time or resources to do it), or maybe too documented and should mention this 🤷🏻‍♂️

    Answering to myself, here is what seems to works. But I don't really know if it's supposed to work like this or could break at anytime as it's not really documented (especially language support).

0/9000
2 respuestas
  1. 1 oct 2021, 5:29 a.m.

    Hello,

     

    Make navigating your site on a mobile device simple with tabbed menus. The tabs are always displayed at the bottom of the screen, making navigation quick and easy (and even one-handed) on your mobile publisher apps.

    This change applies to Aura, LWR, and Visualforce sites accessed mobile publisher apps in Enterprise, Performance, Unlimited, and Developer editions.

     

    Details:

    https://help.salesforce.com/s/articleView?id=release-notes.rn_experiences_tabbed_mobile_menu.htm&type=5&release=232

     

    Thanks

0/9000