💡 [Feature]: Improve SPFx Project detection logic
🎯 Aim of the feature
The current SPFx project detection relies completely on .yo-rc.json files, which creates a couple of issues:
- Sample Gallery missing valid samples - The
prepare-sample-data.ps1script skips samples that don't have this file. The sample gallery's primary purpose is to provide developers with various real-world examples for learning and inspiration. By excluding valid SPFx projects due to this missing file, we are reducing the number of available community samples. - Extension fails to detect valid SPFx project - SPFx solutions can function without a
.yo-rc.jsonfile and still build, bundle, and package successfully using npm scripts, the SPFx Toolkit extension hides the Tasks view because it relies on this file to validate the project.
This scope of this issue is to identify key SPFx indicators that are required for all SPFx project types (WebParts, Extensions, Libraries, ACEs) and implement multi-layer SPFx detection solution.
As mentioned in the comment below, the @microsoft/sp-core-library package appears to be a consistent and mandatory dependency for all valid SPFx projects. Let's verify that all SPFx component types (Web Part, Extension, Library, ACE) consistently include this package and then proceed with updating the detection logic to use this package as the primary SPFx indicator, with current .yo-rc.json as a fallback.
files to update:
- prepare-sample-data.ps1
- CommandPanel.ts - isSPFxProject()
📷 Images (if possible) with expected result
No response
🤔 Additional remarks or comments
No response
IMO those projects are still invalid and should get fixed in the sample gallery 😉. Good argument is that you may not extend them using yo with a new component as if this file is missing it will yeoman will create a new project instead of modify the current one.
As for an alternative I would suggest to @microsoft/sp-core-library npm package version. From what I confirmed with the SPFx team this package is always aligned with project SPFx version and there are no plans to change this approach.
Also without this npm package the project will just not build so seems more like a reliable source that is required in the SPFx solution to be a valid solution (therefore bundle, package etc)
@pnp/spfx-toolkit-maintainers any other feed? IMO as first step of this task would be to recheck all possible SPFx project component types (webpart, extension etc) if they have this package in correct version for 1.21 and the current 1.22 beta and if yes I would suggest we proceed like this
agreed on call to proceed as 👆