Open assadi-dev opened 10 months ago
i fix it on remove
on onScroll.js file
This is the fix
In vite.config.js
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`
function reactVirtualized(): PluginOption {
return {
name: 'flat: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: async () => {
const require = createRequire(import.meta.url)
const reactVirtualizedPath = require.resolve('react-virtualized')
const { pathname: reactVirtualizedFilePath } = new url.URL(reactVirtualizedPath, import.meta.url)
const file = reactVirtualizedFilePath
.replace(
path.join('dist', 'commonjs', 'index.js'),
path.join('dist', 'es', 'WindowScroller', 'utils', 'onScroll.js'),
)
const code = await fs.readFile(file, 'utf-8')
const modified = code.replace(WRONG_CODE, '')
await fs.writeFile(file, modified)
},
}
}
export default defineConfig({
plugins: [react(), reactVirtualized().....
thanks
@mcosti, thank you!! this saved me lots of time.
including imports, this is what got it working for me:
import { PluginOption, defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import fs from "fs/promises";
import { createRequire } from 'module';
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`
function reactVirtualized(): PluginOption {
return {
name: 'flat: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: async () => {
const require = createRequire(import.meta.url)
const reactVirtualizedPath = require.resolve('react-virtualized')
const { pathname: reactVirtualizedFilePath } = new URL(reactVirtualizedPath, import.meta.url)
const file = reactVirtualizedFilePath
.replace(
path.join('dist', 'commonjs', 'index.js'),
path.join('dist', 'es', 'WindowScroller', 'utils', 'onScroll.js'),
)
const code = await fs.readFile(file, 'utf-8')
const modified = code.replace(WRONG_CODE, '')
await fs.writeFile(file, modified)
},
}
}
export default defineConfig({
plugins: [react(), reactVirtualized().....
i fix it on remove
on onScroll.js file
This worked for me too!!
Is there a reason we haven't added this as an update to the package or even a separate plugin ?
The maintainer is not responding anymore and no one forked the project yet
Someone has created this vite plugin to fix this issue
// vite.config.ts
import fixReactVirtualized from "esbuild-plugin-react-virtualized";
export default defineConfig({
plugins: [react(), tsconfigPaths()],
optimizeDeps: {
esbuildOptions: {
plugins: [fixReactVirtualized],
},
},
});
I have this error when i import Timeline on vite project