Giter VIP home page Giter VIP logo

Comments (7)

wKich avatar wKich commented on June 12, 2024 1

@patrickjm could you please take a look at this. It seems you fixed types in source code in this PR #2324 but the final package.json doesn't have that fix

from graphql-modules.

basicdays avatar basicdays commented on June 12, 2024

My current workaround is just to do the following when importing:

import graphqlModules = require("graphql-modules");

const { gql, createModule } = graphqlModules;

from graphql-modules.

basicdays avatar basicdays commented on June 12, 2024

Good news, I edited the graphql-modules/package.json file in my node_modules directly and got it working with the following:

{
  "main": "index.js",
  "module": "index.mjs",
  "typings": "index.d.ts",
  "typescript": {
    "definition": "index.d.ts"
  },
  "exports": {
    ".": {
      "require": {
        "types": "./index.d.ts",
        "default": "./index.js"
      },
      "import": {
        "types": "./index.d.ts",
        "default":"./index.mjs"
      }
    },
    "./*": {
      "require": {
        "types": "./*.d.ts",
        "default": "./*.js"
      },
      "import": {
        "types": "./*.d.ts",
        "default": "./*.mjs"
      }
    },
    "./package.json": "./package.json"
  }
}

from graphql-modules.

basicdays avatar basicdays commented on June 12, 2024

So I just revisted this again. Was going to do a PR to fix this, but I noticed that the package.json in the source includes the proper typings: https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/package.json#L21

However the package.json you get from the package published to npm is missing the exports["."].types and exports["./*"].types fields. I've used patch-package to at least rectify this for now, but is this a bug in the publishing process that's changing them? Does the package just need to get republished to get the correct exports?

Here's the patch-package diff for reference:

diff --git a/node_modules/graphql-modules/package.json b/node_modules/graphql-modules/package.json
index 00c64ab..c5b45b2 100644
--- a/node_modules/graphql-modules/package.json
+++ b/node_modules/graphql-modules/package.json
@@ -30,11 +30,13 @@
   "exports": {
     ".": {
       "require": "./index.js",
-      "import": "./index.mjs"
+      "import": "./index.mjs",
+      "types": "./index.d.ts"
     },
     "./*": {
       "require": "./*.js",
-      "import": "./*.mjs"
+      "import": "./*.mjs",
+      "types": "./*.d.ts"
     },
     "./package.json": "./package.json"
   }

from graphql-modules.

itpropro avatar itpropro commented on June 12, 2024

Any updates on this @patrickjm ? These are the exports from the published npmjs package, they seem to miss the types:
image

from graphql-modules.

patrickjm avatar patrickjm commented on June 12, 2024

No updates here, would recommend making another PR for this one.

from graphql-modules.

itpropro avatar itpropro commented on June 12, 2024

No updates here, would recommend making another PR for this one.

The source code looks fine, this seems to be connected to the publishing pipeline.

from graphql-modules.

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.