Open rahulgawale opened 7 months ago
Thanks for reporting! I've notified the LWR team (LWR is not hosted in this repo, which is for the the LWC open-source framework).
Do you get the same error in WSL? The stacktrace you provide seems to be from raw Windows (cmd.exe or some other terminal I assume).
@nolanlawson Yes I am getting a similar error in WSL too. Added the stack trace from WSL to the Actual Results [WSL]
section. The build works just fine until I add the Lightning Base Components and SLDS. The problem occurs as soon as I add these two.
Also Is there a separate public repo for lwr? If yes please drop in the link because I couldn't find one.
Response from Salesforce support: "LWR is not supported on Windows." 🙃
@forcePanda What is supported then? it also doesn't work on Linux. Just curious, Did you raise a case for this?
Response from support:
Engineering has logged this as a bug and for now, it looks like it will only work on mac os. https://issues.salesforce.com/issue/a028c00000yx5yH/lwr-build-is-not-working-in-both-wsl-and-windows
@forcePanda Thanks for the update, I hope it will be fixed soon. At least it should work on Linux.
@rahulgawale it should work on linux / mac osx, can you confirm you are hitting the same error stack trace on linux?
@forcePanda @rahulgawale if either of you could share your actual github repositories with me (or an example repository that replicates the issue) - I will take a look at it
@nrkruk Thanks, I tried to run my code in Mac OSX and it works, but not everyone in our team has that. I have to set up Linux on my machine, once done I will try that out, also I will share the repository tomorrow. Thank you very much for looking into this.
@nrkruk the build works on Linux but there is an exception. The linux build output fails to show slds icons that are used in lwc base components.
Mac OS works fine for all the scenarios I've come across.
@nrkruk Here is the repo with the sample code. - https://github.com/rahulgawale/lwr-site-demo
Please note that I have not added the SLDS assets in the repo, which you can copy from the node module as per the docs - Set up Salesforce Lightning Design System
Screenshot of my assets folder for your reference.
As said by @forcePanda build works on Linux with an exception of icons not showing. There are some warnings when npm run build
command is executed. See the command output below.
rahul@rahul-ubuntu:~/Public/lwr-site-demo$ npm run build
> lwr-site-demo@0.0.1 build
> lwr build --clean
[info][build] Building lwr application
[info][build] Clearing output directory: site
[info][ssg] Static Site Generation
[info][ssg] Building routes (this may take some time to complete)
[info][ssg] en-US / in 732 ms
[warn][ssg] Could not find assets to copy at path: /home/rahul/Public/lwr-site-demo/site/fonts
[warn][ssg] Could not find assets to copy at path: /home/rahul/Public/lwr-site-demo/site/lightning.utilitySprite
[warn][ssg] Could not find assets to copy at path: /home/rahul/Public/lwr-site-demo/site/lightning.standardSprite
[info][ssg] Static Site Generation complete in 2 seconds
rahul@rahul-ubuntu:~/Public/lwr-site-demo$
I would also like to bring it to your attention that there is a bug in the documentation - i.e. (https://developer.salesforce.com/docs/platform/lwr/guide/lwr-slds.html?q=styles#set-up-salesforce-lightning-design-system)
The copy-slds.mjs
code does not work at all. It gets executed but does not copy the assets from node module to /src/assets
folder, so you have to do that manually.
Also the package.json
snippet has syntax error, see below.
There are two (`) back ticks, which are not needed.
{
"scripts": {
"build": "`node ./scripts/copy-slds.mjs"`
}
}
Removed the back ticks.
{
"scripts": {
"build": "node ./scripts/copy-slds.mjs"
}
}
Also another issue with the docs is that the commands are not consistent, some pages use npm
to run commands but some pages use yarn
so it is kind of confusing. Wondering if package manager has anything to do with the error? Because I am using npm
.
@nrkruk did you get any chance to look into this?
Thanks for reporting! I've notified the LWR team (LWR is not hosted in this repo, which is for the the LWC open-source framework).
@nolanlawson What is the correct way of addressing issues for LWR? Making an issue here? I have been working several months on a website with LWR and sometimes I find bugs that I end up having to solve locally in the files. Sometimes it seems very weird that these things everyone should have issues with persist. Like for example right now I'm stuck with a bug with modals that don't open because isOverlayAllowedToAdd rejects which is caused by the class being imported twice in 2 different bundles
@juvian All I can say is that this repo is only concerned with the open-source LWC framework, not with LWR. LWR is currently closed-source, and there is no equivalent GitHub repo we can move this issue to.
If you remain blocked, I would recommend opening a Salesforce Stack Exchange question or a Salesforce case.
@rahulgawale - I did take a look, and there are definitely some path resolution issues we need to fix on windows. I'm working on getting that prioritized with the team but I don't have a definitive timeline on when that will be fixed for you.
You are correct in that the documentation is wrong here. If you fix the paths in the script, it will copy the assets as expected:
cpx.copy('./node_modules/@salesforce-ux/design-system/assets/**/*', './src/assets', () => {
console.log('Done copying SLDS resources');
});
It also appears that the lightning sprites and the /font directory are not included in the ux design system package, so will need to check on what the correct steps are for those assets. I've filed a bug on our doc team.
What package manager you use doesn't matter as far as LWR is concerned, both npm and yarn will work fine.
I got it to work on windows months ago (at least development mode, prod doesn't work) by changing these files
@lwrjs\asset-registry/build/cjs/index.cjs
async delegateGetAsset(assetIdentifier) {
if (assetIdentifier.specifier.includes('\\') && assetIdentifier.specifier.includes('assets')) {
assetIdentifier.specifier = assetIdentifier.specifier.replaceAll('\\', '/').replaceAll('//', '/');
}
@lwrjs\module-registry\build\cjs\linker\linker.cjs
let link = strategy(importRef, runtimeEnvironment, runtimeParams, signature);
// replace all locations of importee with the link
if (link.includes('\\utils') || link.includes('lightning_iconSvgTemplatesUtility')) {
link = link.replaceAll('\\', '#');
}
@lwrjs\module-registry\build\cjs\index.cjs
resolveModuleUriSync
if (moduleId.specifier.includes('#')) {
return uri.replaceAll('\\', '_');
}
@juvian Thanks for the workaround, I have been using your workaround hoping that someday it will be fixed. Kept using it in dev mode, but now I need to build and deploy my site. At least I expected this to work properly on Linux, but that is not the case either. Honestly, LWC OSS is a great framework but it does not provide any trustworthy build mechanism for Windows, I have also tried to use Webpack and Rollup but that didn't work either.
@nolanlawson Could you provide any alternative way to build static LWC OSS site? Maybe using Webpack or Rollup? Something similar to create-lwc-app
@rahulgawale LWR is our recommended path forward. However we do ship a Rollup plugin and webpack plugin, but it's not a batteries-included meta-framework. create-lwc-app
is deprecated.
@nolanlawson I hope you are doing great! Just wanted to check if any update on the fix for the issue. Thanks
Description
Steps to Reproduce
lwr.config.json
Package.json
Expected Results
lwr build command should generate static site in the
site
folder.Actual Results [Windows]
build command runs into error.
Actual Results [WSL]
Browsers Affected
Version
Node v20.11.0
Additional info
The
npm run dev
also renders the site very slow. Everything just works fine until you add lightning-base components. Please provide a working sample that works on Windows. I tried using rollup but that is also a running issue.Possible Solution
Additional context/Screenshots Add any other context about the problem here. If applicable, add screenshots to help explain.