Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Can't reexport the named export 'renderToString' #7

Open
Drarig29 opened this issue Aug 18, 2021 · 1 comment
Open

Can't reexport the named export 'renderToString' #7

Drarig29 opened this issue Aug 18, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@Drarig29
Copy link

Describe the bug

I have this error when I yarn start and yarn build.

Can't reexport the named export 'renderToString' from non EcmaScript module (only default export is available)

This is linked to this comment: preactjs/preact#1399 (comment)

To Reproduce
Steps to reproduce the behavior:

  1. Install preact: 10.5.14
  2. Install preact-render-to-string: 5.1.19
  3. Try to compile

Expected behavior
It should build the project.

Versions

  • react-scripts v : 4.0.3
  • cra-preact v : 0.4.0
@Drarig29 Drarig29 added the bug Something isn't working label Aug 18, 2021
@Drarig29
Copy link
Author

Drarig29 commented Aug 18, 2021

What I did to resolve the issue, but only temporarily, is to add webpack-modules in node_modules/cra-preact/src/(start|build).js.

Like the following:

const hookIntoRequire = require('require-in-the-middle')
+ const WebpackModules = require('webpack-modules')

hookIntoRequire(['react-scripts/config/webpack.config'], configFactory => {
	const config = configFactory('production')

	config.resolve.alias['react'] = 'preact/compat'
	config.resolve.alias['react-dom'] = 'preact/compat'
	config.resolve.alias['react-dom/test-utils'] = 'preact/test-utils'
    
+    config.plugins.push(new WebpackModules())

	return () => config
})

require('react-scripts/scripts/build')

Drarig29 added a commit to Drarig29/cra-preact that referenced this issue Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant