feat: Use DIR_ASSETS path to locate resource bundles#47439
feat: Use DIR_ASSETS path to locate resource bundles#47439deepak1556 merged 7 commits intoelectron:mainfrom
Conversation
| * `temp` Temporary directory. | ||
| * `exe` The current executable file. | ||
| * `module` The `libchromiumcontent` library. | ||
| * `module` The location of the Chromium module. By default this is synonymous with `exe`. |
There was a problem hiding this comment.
This is only tangentially related to the other changes, but libchromiumcontent hasn't existed for a long time, so it seemed worth updating these docs while I'm here.
|
This looks good, can you make the following additional changes
|
@deepak1556 I started working on this but then got pulled into other work for awhile. What I've found by adding some tests is that |
|
Thanks for looking into the tests, if it would make things easier, we can expose the My initial comment for tests was also specific to windows and linux since the code paths touched in this PR are specific to those platforms. |
|
Pending one more API approval @electron/wg-api |
…ble on Windows + Linux
404b4d2 to
1596059
Compare
|
Failing tests are unrelated, merging. |
|
Release Notes Persisted
|
|
I have automatically backported this PR to "38-x-y", please check out #47950 |
|
I have automatically backported this PR to "37-x-y", please check out #47951 |
* feat: Use DIR_ASSETS path to locate resource bundles
* Use DIR_ASSETS for calculating ASAR relative paths
* Add test to verify 'assets' matches parent dir of 'exe'
* Add Mac-specific test for assets path (but it is failing)
* test: Update app.getPath('assets') to expect an exception on Mac
* docs: Update docs for 'assets' path to indicate that it's only available on Windows + Linux
* fix: Don't define 'assets' mapping on macOS
Description of Change
Electron currently uses the
DIR_MODULEconstantsDIR_EXEwhen querying thePathServiceto calculate resource paths, but the Chromium source and https://issues.chromium.org/issues/40203062 both discourage using these constants to locate assets, and instead recommend usingDIR_ASSETS.By default
DIR_ASSETSis an alias forDIR_MODULE, but by updating Electron to useDIR_ASSETS, we align better with Chromium recommendations, and make it possible for apps with custom layouts to only need to overrideDIR_ASSETS.In addition to changing the constants used internally for loading
resources.pakand for theprocess.resourcesPath, this PR adds "assets" as a key that can be queried viaapp.getPath.Because
DIR_ASSETSis treated as an alias forDIR_MODULEby default, these changes should be a no-op for any existing apps.Checklist
npm testpassesRelease Notes
Notes: Internally switched to using
DIR_ASSETSinstead ofDIR_MODULE/DIR_EXEto locate assets and resources, and added "assets" as a key that can be queried viaapp.getPath.