react-virtualized icon indicating copy to clipboard operation
react-virtualized copied to clipboard

esm output provides wrong import statement

Open TrySound opened this issue 6 years ago • 14 comments

There is in the end unused and not existing import. Seems like generated by mistake https://unpkg.com/[email protected]/dist/es/WindowScroller/utils/onScroll.js

import { bpfrpt_proptype_WindowScroller } from '../WindowScroller.js';

/cc @brigand

TrySound avatar Sep 12 '18 15:09 TrySound

Hey, this is expected behavior of the plugin, but since bpfrpt_proptype_WindowScroller isn't used anywhere, we'd ideally remove it. However, this requires some form of escape-analysis, which is a bit tricky. Created an issue.

If a quick fix is needed, you can add this line to the file:

'no babel-plugin-flow-react-proptypes';

brigand avatar Sep 12 '18 19:09 brigand

I cannot build the package with esbuild because of this issue

error: No matching export for import "bpfrpt_proptype_WindowScroller"
    75 │ import { bpfrpt_proptype_WindowScroller } from '../WindowScroller.js';

remorses avatar Dec 21 '20 17:12 remorses

For esbuild, i've redirected imports to umd and it seems to work

const resolveFixup = {
  name: 'resolve-fixup',
  setup(build) {
    build.onResolve({ filter: /react-virtualized/ }, async args => {
      return {
        path: path.resolve('./node_modules/react-virtualized/dist/umd/react-virtualized.js'),
      }
    })
  },
};

esbuild.build({
  plugins: [
    resolveFixup,
    // your plugins
  ],
});

YurySolovyov avatar May 25 '21 10:05 YurySolovyov

@YurySolovyov This is a good patch fix for this issue, but this needs to be resolved in a later release of react-virtualized!

lucantini avatar Aug 02 '21 18:08 lucantini

For anyone using Vite v2.3.0 or newer, you can apply the esbuild plugin that @YurySolovyov wrote above by modifying your Vite config to include the following:

export default defineConfig({
  optimizeDeps: {
    esbuildOptions: {
      plugins: [resolveFixup]
    }
  }
});

kitsune7 avatar Aug 05 '21 16:08 kitsune7

This problem also happens when building with rollup. Can we remove this particular import since this variable doesn't seem to exist?

lucantini avatar Aug 25 '21 19:08 lucantini

This is still an issue for us when building with esbuild.

jasonwilliams avatar Dec 17 '21 13:12 jasonwilliams

Yeh, I worked through several issues I had trying out esbuild and using a lerna monorepo, and after all those were resolved I hit this. Bumping this in hopes it gets attention. :-)

intafon avatar Jan 10 '22 08:01 intafon

@intafon if you need a quick fix https://github.com/bvaughn/react-virtualized/issues/1212#issuecomment-847759202 solution worked for me.

In terms of this being fixed in general, it's already been fixed and merged but it seems to be stuck on being published. https://github.com/bvaughn/react-virtualized/commit/2e962d8f8aebc22cb1168a8d147bcaa1d27aa326

jasonwilliams avatar Mar 04 '22 12:03 jasonwilliams

It's still an issue in 2023 vite v4.3.8

VladBrok avatar May 20 '23 13:05 VladBrok

image

please fix (((

VladBrok avatar May 20 '23 13:05 VladBrok

Also hitting this issue. Please fix!

kaiyoma avatar May 22 '23 21:05 kaiyoma

Hotfix for this issue has been resolved above at the comment comment

H0JLuk avatar Jul 10 '23 10:07 H0JLuk

I wrote an esbuild plugin to fix this: https://npmjs.com/package/esbuild-plugin-react-virtualized

abemedia avatar Jan 26 '24 08:01 abemedia