nearform / graphql-hooks

🎣 Minimal hooks-first GraphQL client
Other
1.88k stars 90 forks source link

Src folder with typescript files shipped in npm package #991

Closed arminh closed 1 year ago

arminh commented 1 year ago

Package

graphql-hooks

Environment

Description

My react 18 project is using a plugin which in turn makes use of the grapqhql-hooks library. Since the recent update to webpack 5 an error is thrown during the build process:

ERROR in ../node_modules/graphql-hooks/src/events.ts 1:7
  Module parse failed: Unexpected token (1:7)
  You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
  > export enum Events {
  |   DATA_INVALIDATED = 'DATA_INVALIDATED',
  |   DATA_UPDATED = 'DATA_UPDATED'`

For some reason the src folder is shipped with the graphql-hooks library and webpack tries to load the typescript files contained in it. I don't see a reason why the src folder should be shipped with the package.

How to reproduce

I couldn't reproduce the error in a fresh react app. However, the src folder is contained in node_modules/graphql-hooks if you just create a new project and install the graphql-hooks library from npm: npm i graphql-hooks@6.0.5

Suggested solution

It seems like there is a reference to one or more of the typescript files from the .dt.s files or something similar. I couldn't figure out though, which one. Furthermore the folder structure in the /lib/types folder seems weird. Besides the _d.ts files it includes another types folder (/lib/types/types) that only contains the common-types.d.ts file. Could you please have a look if there is an unintended reference?

stearm commented 1 year ago

Hello, @arminh. I am unable to reproduce the problem using your same package versions. Could you please provide a small repo where the bug is reproducible? Meanwhile, I'm working on removing the src folder from the published ones, as you stated this should be the issue.

arminh commented 1 year ago

Hey @stearm! Unfortunately I wasn't able to reproduce the error in isolation. I am only indirectly using graphql-hooks via another library, with no direct access to the source code. So I don't know exactly how they are using it. Thanks for taking care of the src folder that quickly, though!