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: 'convertToRaw' is not exported by node_modules/draft-js/lib/Draft.js" in version 2.1.8 #153

Open
serafinomb opened this issue Aug 6, 2019 · 2 comments

Comments

@serafinomb
Copy link

Hello,
during a clean npm install I encountered the error reported below.

These are the "draft-js" and "draft-convert" versions in my "package.json" file.

"dependencies": {
    "draft-convert": "^2.0.1",
    "draft-js": "^0.10.5",
    ...
}

And the error encountered:

    [!] Error: 'convertToRaw' is not exported by node_modules/draft-js/lib/Draft.js
    https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
    node_modules/draft-convert/esm/convertToHTML.js (5:9)
    3: import React from 'react';
    4: import ReactDOMServer from 'react-dom/server';
    5: import { convertToRaw } from 'draft-js';
                ^
    6: import encodeBlock from './encodeBlock';
    7: import blockEntities from './blockEntities';

I updated the "draft-convert" version to "2.1.7" momentarily to fix the issue. It seems that the latest release has incompatibilities with the latest release (as of today) of "draft-js".

Please let me know if I do anything to help debug the issue,
thank you.

@serafinomb serafinomb changed the title Error 'convertToRaw' is not exported by draft-js/lib/Draft.js in version 2.1.8 "Error 'convertToRaw' is not exported by draft-js/lib/Draft.js" in version 2.1.8 Aug 6, 2019
@serafinomb serafinomb changed the title "Error 'convertToRaw' is not exported by draft-js/lib/Draft.js" in version 2.1.8 "Error 'convertToRaw' is not exported by node_modules/draft-js/lib/Draft.js" in version 2.1.8 Aug 6, 2019
@serafinomb serafinomb changed the title "Error 'convertToRaw' is not exported by node_modules/draft-js/lib/Draft.js" in version 2.1.8 "Error: 'convertToRaw' is not exported by node_modules/draft-js/lib/Draft.js" in version 2.1.8 Aug 6, 2019
@dumistoklus
Copy link

dumistoklus commented Aug 31, 2019

@serafinomb, To fix this error add convertToRaw to commonjs rollup plugin section in rollup config.

plugins: [
  commonjs({
    namedExports: {
      'node_modules/draft-js/lib/Draft.js': [
        'convertToRaw',
        // ...other exports
      ]
    }
  })
]

@TrySound
Copy link
Contributor

TrySound commented Sep 1, 2019

Similar way with kinda automating named exports list

import * as draftJs from 'draft-js';
commonjs({
  namedExports: {
    'draft-js': Object.keys(draftJs)
  }
})

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

3 participants