Skip to content

The module breaks with create-react-app v4 applications (parseUrl is not a function) #152

@niryarden

Description

@niryarden

Issue:

The module breaks, and as a result unusable from React applications that were created using the 4th version of create-react-app. (create-react-app has a 5th version in the which the problem does not exist, but it can be very complicated to upgrade it). Many React applications are still using the 4th version and as a result cannot use this great module 😖
I believe the reason for the issue is this commit:
IonicaBizau/parse-url@a10861c#diff-92bbac9a308cd5fcf9db165841f2d90ce981baddcb2b1e26cfff170929af3bd1L51
(and this can also be relevant - https://stackoverflow.com/a/43249395)

Reproducion Steps:

Create a new create-react-app application

npx create-react-app my-app

Downgrade it to create-react-app v4

in package json of the project, change react-scripts dependency to version ^4.0.3, and run

npm install

Add git-url-parse to your project and use it

npm install git-url-parse

and use the module in App.js, for example:

import { useEffect } from 'react';
import gitUrlParse from 'git-url-parse';

function App() {
  useEffect(() => {
    const res = gitUrlParse("https://github.com/IonicaBizau/git-url-parse");
    console.log(res);
  }, [])

  return (
    <div />
  );
}

export default App;

Run the app and get the error in the browser console:

npm start

console:

index.js:29 Uncaught TypeError: parseUrl is not a function
    at gitUp (index.js:29:1)
    at gitUrlParse (index.js:48:1)
    at App.js:6:1
    at commitHookEffectListMount (react-dom.development.js:23150:1)
    at commitPassiveMountOnFiber (react-dom.development.js:24926:1)
    at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
    at commitPassiveMountEffects_begin (react-dom.development.js:24878:1)
    at commitPassiveMountEffects (react-dom.development.js:24866:1)
    at flushPassiveEffectsImpl (react-dom.development.js:27039:1)
    at flushPassiveEffects (react-dom.development.js:26984:1)
    at react-dom.development.js:26769:1
    at workLoop (scheduler.development.js:266:1)
    at flushWork (scheduler.development.js:239:1)
    at performWorkUntilDeadline (scheduler.development.js:533:1)
    at run (setImmediate.js:40:1)
    at runIfPresent (setImmediate.js:69:1)
    at onGlobalMessage (setImmediate.js:109:1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions