question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

esm output provides wrong import statement

See original GitHub issue

There is in the end unused and not existing import. Seems like generated by mistake https://unpkg.com/react-virtualized@9.20.1/dist/es/WindowScroller/utils/onScroll.js

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

/cc @brigand

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:22
  • Comments:9

github_iconTop GitHub Comments

18reactions
YurySolovyovcommented, May 25, 2021

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
  ],
});
17reactions
kitsune7commented, Aug 5, 2021

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]
    }
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest and ESM throwing errors with import fs - Stack Overflow
I've looked only, through many examples and Q&A, but almost all of them refers to changes with ts-node or babel . My package...
Read more >
How to Fix "SyntaxError: Cannot use import statement outside ...
In this post, we'll learn more about the "SyntaxError: Cannot use import statement outside a module" error and how to fix it in...
Read more >
TypeScript: Cannot use import statement outside a module
To solve the error "Cannot use import statement outside a module" in TypeScript, set the module option to commonjs in your tsconfig.json file...
Read more >
rollup.js
You can provide an optional Rollup configuration file to simplify command line ... since a proper understanding of the import and export statements...
Read more >
Avoid these issues when using new ECMAScript modules in ...
But if your package uses import/export and you don't tell Jest that the package is using es6 modules then it will try to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found