Open
Description
Description
I've started with a Single Page Application on LWR, Able to run the app with Lightning design system and LWC base component package.
When I use <lightning-input>
tag in my component js, it breaks the compilation and when I tried to load the application I see following error on terminal along with on browser I see blank page with error on console. Also same thing happens when I tried to use any onchange event like on any of the form element fields, like textarea, checkbox etc.
Error details (copied from Terminal):
Running LWR v0.7.3 at: http://localhost:3000 | mode: dev
Watching: D:\SFDC Dev\LWR\lwr-new\lwr-project\src\layouts\main.html
Watching: D:\SFDC Dev\LWR\lwr-new\lwr-project\src\modules\example\app\app.js
Watching: D:\SFDC Dev\LWR\lwr-new\lwr-project\src\modules\example\app\app.html
Watching: D:\SFDC Dev\LWR\lwr-new\lwr-project\src\modules\example\app\app.css
Error: Transform failed with 1 error:
<stdin>:5:191: error: Syntax error "t"
at failureErrorWithLog (D:\SFDC Dev\LWR\lwr-new\lwr-project\node_modules\@lwrjs\compiler\node_modules\esbuild\lib\main.js:1224:15)
at D:\SFDC Dev\LWR\lwr-new\lwr-project\node_modules\@lwrjs\compiler\node_modules\esbuild\lib\main.js:1072:33
at D:\SFDC Dev\LWR\lwr-new\lwr-project\node_modules\@lwrjs\compiler\node_modules\esbuild\lib\main.js:568:9
at handleIncomingPacket (D:\SFDC Dev\LWR\lwr-new\lwr-project\node_modules\@lwrjs\compiler\node_modules\esbuild\lib\main.js:657:9)
at Socket.readFromStdout (D:\SFDC Dev\LWR\lwr-new\lwr-project\node_modules\@lwrjs\compiler\node_modules\esbuild\lib\main.js:535:7)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23) {
errors: [
{
detail: undefined,
location: [Object],
notes: [],
text: 'Syntax error "t"'
}
],
warnings: []
}
Error screenshot from Browser (localhost:3000)
Steps to Reproduce
- Clone the project boilerplate from here, I've created this project from my local system.
- setup the project directory and navigate to it from command line.
- Run the following command
npm install
andnpm dev run
which will run the local server on thelocalhost:3000
- Open the browser and Navigate to the
localhost:3000
see the error message on the console and terminal as mentioned. - Now for a moment remove the
<lightning-input>
tag from the component js/src/modules/example/app/app.html
and run the server again, see the error is gone.
Code Snippet
lwr.config.json
{
"lwc": { "modules": [{ "dir": "$rootDir/src/modules" },{ "npm": "lightning-base-components" }] },
"assets": [
{
"alias": "assetsDir",
"dir": "$rootDir/node_modules/@salesforce-ux/design-system/assets",
"urlPath": "/assets"
}
],
"routes": [
{
"id": "example",
"path": "/",
"rootComponent": "example/app",
"layoutTemplate": "$layoutsDir/main.html",
"bootstrap": {
"syntheticShadow": true
}
}
]
}
package.json
{
"name": "lwr-project",
"version": "0.0.1",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"clean": "rm -rf __lwr_cache__",
"dev": "lwr serve",
"start": "lwr serve --mode prod",
"start:compat": "lwr serve --mode compat",
"start:prod-compat": "lwr serve --mode prod-compat"
},
"dependencies": {
"@salesforce-ux/design-system": "^2.17.5",
"lightning-base-components": "^1.15.4-alpha",
"lwc": "2.17.0",
"lwr": "0.7.3"
},
"engines": {
"node": ">=14.15.4 <19"
}
}
Component HTML and JS
<!-- app.html -->
<template>
<div class="container">
<lightning-layout horizontal-align="center">
<lightning-layout-item padding="around-medium">
<div class="slds-text-heading_large">Sample LWC App</div>
</lightning-layout-item>
</lightning-layout>
<lightning-layout horizontal-align="center">
<lightning-layout-item padding="around-medium">
<lightning-input onchange={handleOnChange} value={inputVal} label="Enter Name"></lightning-input>
</lightning-layout-item>
<lightning-layout-item padding="around-medium">
<lightning-button label="Click Me!" onclick={handleClick}></lightning-button>
</lightning-layout-item>
</lightning-layout>
<lightning-layout horizontal-align="center">
<lightning-layout-item padding="around-medium"><div>Entered Value: {inputVal}</div></lightning-layout-item>
</lightning-layout>
</div>
</template>
// app.js
import {track,LightningElement} from 'lwc';
export default class HelloWorldApp extends LightningElement {
@track inputVal = 'Default text';
handleOnChnage(event){
this.inputVal = event.target.value;
}
handleClick(event){
this.inputVal = 'Changed By Click';
}
connectedCallback(){
//console.log('In connected callback');
}
renderedCallback(){
//console.log('In rendered callback');
}
}
Browsers Affected
All browsers, tested with Chrome, Mozilla, Edge
Version
- Node Version: v14.16.0
- OS: Windows 10
- NPM: 6.14.11
- @salesforce-ux/design-system- 2.18.1
- lightning-base-components- 1.15.4-alpha
- lwc- 2.17.0
- lwr- 0.7.3
Activity