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

Moving .jsx components from Create-React-App #2847

Closed
valorloff opened this issue Aug 25, 2017 · 5 comments
Closed

Moving .jsx components from Create-React-App #2847

valorloff opened this issue Aug 25, 2017 · 5 comments

Comments

@valorloff
Copy link

valorloff commented Aug 25, 2017

I'm trying move .jsx components looks like:

class Header extends React.Component {
  constructor(props) {
............................................
}
render() {
    return 
    (
    <div className="nav-container">
      <a id="top"></a>
        <nav>
          <div className="nav-utility">
            <div className="module left">
 ..........................)

from production ready CreateReactApp to new next.js project and once faced with module parse fail:

Module parse failed: /home/orloff/projects/dst-next/src/app/components/layout/header.jsx Unexpected token (40:6)
You may need an appropriate loader to handle this file type.
| render() {
|     return
|     ( <div>Header</div>
|   //   <div className="nav-container">
|   //     <a id="top"></a>

 @ ./components/App.js 11:14-44
 @ ./pages?entry
 @ multi ./pages?entry

what is correct way solve it?

@Florian-R
Copy link

This is caused by the jsx extension. See #2391 and #2699

@timneutkens
Copy link
Member

Closing as duplicate

@valorloff
Copy link
Author

Thanks!
i'm add content of examples/with-jsx/next.config.js and next llaunched properly

@valorloff
Copy link
Author

valorloff commented Aug 25, 2017

but not works properly:
yarn build-next && yarn build-firebase

> Using "webpack" config function defined in next.config.js.
> Failed to build on /tmp/53bd3882-64aa-43bd-9ad1-3cdc2e54cc93
{ Error: ./components/App.js
Module not found: Error: Can't resolve './layout/header' in '/home/orloff/projects/dst-next/src/app/components'
resolve './layout/header' in '/home/orloff/projects/dst-next/src/app/components'

though
header.jsx in place, what is wrong?

@valorloff
Copy link
Author

valorloff commented Aug 25, 2017

using description file: /home/orloff/projects/dst-next/src/app/package.json (relative path: ./components)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/orloff/projects/dst-next/src/app/package.json (relative path: ./components)
    using description file: /home/orloff/projects/dst-next/src/app/package.json (relative path: ./components/layout/header)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /home/orloff/projects/dst-next/src/app/components/layout/header doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /home/orloff/projects/dst-next/src/app/components/layout/header.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /home/orloff/projects/dst-next/src/app/components/layout/header.json doesn't exist
      as directory
        /home/orloff/projects/dst-next/src/app/components/layout/header doesn't exist
[/home/orloff/projects/dst-next/src/app/components/layout/header]
[/home/orloff/projects/dst-next/src/app/components/layout/header.js]
[/home/orloff/projects/dst-next/src/app/components/layout/header.json]
[/home/orloff/projects/dst-next/src/app/components/layout/header]
 @ ./components/App.js 11:14-40

but in next.config.js explicitly defined:

module.exports = {
  distDir: "../functions/next",
  // Add extensions
  pagesExtensions: [
    'js',
    'jsx',
    'json'],

Where should Field 'browser' be?
Where in src/app/package.json should be described it?

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants