preactjs / preact-compat

ATTENTION: The React compatibility layer for Preact has moved to the main preact repo.
http://npm.im/preact-compat
MIT License
949 stars 148 forks source link

Module not found: 'react-dom/lib/CSSProperty' #404

Closed ramrami closed 5 years ago

ramrami commented 7 years ago

Hi, I want to convert one of my React project to preact, we're using DraftJs as a "a framework for building rich text editors in React", but I get the following build error :

ERROR in ./node_modules/draft-js-export-html/lib/helpers/styleToCSS.js Module not found: Error: Can't resolve 'react-dom/lib/CSSProperty' in '~/project/node_modules/draft-js-export-html/lib/helpers' @ ./node_modules/draft-js-export-html/lib/helpers/styleToCSS.js 7:19-55 @ ./node_modules/draft-js-export-html/lib/stateToHTML.js @ ./node_modules/draft-js-export-html/lib/main.js @ ./app/components/ArticleEditorPage.js @ ./app/router/index.js @ ./app/app.js @ multi ./app/app.js

How can I get around this error ?

mpavel commented 7 years ago

+1

mpavel commented 7 years ago

Here's how I solved it. Basically, due to the aliasing of react and react-dom to preact-compat, the reference to the file CSSProperty.js is wrong.

I copied the js file from react-dom to preact-compat and the build worked.

In my gulpfile, I've just setup the following, as quick fix:

/**
 * Preact fixes
 */
const fs = require('fs');

fs.createReadStream('./node_modules/react-dom/lib/CSSProperty.js').pipe(
  fs.createWriteStream('./node_modules/preact-compat/lib/CSSProperty.js'),
);