1
0
mirror of synced 2026-01-15 06:06:30 -05:00
Files
airbyte/airbyte-webapp/packages/vite-plugins/patch-react-virtualized.ts
Tim Roes 828b32a3a2 🪟 🔧 Migrate from react-scripts to Vite (#21421)
* Migrate to Vite

* Continue work on vite migration

* More environment fixes

* Add CSP headers to dev server

* Remove react-scripts

* Shim process.env

* Cleanup

* Create ESLint failure for CI test

* create vite-plugins package

* Update nodeJS

* Make eslint warnings fail build

* Remove trailing empty line in nvmrc

* Match package.json with nvmrc

* Fix eslint test breakage

* Revert node upgrade

* Remove setupProxy script

* Change default API endpoints to be http
2023-01-23 21:10:23 +01:00

30 lines
1.2 KiB
TypeScript

import type { Plugin } from "vite";
import fs from "fs";
import path from "path";
// Patches the react-virtualized library which is pulled in by react-lazylog to remove
// a broken import in it. See https://github.com/bvaughn/react-virtualized/issues/1632
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
export function patchReactVirtualized(): Plugin {
return {
name: "airbyte/patch-react-virtualized",
// Note: we cannot use the `transform` hook here
// because libraries are pre-bundled in vite directly,
// plugins aren't able to hack that step currently.
// so instead we manually edit the file in node_modules.
// all we need is to find the timing before pre-bundling.
configResolved() {
const file = require
.resolve("react-lazylog/node_modules/react-virtualized")
.replace(
path.join("dist", "commonjs", "index.js"),
path.join("dist", "es", "WindowScroller", "utils", "onScroll.js")
);
const code = fs.readFileSync(file, "utf-8");
const modified = code.replace(WRONG_CODE, "");
fs.writeFileSync(file, modified);
},
};
}