Skip to content

ECMAScript module loading error #40

@ghost

Description

Thank you for your great package. I have one question:

When using the program with ESM (.mjs import) I get an error with the current version of Node (9.4.0).

(node:4290) ExperimentalWarning: The ESM module loader is experimental.
file:///Users/.../node_modules/apollo-upload-server/lib/types.mjs:1
import { GraphQLScalarType } from 'graphql'
         ^^^^^^^^^^^^^^^^^
SyntaxError: The requested module does not provide an export named 'GraphQLScalarType'
    at ModuleJob._instantiate (internal/loader/ModuleJob.js:86:19)
    at <anonymous>
error Command failed with exit code 1.

The problem should be resolved by changing the following lines in types.mjs:

import graphql from 'graphql'

const { GraphQLScalarType } = graphql

I think GraphQL exports currently only with CJS and not yet with ESM and therefore there is only the "default export". Since you are running this program with Babel, you will not get an error. I use the package directly with Node.

https://nodejs.org/api/esm.html#esm_interop_with_existing_modules

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions