Open marvinhagemeister opened 2 weeks ago
The problem occurs because Deno picks the wrong entry point.
Deno is picking the same entry point as Node. I believe it's correct to use "main". I think probably there is something wrong with the cjs export analysis.
> cat index.mjs
import * as gql from "graphql-tag";
console.log(gql);
> deno -A index.mjs
[Module: null prototype] {
default: <ref *1> [Function: gql] {
gql: [Circular *1],
resetCaches: [Function: resetCaches],
disableFragmentWarnings: [Function: disableFragmentWarnings],
enableExperimentalFragmentVariables: [Function: enableExperimentalFragmentVariables],
disableExperimentalFragmentVariables: [Function: disableExperimentalFragmentVariables],
default: [Circular *1]
}
}
> node index.mjs
[Module: null prototype] {
__esModule: undefined,
default: <ref *1> [Function: gql] {
gql: [Circular *1],
resetCaches: [Function: resetCaches],
disableFragmentWarnings: [Function: disableFragmentWarnings],
enableExperimentalFragmentVariables: [Function: enableExperimentalFragmentVariables],
disableExperimentalFragmentVariables: [Function: disableExperimentalFragmentVariables],
default: [Circular *1]
},
disableExperimentalFragmentVariables: [Function: disableExperimentalFragmentVariables],
disableFragmentWarnings: [Function: disableFragmentWarnings],
enableExperimentalFragmentVariables: [Function: enableExperimentalFragmentVariables],
gql: <ref *1> [Function: gql] {
gql: [Circular *1],
resetCaches: [Function: resetCaches],
disableFragmentWarnings: [Function: disableFragmentWarnings],
enableExperimentalFragmentVariables: [Function: enableExperimentalFragmentVariables],
disableExperimentalFragmentVariables: [Function: disableExperimentalFragmentVariables],
default: [Circular *1]
},
resetCaches: [Function: resetCaches]
}
The module is clearly cjs and re-exports a function from a UMD module
module.exports = require('./lib/graphql-tag.umd.js').gql;
gql
is a function that has a "default" property that is referencing itself.gql
function Object.defineProperty(exports, '__esModule', { value: true });
They use roll-up to generate it and it has been 3 years since the last update. These hybrid packages make me mad.
The published code: https://www.npmjs.com/package/graphql-tag?activeTab=code
Reported in Discord: https://discord.com/channels/684898665143206084/1279102082452029520/1279102082452029520
Steps to reproduce
Run this snippet:
Output:
The problem occurs because Deno picks the wrong entry point.
Version: Deno 1.46.2+d71eebb