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

Does not build with create-react-app #134

Closed
marwej opened this issue Jul 9, 2017 · 3 comments
Closed

Does not build with create-react-app #134

marwej opened this issue Jul 9, 2017 · 3 comments

Comments

@marwej
Copy link

marwej commented Jul 9, 2017

I use react-calendar-timeline together with create-react-app but 0.15.0 don't build:

./~/react-calendar-timeline/src/lib/Timeline.js
Module parse failed: .../node_modules/react-calendar-timeline/src/lib/Timeline.js Unexpected token (73:19)
You may need an appropriate loader to handle this file type.
| 
| export default class ReactCalendarTimeline extends Component {
|   static propTypes = {
|     groups: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,
|     items: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired,

I don't want to eject my projects to include more loaders in the build process which makes it impossible to use this version.

(Thanks for a great product, by the way!)

@mariusandra
Copy link
Collaborator

mariusandra commented Jul 10, 2017

Hi, the problem is closely connected to this point in the readme.

The issue is that your app need to have babel-plugin-transform-class-properties enabled. While we ship transpiled ES5 code with the module, webpack 2+ uses the original ESnext code by default, which needs this plugin.

So there are two options: use the transpiled code or install the plugin.

  1. To use the transpiled code, simply switch your include statement to this:
// import Timeline from 'react-calendar-timeline' // old
import Timeline from 'react-calendar-timeline/lib' // new

This path may change in the future, so pay attention to the changelog when upgrading!

  1. Install the babel plugin... or at least all stage-2 plugins (or even stage-0). It's probably easiest to install custom-react-scripts
yarn add custom-react-scripts
yarn remove react-scripts

Then add this line to a file called .env:

REACT_APP_BABEL_STAGE_0=true

Then you may import the component like you would normally

import Timeline from 'react-calendar-timeline'

@p-glynn
Copy link

p-glynn commented Apr 23, 2018

Using custom-react-scripts worked great for me when i was running into this same issue using webpack 2+. Thanks so much!!

@DChefHarshil
Copy link

DChefHarshil commented Nov 17, 2022

@mariusandra I have similar but little bit different issue. I am using create-react-app for building the app. The app works fine in development mode but when I run the production build using serve -s build, I can't see anything on timeline but headers and sidebar. I can't even scroll or see any items. This is how it looks. @Ilaiwi Any thoughts?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants