Skip to content

Can't import from graphql-type-json #277

Description

@lenneis

Hi,

this is a minimal code snippet from a module I am developing:

import { GraphQLJSONObject } from 'graphql-type-json';

It lives inside a xxx.mjs file, which is imported by other ES6 modules in the application.

When I run this (node version 13.14) I get a fatal error:

import { GraphQLJSONObject } from 'graphql-type-json'; ^^^^^^^^^^^^^^^^^ SyntaxError: The requested module 'graphql-type-json' does not provide an export named 'GraphQLJSONObject'

I looked at the package.json file in your module and I am not sure it does the right thing, according to the node.js documentation:

"module": "es/index.js",

This is ignored by node, according to their docs (https://nodejs.org/docs/latest-v13.x/api/esm.html). Instead, one is supposed to use a conditional export in package.json , like this:

"exports": { "import": "./main-module.js", "require": "./main-require.cjs" },
main-module.js does the ES6 thing and main-require.cjs the commonJS one. Any thoughts?

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