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

Syntax error while compiling component from node_modules #9633

Open
andiappan-ar opened this Issue Mar 4, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@andiappan-ar
Copy link

andiappan-ar commented Mar 4, 2019

I have below structure and its compiling good.

  • Project
    • Zoo
      • Src
      • Components
        • MySharedComponents

When i try to move my shared components as one Project and try to install it in other project like below structure. This gives compilation syntax error.

  • Feature (My shared component project)
    • Src
      • Components
        • MySharedComponents
  • Project
    • node_modules
      • Feature
    • Zoo
      • Src
      • Components

When i try to build my project its throwing syntax error in node_modules components.

Error Image : https://i.stack.imgur.com/TEynK.png

My GIT Repo Here : https://github.com/andiappan-ar/babelIssue.git

I tried below options but nothing works,

  1. Instead of manually install my shared project, i have used lerna that also causing the same issue.

  2. Currently my project doesnt have ".babelrc" file all my babel-presets in webpackconfig itself. Even i introduce babelrc file in both project doesnt solve the issue.

  3. I have cross across many git links they are saying to add presets in multiple way. but nothing work out.
    The related Issue seems still open facebook/create-react-app#5100.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Mar 4, 2019

Hey @andiappan-ar! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Mar 4, 2019

  1. Which command should I run in your repo? I tried npm run build:webpack in project/safarizoo but it doesn't load the webpack config, so Babel isn't used.
  2. Your webpack config is explicitly excluding node_modules/feature (the linked package). Maybe you want something like this?
      {
        test: /\.m?jsx?$/,
        exclude: {
          test: /node_modules/,
          not: [/node_modules\/feature/]
        },
        use: {
          loader: 'babel-loader',
          options: {
            rootMode: 'upward'
          },
        },
      },
  1. All your .babelrc files are using babel6 presets. I suggest removing them since you are already using babel.config.js (unless you don't want a shered config: in that case you need to update them to use v7 packages).
  2. Your babel.config.js contains './samples/react/*', but the path is Samples/React
@andiappan-ar

This comment has been minimized.

Copy link
Author

andiappan-ar commented Mar 4, 2019

Thanks for the reply , you can build my project/safarizoo using ">jss build".
Meanwhile let me check your suggestions

@andiappan-ar

This comment has been minimized.

Copy link
Author

andiappan-ar commented Mar 4, 2019

@nicolo-ribaudo i had tried your suggestions still issue is re-produced.

Updaed repo also. (https://github.com/andiappan-ar/babelIssue.git). Can you please look from your side. You can build project/safarizoo using

jss build

.

In root direcory install this cli

npm install -g @sitecore-jss/sitecore-jss-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.