Skip to content
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

Error: Can't resolve 'use-sync-external-store/shim/with-selector' in '/../node_modules/@slate-yjs/react/dist' #366

Open
rcbevans opened this issue Oct 7, 2022 · 6 comments

Comments

@rcbevans
Copy link

rcbevans commented Oct 7, 2022

ERROR in ./node_modules/@slate-yjs/react/dist/index.js 82:0-94
Module not found: Error: Can't resolve 'use-sync-external-store/shim/with-selector' in '/../node_modules/@slate-yjs/react/dist'
Did you mean 'with-selector.js'?
BREAKING CHANGE: The request 'use-sync-external-store/shim/with-selector' 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.
webpack compiled with 2 errors and 1 warning

I'm trying to bump @slate-yjs/core and @slate-yjs/react to ^0.3.0 and after fixing up the breaking API changes to cursors, my front-end is unable to build due to to the error above.

This is in a react 17.0.2 create-react-app project with no explicit dependency on use-sync-external-store myself.

I tried nuking all node_modules, as well as installing after removing yarn.lock.

FWIW I don't have a package.json with "type": "module".

Any idea where this might be coming from, or how to resolve the issue?

@faizansaleem13504
Copy link

Facing the exact same issue

@faizansaleem13504
Copy link

One solution that worked for me was to patch the package.json file and setting default export from "default": "./dist/index.js" to "default": "./dist/index.cjs"
image

@cjjeon
Copy link

cjjeon commented Nov 10, 2022

This is somewhat related to this thread anza-xyz/wallet-adapter#200 which seems like webpack 5 issue with create-react-app.

The way I fixed this issue is updating webpack config following https://stackoverflow.com/questions/63280109/how-to-update-webpack-config-for-a-react-project-created-using-create-react-app.

And I updated the file config-overrides.js as:

// config-overrides.js
module.exports = function override(config, env) {
  // New config, e.g. config.plugins.push...
  config.module.rules.push({
    test: /\.m?js/,
    resolve: {
      fullySpecified: false,
    },
  });
  return config;
};

@rcbevans
Copy link
Author

@cjjeon I feel terrible for not following up here, but I ended up doing exactly this.

@jameskirkby
Copy link

For anyone using Next.js (we're using v13.1.5), adding this to the next.config.js fixed the issue:

// next.config.js
const nextConfig = {
  // ...
  transpilePackages: ['@slate-yjs/react'],
}

module.exports = nextConfig

@thovden
Copy link

thovden commented Jan 1, 2024

I ran into this using vitest (I don't get this error in vite for some reason). I resolved it in vitest.config forcing use of the CJS variant:

test: {
  alias: {
        '@slate-yjs/react': path.resolve(baseDir, 'node_modules', '@slate-yjs', 'react', 'dist', 'index.cjs'),
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants