mirror of
https://github.com/bitwarden/browser
synced 2025-12-28 14:13:22 +00:00
[PM-22629] Forbid importing popup outside (#15168)
Adds an eslint rule forbidding non popup scripts from importing popups. Also added a webpack plugin that throws if it detects @angular inside background output.
This commit is contained in:
21
apps/browser/webpack/angular-check.js
vendored
Normal file
21
apps/browser/webpack/angular-check.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Webpack plugin that errors if it detects angular imports.
|
||||
*/
|
||||
class AngularCheckPlugin {
|
||||
apply(compiler) {
|
||||
compiler.hooks.assetEmitted.tap("AngularCheckPlugin", (file, info) => {
|
||||
// Ensure we only check outputted JavaScript files
|
||||
if (!file.endsWith(".js")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.content.includes("@angular")) {
|
||||
throw new Error(
|
||||
`Angular detected in ${file}. Please ensure angular is not imported to non popup scripts.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AngularCheckPlugin;
|
||||
Reference in New Issue
Block a user