tajo / react-movable

🔀 Drag and drop for your React lists and tables. Accessible. Tiny.
https://react-movable.pages.dev
MIT License
1.55k stars 51 forks source link

3.0.1 is broken #75

Closed Hypnosphi closed 3 years ago

Hypnosphi commented 3 years ago

When trying to use 3.0.1 in a webpack project:

ERR! Module not found: Error: Can't resolve './List' in '/mnt/agent/work/3f8925a0bfceb8d1/node_modules/react-movable/lib'
ERR! Did you mean 'List.js'?
ERR! BREAKING CHANGE: The request './List' failed to resolve only because it was resolved as fully specified
ERR! (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
ERR! The extension in the request is mandatory for it to be fully specified.
ERR! Add the extension to the request.

you should probably add extension to all imports, as stated here: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-move-my-commonjs-project-to-esm

Use only full relative file paths for imports: import x from '.'; → import x from './index.js';.

You must use a .js extension in relative imports even though you're importing .ts files.

tajo commented 3 years ago

Should be fixed in 3.0.2, thanks.

dkadrios commented 2 years ago

Webpack is fine in 3.0.2, but we're still receiving errors in Jest from a unit that imports arrayMove.

/Users/darin/git/traverse/frontend/node_modules/react-movable/lib/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import List from './List.js';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      1 | import PropTypes from 'prop-types'
      2 | import { useState } from 'react'
    > 3 | import { arrayMove } from 'react-movable'
        | ^

Adding react-movable to Jest's transformIgnorePatterns doesn't work in this case.

tajo commented 2 years ago

Jest also supports ESM with some extra settings: https://jestjs.io/docs/ecmascript-modules

dkadrios commented 2 years ago

They do, as experimental support. It does not work (at least for our codebase)

linhpham199 commented 2 years ago

@tajo This issue reappears in the latest 3.0.3. I had to install 3.0.2 instead.

ERROR in ./node_modules/react-movable/lib/index.js 1:0-26
Module not found: Error: Can't resolve './List' in '/Users/*/node_modules/react-movable/lib'
Did you mean 'List.js'?
BREAKING CHANGE: The request './List' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
ERROR in ./node_modules/react-movable/lib/index.js 2:0-49
Module not found: Error: Can't resolve './utils' in '/Users/*/node_modules/react-movable/lib'
Did you mean 'utils.js'?
BREAKING CHANGE: The request './utils' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
tajo commented 2 years ago

@linhpham199 3.0.4 should be fine now