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

Module parse failed #17

Open
tjiang11 opened this issue May 31, 2017 · 10 comments
Open

Module parse failed #17

tjiang11 opened this issue May 31, 2017 · 10 comments

Comments

@tjiang11
Copy link

tjiang11 commented May 31, 2017

Hi everyone, I'm having trouble importing VoicePlayer into my project. Anyone know what the problem is? This is the error I get.

I'm trying to get this to work in a project made with create-react-app

error repro: https://github.com/tjiang11/react-bug-repro

./~/react-voice-components/lib/VoicePlayer.js
Module parse failed: /home/tjiang11/Documents/Projects/lingua/node_modules/react-voice-components/lib/VoicePlayer.js Unexpected token (19:15)
You may need an appropriate loader to handle this file type.
|   }
| 
|   createSpeech = () => {
|     const defaults = {
|       text: '',
@cr101
Copy link

cr101 commented Jun 1, 2017

@tjiang11 it might have something to do with the source code of this library not being compiled to ES5

@v-stickykeys
Copy link

v-stickykeys commented Sep 22, 2017

I'm not sure how to do the compiling thing but I fixed this by rewriting all functions to this form

createSpeech() { const defaults = { text: '',

I also had to import both the VoicePlayer and VoiceRecognition in order to use either of them.

import {VoicePlayer, VoiceRecognition} from 'react-voice-components';

@sho13
Copy link

sho13 commented Oct 6, 2017

@tjiang11 I had the same problem, i resolved it by adding the /(?!react-voice-components)/ to my exclude line in my webpack.config.

it's referenced here webpack/webpack#2031

{
  test: /\.jsx?$/,
  exclude: /node_modules\/(?!react-voice-components)/,
  use: [
    'babel-loader',
  ],
}

@DamnedScholar
Copy link

@sho13 Would it be possible for me to see your whole config file?

@jangidhitesh
Copy link

Copy VoiceRecognition.js, VoicePlayer.js in you src folder. And import them from there. You might have to add a loader in webpack file also (or rewriting all functions to this form
createSpeech() { const defaults = { text: '',
)

@DamnedScholar
Copy link

I solved it by importing them with a loader directive:

import { VoicePlayer, VoiceRecognition } from 'babel-loader!react-voice-components'

@bchang1213
Copy link

I forked this module and fixed the ES5 incompatability by rewriting the functions in the same way as @thevaleriemack .

I have made a pull request for the fixes, but in the meantime, you can fork my repo from here: https://github.com/bchang1213/react-voice-components

@stahlmanDesign
Copy link

@bchang1213 Your fix worked for me

@MonaTem
Copy link

MonaTem commented Mar 31, 2018

@jangidhitesh your fix worked for me, but I had to modify the code in VoicePlayer.js by removing references to the end method, which doesn't exist for speechsynthesis.

@flamincode
Copy link

@tjiang11 your fix worked for me. Thanks.

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

10 participants