-
-
Notifications
You must be signed in to change notification settings - Fork 522
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(plugin-webpack): support standalone preload entry points #2950
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2950 +/- ##
==========================================
+ Coverage 71.33% 73.47% +2.14%
==========================================
Files 79 68 -11
Lines 2414 2202 -212
Branches 452 440 -12
==========================================
- Hits 1722 1618 -104
+ Misses 469 374 -95
+ Partials 223 210 -13
Continue to review full report at Codecov.
|
The code works and I've fixed existing tests. Before writing new tests for this feature, I'd love some API feedback. |
So we're technically still in beta. We could just require everyone to add |
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.
LGTM, however I'm with @malept with changing type
to be a required field. Right now the code comment indicatingWebpackPluginEntryPoint.type
's default value is tightly coupled with code behaviour in WebpackConfig.ts
, and it isn't immediately obvious that if we ever change the code behaviour we have to change the comment indicating that the default value of type
is local-window
. Making type
default could be the solution here (non blocking though)
I think a deprecation warning for Forge 7 would be a good solution. |
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.
I'm not clear on why we need a type
field instead of just making certain property combinations possible / allowed.
E.g. Right now the js
key is required and the html
and preload
keys are optional
If we instead document the type like so, we could simply infer what you're calling the "type" based on the present keys and error out if an invalid combination of keys is provided.
type Entry = {
js: string;
} | {
html: string;
js: string;
} | {
html: string;
js: string;
preload: WebpackPreloadEntryPoint;
} | {
preload: WebpackPreloadEntryPoint;
}
I'm not sure if that's a better API but I don't like this type
parameter floating around, it feels kinda boxy for something that doesn't have to be.
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!
Is there anywhere in the docs where we can/need to update the examples for the webpack plugin (e.g.: local window, no window, preload only)? It might be nice to show those options for clarity.
(Not holding it as a merge blocker, but it looks like our friend the linux-x64 fixture binary also got committed) |
We should update the docs in accordance yep. Technically since this doesn't have any breaking changes we can just add it in later. |
Summary
Closes #2859
A common pattern for Electron applications is to load a remote website into a BrowserWindow and augmenting it with a preload script without having a local
index.html
renderer process.However, the webpack plugin does not support having a preload entry without an attached
index.html
file. This is an attempt at changing that.API
Entry points can now be one of three types:
html
,js
preload
js
preload
These are inferred via which fields are present or not in the config.
Demo
See https://github.com/erickzhao/ericktron-forge/tree/templated
Questions
Are the names good? Suggestions welcome!
Do we even need the
type
property? Technically, all 3 current configurations can be inferred by the presence of thehtml
/js
/preload
properties, so we can get away with not adding any new properties to the config. However, being explicit makes the config more readable and makes TypeScript support better.