Manifest file references hostname value from serve.json in URL for scriptResources
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
Linux
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [ ] 💥 Microsoft Edge
- [ ] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [X] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
Docker Desktop 3.3.3 Linux container image running SharePoint Framework 1.12.1 (Node.js 14.17.0)
Describe the bug / error
In order to support testing and debugging client-side web parts in the workbench when running the SPFx developer toolchain within a container such as Docker, instructions for previous versions of SPFx required three changes:
- Adding a
hostnamevalue of0.0.0.0toconfig/serve.json. - Adding a
debugBasePathvalue ofhttps://localhost:4321inconfig/write-manifests.json. - Adding the statement
if (!spBuildCoreTasks.writeManifests.taskConfig.debugBasePath)at line 96 ofnode_modules/@microsoft/sp-build-web/lib/SPBuildRig.js(the relevant section of this file no longer exists in SPFx 1.12.1).
I believe due to the fact that the relevant section of SPBuildRig.js referenced in step 3 above no longer exists, running gulp bundle after following steps 1-2 above generates a manifest file containing the following (see attached file):
"loaderConfig": {
"internalModuleBaseUrls": [
"https://0.0.0.0:4321/dist/"
]
This leads to the following error when attempting to load the web part within either the local or hosted workbench:
[SPLoaderError.loadComponentError]: Failed to load component "b0605d1f-279b-4de4-8f73-66b694df270c" (HelloWorldWebPart). Original error: Failed to load URL 'https://0.0.0.0:4321/dist/HelloWorldWebPartStrings_en-us.js' for resource 'HelloWorldWebPartStrings' in component 'b0605d1f-279b-4de4-8f73-66b694df270c' (HelloWorldWebPart). There was a network problem. This may be a problem with a HTTPS certificate. Make sure you have the right certificate.
INNERERROR: Failed to load URL 'https://0.0.0.0:4321/dist/HelloWorldWebPartStrings_en-us.js' for resource 'HelloWorldWebPartStrings' in component 'b0605d1f-279b-4de4-8f73-66b694df270c' (HelloWorldWebPart). There was a network problem. This may be a problem with a HTTPS certificate. Make sure you have the right certificate. CALLSTACK: Error at SPLoaderError.SPError [as constructor] (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_en-us.js:38476:23) at new SPLoaderError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_en-us.js:52330:28) at Function.ff4n.ErrorBuilder.buildErrorWithVerboseLog (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_en-us.js:54879:21) at Function.ff4n.ErrorBuilder.buildLoadComponentError (https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/sp-webpart-workbench-assembly_en-us.js:54748:21) at https://localhost:4321/temp/workbench-packages/@microsoft_sp-webpart-workbench/local-workbench/chunk.systemjs-component-loader_en-us.js:1025:75
Steps to reproduce
- Install Docker Desktop and launch a container running an image configured with SPFx 1.12.1.
- Scaffold a new client-side web part, accepting all defaults from the generator.
- Add the appropriate
hostnameanddebugBasePathvalues outlined in steps 1-2 above. - Note that step 3 above can no longer be followed because the relevant section of
SPBuildRig.jsno longer exists. - Run
gulp bundleand examine the value ofloaderConfig : internalModuleBaseUrlsin the generated manifest file in thedistfolder.
Expected behavior
The generated manifest file should reference the url https://localhost:4321/dist instead of https://0.0.0.0:4321/dist in the loaderConfig : internalModuleBaseUrls.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
I'm having the same issue and came to the same conclusion as @dannyjessee. (We have to use Docker for developing/supporting multiple versions of SPFx because we don't have local admin rights on our machines.)
I also face exactly the same issue, the workaround used to work until @microsoft/[email protected], but now it's no longer possible to run the workbench with Docker on Windows, which is very problematic. It would be nice if the toolchain could be updated to properly support Docker on Windows.
FYI - Docker isn't an officially supported pattern for SPFx dev from Microsoft.
Ping @waldekmastykarz who's behind the Docker setup...
@idboyd01 said:
(We have to use Docker for developing/supporting multiple versions of SPFx because we don't have local admin rights on our machines.)
I've solved this exact thing using NVM which installs Node versions within your profile that you have admin rights to and thus, gets around this
FYI - Docker isn't an officially supported pattern for SPFx dev from Microsoft.
Ping @waldekmastykarz who's behind the Docker setup...
For what it's worth, @waldekmastykarz was the one who told me to submit the issue here.
@idboyd01 said:
(We have to use Docker for developing/supporting multiple versions of SPFx because we don't have local admin rights on our machines.)
I've solved this exact thing using NVM which installs Node versions within your profile that you have admin rights to and thus, gets around this
Hi @andrewconnell. Do you do this on Windows? I had tried nvm-windows before trying Docker, but at the time (and the docs still suggest) that Windows admin rights are needed for 'nvm install' and 'nvm use', which is why we went with Docker instead. Maybe I'm not up to date, or looking at the wrong NVM?
FYI - Docker isn't an officially supported pattern for SPFx dev from Microsoft. Ping @waldekmastykarz who's behind the Docker setup...
For what it's worth, @waldekmastykarz was the one who told me to submit the issue here.
The docs suggested Docker as an option, which is why we have been using it.
Does anyone know if there is there an officially supported option for dev that allows developing/supporting multiple SPFx versions without needing admin rights to switch between versions?
@andrewconnell, the reason I asked @dannyjessee to submit an issue here is because of the change inside SPFx. I understand the patch we've been doing in the past was a no-warranty way of doing it. I thought it would be a good idea to let the PG know of the limitation in SPFx v1.12.1 and see if there is anything that could be done to unblock folks who want to use SPFx in Docker, albeit in a different way than what we used to do in the past.
@idboyd01 said:
Do you do this on Windows?
Lately no... I use macOS. But yes, I have done this on Windows and teach it in my course. Unless something changed with the Windows port, all NVM install does is download the installer and unpack it into a folder within your profile (that you have admin rights to). NVM use just changes your PATH environment variable.
I think there is a problem with node_module/@microsoft/spfx-heft-plugins/lib/plugins/webpackConfigurationPlugin/WebpackConfigurationGenerator.js line 376.
This code is not use config/write-manifests.json debugBasePath setting.
I think there is a problem with node_module/@microsoft/spfx-heft-plugins/lib/plugins/webpackConfigurationPlugin/WebpackConfigurationGenerator.js line 376.
This code is not use config/write-manifests.json debugBasePath setting.
You are correct. Changing line 376 to the following fixes the issue:
const debugBaseUrl = `${serveConfig.https ? 'https' : 'http'}://localhost:${serveConfig.port || 4321}/dist/`;
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues