Chrome Web Store Team complains a Violation: My Extension (Cancelly.ca) is injecting the enterprise.js externally from the Google API in the src/index.js file.
Problem
Operating System macOS Ventura 13.5 Browser Version 116.0.5845.179 (Official Build) (arm64) Firebase SDK Version ^10.1.0 Firebase SDK Product: Auth Describe your project's tooling I am using this https://github.com/JohnBra/vite-web-extension Describe the problem Following code after the build generates minified files containing URLs with enterprise.js so the Chrome Web Store Team complains of a violation. [code block] Steps and code to reproduce issue Defined in the problem.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Remove External Injection of enterprise.js from Build Process
The build process of the extension is inadvertently including the 'enterprise.js' script from the Google API due to the Firebase SDK configuration or the way dependencies are bundled in the Vite setup. This can happen if the Firebase SDK is not properly configured to exclude certain scripts or if the build process does not correctly handle external dependencies.
Awaiting Verification
Be the first to verify this fix
- 1
Update Firebase SDK Configuration
Ensure that the Firebase SDK is configured to not include external scripts like 'enterprise.js'. This can be done by checking the imports in your code and ensuring that only the necessary Firebase modules are imported.
typescriptimport { initializeApp } from 'firebase/app'; import { getAuth } from 'firebase/auth'; // Only import necessary modules - 2
Modify Vite Configuration
Update the Vite configuration to exclude any external scripts during the build process. This can be done by adding a configuration option to prevent the inclusion of unwanted scripts.
javascriptexport default defineConfig({ build: { rollupOptions: { external: ['enterprise.js'], // Exclude enterprise.js } } }); - 3
Check for Unused Dependencies
Run a dependency audit to check for any unused or unnecessary dependencies that might be pulling in 'enterprise.js'. Remove any such dependencies to clean up the project.
bashnpm audit --production npm prune - 4
Rebuild the Extension
After making the above changes, rebuild the extension to ensure that the changes take effect and that 'enterprise.js' is no longer included in the output files.
bashnpm run build - 5
Test the Build Output
Inspect the generated build files to confirm that 'enterprise.js' is no longer present. You can do this by searching the output directory for the script.
bashgrep -r 'enterprise.js' dist/
Validation
Confirm that the build output no longer contains references to 'enterprise.js' by checking the minified files in the 'dist' directory. Additionally, verify that the extension functions correctly without the external script.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep