impersonator-eth / impersonator-extension

Browser extension that enables you to Log-in as ANY address on ALL dapps
54 stars 6 forks source link

chore: migrate from craco to vite #9

Closed Barabazs closed 1 week ago

Barabazs commented 2 weeks ago

The goal of this PR is to migrate from craco to vite.

Previous blocker description **Current blocker:** Vite does not bundle the import `import { StaticJsonRpcProvider } from "@ethersproject/providers"` in [src/chrome/impersonator.ts#L2](https://github.com/Barabazs/impersonator-extension/blob/3625d5b042707fe11efe0b6c0632b9a71129808d/src/chrome/impersonator.ts#L2) and generates a separate file for that import. (url-json-rpc-provider which comes from `@ethersproject/providers`) This results in an error in the browser when attempting to use inpage.js: `error: Uncaught SyntaxError: Cannot use import statement outside a module (at inpage.js:1:173)` ## craco build ``` build ├── asset-manifest.json ├── icons │   ├── icon128.png │   ├── icon16.png │   └── icon48.png ├── impersonatorLogo.png ├── index.html ├── manifest.json └── static ├── css │   ├── main.50755eb3.css │   └── main.50755eb3.css.map └── js ├── impersonator.js ├── impersonator.js.LICENSE.txt ├── impersonator.js.map ├── inject.js ├── inject.js.map ├── main.js ├── main.js.LICENSE.txt └── main.js.map ``` ## vite build ``` build ├── assets │   ├── index-43397656.css │   └── url-json-rpc-provider-75bf59c8.js ├── icons │   ├── icon128.png │   ├── icon16.png │   └── icon48.png ├── impersonatorLogo.png ├── index.html ├── manifest.json └── static └── js ├── inject.js ├── inpage.js └── main.js ```

To resolve the previous blocker, the inpage & inject scripts have to be built separately so they can be built with the iife lib configuration.

apoorvlathey commented 1 week ago

Great 🔥 Works flawlessly!