-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
externals
in compiler builder options (#8959)
feat: init
- Loading branch information
Showing
5 changed files
with
207 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#[derive(Debug, Default)] | ||
pub struct ExternalsPresets { | ||
/// Treat node.js built-in modules like `fs`, `path` or `vm` as external and load them via `require()` when used. | ||
pub(crate) node: Option<bool>, | ||
|
||
/// Treat references to `http(s)://...` and `std:...` as external and load them via import when used. | ||
pub(crate) web: Option<bool>, | ||
|
||
/// Treat references to `http(s)://...` and `std:...` as external and load them via async import() when used | ||
pub(crate) web_async: Option<bool>, | ||
|
||
/// Treat common electron built-in modules in main and preload context like `electron`, `ipc` or `shell` as external and load them via `require()` when used. | ||
pub(crate) electron: Option<bool>, | ||
|
||
/// Treat electron built-in modules in the main context like `app`, `ipc-main` or `shell` as external and load them via `require()` when used. | ||
pub(crate) electron_main: Option<bool>, | ||
|
||
/// Treat electron built-in modules in the preload context like `web-frame`, `ipc-renderer` or `shell` as external and load them via require() when used. | ||
pub(crate) electron_preload: Option<bool>, | ||
|
||
/// Treat electron built-in modules in the preload context like `web-frame`, `ipc-renderer` or `shell` as external and load them via require() when used. | ||
pub(crate) electron_renderer: Option<bool>, | ||
|
||
/// Treat `NW.js` legacy `nw.gui` module as external and load it via `require()` when used. | ||
pub(crate) nwjs: Option<bool>, | ||
} | ||
|
||
impl ExternalsPresets { | ||
pub fn node(&self) -> bool { | ||
self.node.unwrap_or(false) | ||
} | ||
|
||
pub fn web(&self) -> bool { | ||
self.web.unwrap_or(false) | ||
} | ||
|
||
pub fn web_async(&self) -> bool { | ||
self.web_async.unwrap_or(false) | ||
} | ||
|
||
pub fn electron(&self) -> bool { | ||
self.electron.unwrap_or(false) | ||
} | ||
|
||
pub fn electron_main(&self) -> bool { | ||
self.electron_main.unwrap_or(false) | ||
} | ||
|
||
pub fn electron_preload(&self) -> bool { | ||
self.electron_preload.unwrap_or(false) | ||
} | ||
|
||
pub fn electron_renderer(&self) -> bool { | ||
self.electron_renderer.unwrap_or(false) | ||
} | ||
|
||
pub fn nwjs(&self) -> bool { | ||
self.nwjs.unwrap_or(false) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod builder; | ||
mod devtool; | ||
mod externals; | ||
mod target; | ||
|
||
pub use builder::{ | ||
|
9da4fc8
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.
📝 Ecosystem CI detail: Open
9da4fc8
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.
📝 Benchmark detail: Open