-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm es module result do not have bpfrpt_proptype_WindowScroller in WindowScroller/onScroll.js, #1722
Comments
Github link |
@nicktobolski you can use a Vite plugin to fix this. In your vite.config.ts add this: const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
function reactVirtualized() {
return {
name: 'my:react-virtualized',
configResolved() {
const file = require
.resolve('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);
},
};
} The add it to your plugins in the config: export default defineConfig({
plugins: [
//...
reactVirtualized(),
],
// ...
}); |
this is useful for me |
ESM version of the fix: import { readFile, writeFile } from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
import type { PluginOption } from 'vite';
// ...
function reactVirtualized(): PluginOption {
const WRONG_CODE = `import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";`;
return {
name: 'my:react-virtualized',
async configResolved() {
const reactVirtualizedPath = path.dirname(
fileURLToPath(import.meta.resolve('react-virtualized'))
);
const brokenFilePath = path.join(
reactVirtualizedPath,
'..', // back to dist
'es',
'WindowScroller',
'utils',
'onScroll.js'
);
const brokenCode = await readFile(brokenFilePath, 'utf-8');
const fixedCode = brokenCode.replace(WRONG_CODE, '');
await writeFile(brokenFilePath, fixedCode);
},
};
} |
I made an esbuild plugin to fix this: https://npmjs.com/package/esbuild-plugin-react-virtualized // vite.config.js
import { defineConfig } from 'vite'
import fixReactVirtualized from 'esbuild-plugin-react-virtualized'
export default defineConfig({
optimizeDeps: {
esbuildOptions: {
plugins: [fixReactVirtualized],
},
},
}) |
if anyone's getting a ts error here, here's what helped: optimizeDeps: {
esbuildOptions: {
plugins: [fixReactVirtualized],
} as DepOptimizationConfig['esbuildOptions']
}, |
Bug Report
Please include either a failing unit test or a simple repro. You can start by forking this Code Sandbox: https://codesandbox.io/s/03qpzq1p9p?module=%2FExample.js
What is the current behavior?
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React and react-virtualized. Paste the link to your Code Sandbox below:
What is the expected behavior?
Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?
react-virtualized bundle result , this is some bug in esm
the path is: node_modules/react-virtualized/dist/es/WindowScroller/onScroll.js,
....
import { bpfrpt_proptype_WindowScroller } from "../WindowScroller.js";
....
bpfrpt_proptype_WindowScroller is unuse ,meanwhile ../WindowScroller.js do not have named export that is called
bpfrpt_proptype_WindowScroller
The text was updated successfully, but these errors were encountered: