Allow Extensions to use .force_overrides @@W-18216861@@ #2380
Allow Extensions to use .force_overrides @@W-18216861@@ #2380bendvc merged 10 commits intofeature/extensibility-v2from
.force_overrides @@W-18216861@@ #2380Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
vmarta
left a comment
There was a problem hiding this comment.
I've test-driven the PR and could see the app extension doing a force override successfully as described.
| // Lets use the compiler configuration to ensure we are resolving the correct file extensions. | ||
| const compilerOptions = this._compiler?.options | ||
| const extensions = compilerOptions?.resolve?.extensions || [] | ||
| const extensions = options?.resolveExtensions |
There was a problem hiding this comment.
Minor: this is where the webpack world and our app extensions collide :) Maybe rename this extensions to fileExtensions to differentiate it from app extensions?
| } | ||
|
|
||
| /** | ||
| * PRIVATE: Reads and parses a .force_overrides file into a list of clean override entries. |
There was a problem hiding this comment.
Minor: jsdoc has @private that we can use here.
| const projectPath = resourcePath.split(SRC)[0] | ||
| const projectRelPath = resourcePath.split(`${SRC_FOLDER}${path.sep}`)[1].split('.')[0] // File path relative to the project directory without file extension | ||
| const projectPath = resourcePath.split(SRC_FOLDER)[0] | ||
| const options = this.getOptions() |
There was a problem hiding this comment.
Should we print a warning for visibility when we detect the .force_overrides is being used with a similar copy?
pwa-kit/packages/extension-starter/.force_overrides
Lines 3 to 5 in 7d38fc4
Force overrides are in use. This may impact the upgradeability of extensions. Use only as a temporary solution for urgent fixes.
There was a problem hiding this comment.
We could print the warning based on the overridablesSet:
if (overridablesSet.size > 0) {
showWarning()
}
There was a problem hiding this comment.
We decided for now not to do this as we are unsure of the path forward on force_overrides.
There was a problem hiding this comment.
Do we want to update the script npm run list-overrides to list the unused file override defined in the extensions .force-overrides?
There was a problem hiding this comment.
Turns out that this script doesn't use the force-overrides directly. So we are going to create a new ticket for this once we get a better idea on the scope of the requirements.
There was a problem hiding this comment.
Ticket is created here --> https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00002Dzrf2YAB/view
| return content | ||
| .split(/\r?\n/) | ||
| .map((line) => line.trim()) | ||
| .filter((line) => line && !line.startsWith('//')) | ||
| .map((line) => line.split('//')[0].trim()) // remove inline comments | ||
| .filter(Boolean) |
There was a problem hiding this comment.
The .filter(Boolean) at the end looks like is redundant
There was a problem hiding this comment.
If there is a line with only a comment on it, this filter ensures that the empty line isn't included.
| return [ | ||
| path.join(projectDir, OVERRIDABLE_FILE_NAME), | ||
| ...extensions | ||
| .map((ext) => { |
There was a problem hiding this comment.
nit: we can use flatMap() instead of .map() ... .flat()
| // MULTIPLE OVERRIDES CAN BE ADDED TO THIS FILE, ONE PER LINE.\ | ||
| // EXAMPLE: | ||
| // ./node_modules/@salesforce/extension-sample/src/pages/home.tsx No newline at end of file | ||
| ./node_modules/@salesforce/extension-sample/src/pages/home.tsx No newline at end of file |
There was a problem hiding this comment.
I think you want to revert this change by default.
Description
As we make the transition from our current version of extensibility (v3) to the next version (v4) we believe that customers will want to retain many of their overrides that we currently have. This lead to the birth of the
.force_overridesfile which allows you to overrides an extensions public file API and provide overrides for any file that exists in an extension. Allowing the customer to unwind their level of overrides to zero if possible to get them to a place where upgradability isn't a challenge.Currently this feature only works in the base project (aka the project that you generate) but not in an extension project. This has been identified as a short coming of our API via one of our feedback sessions where a users voiced that they might want to override more than the public API if required. This could be for scenarios where they don't want to wait for use to make changes to our extensions to support features or customizations they want.
In this PR I enable the
.force_overridesfor application extension projects.Types of Changes
Changes
How to Test-Drive This PR
I have left in the
template-typescript-minimalproject configured with the store locator and the starter extensions. The starter extension has been updated to have a force_overrides file and an override to the store locator that isn't normally overridable.template-typescript-minimalproject runnpm run startChecklists
General
TODO