-
Notifications
You must be signed in to change notification settings - Fork 16.5k
feat: Use DIR_ASSETS path to locate resource bundles #47439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Use DIR_ASSETS path to locate resource bundles #47439
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Pending one more API approval @electron/wg-api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
…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_MODULE
constantsDIR_EXE
when querying thePathService
to 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_ASSETS
is 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.pak
and for theprocess.resourcesPath
, this PR adds "assets" as a key that can be queried viaapp.getPath
.Because
DIR_ASSETS
is treated as an alias forDIR_MODULE
by default, these changes should be a no-op for any existing apps.Checklist
npm test
passesRelease Notes
Notes: Internally switched to using
DIR_ASSETS
instead ofDIR_MODULE
/DIR_EXE
to locate assets and resources, and added "assets" as a key that can be queried viaapp.getPath
.