Giter VIP home page Giter VIP logo

Comments (22)

n7best avatar n7best commented on May 20, 2024 11

@nikomc0 encounter the same issue while using create-react-app.

What I did to solve around is to import the pre-compiled version directly and use the RSSParser instead of Parse and I also have to declare eslint global namespace to avoid the create-react-app build errors.

/* global RSSParser */
import 'rss-parser/dist/rss-parser.min.js';

let parser = new RSSParser();

also, I tried to add module property to the package.json which pass the build but since two version has different parser naming, it wasn't working properly.

from rss-parser.

cgpomeroy avatar cgpomeroy commented on May 20, 2024 3

Can someone explain further how to implement @n7best 's workaround?
I've tried the below with no success.

captura de pantalla de 2018-06-03 00-45-48

from rss-parser.

tomclark avatar tomclark commented on May 20, 2024 2

Was in a bit of a hurry, so I just downgraded to 2.12.1 which works absolutely fine and got me moving.

Will have a go at importing the file directly when I get a chance at the weekend and report back.

Thanks for the quick reply! 👍

from rss-parser.

ranpox avatar ranpox commented on May 20, 2024 2

@cgpomeroy
Hi, have you found the way to solve it? Workaround from @n7best doesn't work for me.

from rss-parser.

415DomSmith avatar 415DomSmith commented on May 20, 2024 1

@cgpomeroy

I was able to implement in my create-react-app.

I'm using Axios to fetch the page data.

const RSSParser = require('rss-parser');

getWiredFeed(){
    axios.get('https://www.wired.com/feed')
    .then((res) => {
      let parser = new RSSParser();
      parser.parseString(res.data, (err, feed)=> {
        this.setState({
          wiredItems: feed.items
        });
      });
    })
    .catch((err) => {
      console.log(err);
    })
  }

from rss-parser.

rbren avatar rbren commented on May 20, 2024 1

I would try using the file in dist/rss-parser.min.js. If you're using version 2.x, you should also use the README from that version, as the API has changed. In particular, RSSParser is not a constructor in 2.x - instead, you use RSSParser.parseUrl(...)

from rss-parser.

rbren avatar rbren commented on May 20, 2024

Thanks for the report. We did switch to ES6 in 3.0.0

From the bit.ly link, it says "ask that the package be published pre-compiled". We have a pre-compiled version in dist/rss-parser.min.js. Are you able to import that file?

from rss-parser.

nikomc0 avatar nikomc0 commented on May 20, 2024

I've got a noob question. Im not quite sure exactly how to properly import the min version.

from rss-parser.

tomclark avatar tomclark commented on May 20, 2024

What client technology are you using?

At the root of the project, run:

npm install --save rss-parser

It's then in node_modules/rss-parser/dist/rss-parser.min.js.

How and where you include that in your pages then depends what client framework you're using (i.e.React, Angular etc).

from rss-parser.

nikomc0 avatar nikomc0 commented on May 20, 2024

Im using react and getting "Parser is not a constructor" error.

screen shot 2018-02-03 at 6 13 40 pm

from rss-parser.

rbren avatar rbren commented on May 20, 2024

It should be new RSSParser()

from rss-parser.

rbren avatar rbren commented on May 20, 2024

Thanks @n7best. Any tips on how we can change rss-parser to better support create-react-app?

from rss-parser.

JochenFromm avatar JochenFromm commented on May 20, 2024

Had the same issue for a Travis CI integration of an app created with create-react-app. The Travis log says

> react-scripts build
Creating an optimized production build...
Failed to compile.
Failed to minify the code from this file: 
 	./node_modules/rss-parser/lib/parser.js:16 

The create-react-app README argues the package should be published pre-compiled to ES5 (not ES6).

from rss-parser.

rbren avatar rbren commented on May 20, 2024

I tried switching to babel-preset-env, but it gives the same result as babel-preset-2015

The code generated by babel (everything in ./dist/) is all ES5, per the README. So I'm not sure what the problem might be.

from rss-parser.

Locheed avatar Locheed commented on May 20, 2024

Any news about a solution for this? Just noticed the same problem and came searching some answers.

from rss-parser.

Locheed avatar Locheed commented on May 20, 2024

Yea CRA doesn't seem to transpile external dependencies to ES5. It has to be precompiled.
facebook/create-react-app#1125

workaround from @n7best works fine now.

from rss-parser.

Ueland avatar Ueland commented on May 20, 2024

Jumping in on this thread after noticing the same issue, will use the workaround for now.

from rss-parser.

gazpachu avatar gazpachu commented on May 20, 2024

I will also use the workaround for now

from rss-parser.

udeshx avatar udeshx commented on May 20, 2024

Using the suggestion from @415DomSmith I got the example to work without the need for axios

const RSSParser = require('rss-parser');
const CORS_PROXY = "https://cors-anywhere.herokuapp.com/"

let parser = new RSSParser();
parser.parseURL(CORS_PROXY + 'https://www.reddit.com/.rss', function(err, feed) {
  console.log(feed.title);
  feed.items.forEach(function(entry) {
    console.log(entry.title + ':' + entry.link);
  })
})

from rss-parser.

antoinedelp avatar antoinedelp commented on May 20, 2024

Hi @bobby-brennan, thanks for your great RSS Parser. Everything works fine in development, but I get the same "Failed to minify the code from this file: ./node_modules/rss-parser/lib/parser.js:16" error message when building my project.

The workaround (importying the minified version) is not working as I get this error message : RSSParser() is not a constructor.

By any chance, did you manage to identify what the issue is, or at least do you recommend a specific workaround to solve this issue?
Thanks!

from rss-parser.

anshulsinha1101 avatar anshulsinha1101 commented on May 20, 2024

@nikomc0 encounter the same issue while using create-react-app.

What I did to solve around is to import the pre-compiled version directly and use the RSSParser instead of Parse and I also have to declare eslint global namespace to avoid the create-react-app build errors.

/* global RSSParser */
import 'rss-parser/dist/rss-parser.min.js';

let parser = new RSSParser();

also, I tried to add module property to the package.json which pass the build but since two version has different parser naming, it wasn't working properly.

If i am using Your method i am getting a compile time error of

TS2304: Cannot find name 'RSSParser'

please help me to resolve this

from rss-parser.

JohnnyHandy avatar JohnnyHandy commented on May 20, 2024

@415DomSmith solution worked for me! The only difference is that I had to use the cors proxy.

from rss-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.