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

Is this in npm? #2

Open
aguynamedben opened this issue Jan 12, 2021 · 2 comments
Open

Is this in npm? #2

aguynamedben opened this issue Jan 12, 2021 · 2 comments

Comments

@aguynamedben
Copy link

aguynamedben commented Jan 12, 2021

Hi, I'm really liking the sister package to this (redux-json-api) and it's saving me from a ton of server-side and client-side boilerplate. Thank you for publishing that project. 🙏

I tried using this as well, putting this in my package.json

    "react-redux-json-api": "redux-json-api/react-redux-json-api#d17c93",

But the import is failing, I believe because getting this from a GitHub checkout leaves the "main": "lib/index.js", file un-built.

Did you ever consider putting this in npm like redux-json-api is?

What's the alternative? Some sort of after yarn install hook in my project's package.json that runs the build commands for react-redux-json-api? I think for some other dependencies I've forked the project just to commit the built files.

Thanks again for making this project available. 🙏 🙏 🙏

@aguynamedben
Copy link
Author

Hmm, I forked and built my own version (diff), commenting out /lib in .gitignore, and now getting this error.

image

I know this isn't a broadly used library, but any quick tips on where to go could be helpful! I'm happy to contribute back fixes and improvements.

@aguynamedben
Copy link
Author

I tried getting this working in my project a few different ways, but I'm not having any luck. This work attempts were done using my fork of react-redux-json-api, which upgrades to Babel 7, upgrades rollup, etc.

My fork's branch with updates: getcommande#1

Environment

My project is an Electron 11 project, so I'm probably importing using Node 12.8.3. I'm not well-versed on the history of amd, cjs, es, etc. but I think this means my environment would like dependencies such as this library to be built using cjs. However, my project uses ES6, webpack, and babel, so maybe there's a way I can use an 'es' packaged dependency as well. 🤷‍♂️

Here are the things I tried...

Attempt 1: Import while using 'es' in rollup

The build for react-redux-json-api works fine, and my project's webpack build works fine, but then I get a runtime error I'm not sure what to do about.

image

Attempt 2: Import while using 'cjs' in rollup**

// in rollup.config.js
{ file: pkg.browser, format: 'cjs', exports: 'auto' },
// (exports was added because rollup told me to do so)

The build for react-redux-json-api works fine, and my project's webpack build works fine, but then I get a runtime error when navigating to the component that uses Query from this package.

image

I don't understand where in react-redux-json-api's code this error is coming from (invariant?), and my component tree does have at the root level:

  return (
    <HotKeys handlers={HANDLERS} keyMap={hotkeysKeyMap.common} root="true">
      <ErrorBoundary
        placeholder={AppError}
      >
        <Provider store={store}>
          <ConnectedRouter history={history}>
            <Routes />
          </ConnectedRouter>
        </Provider>
      </ErrorBoundary>
    </HotKeys>
  );

Attempt 3: Import directly from /src

My project uses JavaScript + Flow as well, so I tried importing Query directly from /src, i.e. import Query from 'react-redux-json-api/src';. But that produces a webpack build-time error I'm not sure how to address. I upgraded core-js in my own "host" project, but no dice.

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

1 participant