Preact-cli: Exports beyond the default export from components in the route directory do not work

Created on 12 Mar 2019  路  3Comments  路  Source: preactjs/preact-cli


Do you want to request a feature or report a bug?
bug
What is the current behaviour?
Exports beyond default exports from route components are not working.
If the current behaviour is a bug, please provide the steps to reproduce.
Export anything besides default from a component in the routes directory and try to import it in another file. There's a warning from webpack and the import will be undefined.

What is the expected behaviour?
Exports beyond the default export from a route component should work.
If this is a feature request, what is motivation or use case for changing the behaviour?

Please mention other relevant information.

  • Node version 10.15.0
  • npm version 6.9.0
  • Operating system OSX 10.14.2
  • CLI version 2.2.1
  • Browser Chrome
bug future

Most helpful comment

Yup it's because of the async loader, we're not quite sure how to fix it

If you rename the directory it will work

All 3 comments

Yup it's because of the async loader, we're not quite sure how to fix it

If you rename the directory it will work

This is an intentional limitation that ensures effective code splitting. For components that need named exports, place them in a directory that doesn't trigger automatic code splitting. You can then manually code-split the default export by re-exporting it from routes/ or importing it with the "async!" prefix.

For more information on this, please refer to the Route Based Code Splitting in README.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jpoo90 picture jpoo90  路  4Comments

ethanwu10 picture ethanwu10  路  3Comments

tmcw picture tmcw  路  4Comments

AlStar01 picture AlStar01  路  3Comments

c0debreaker picture c0debreaker  路  4Comments