Skip to content

ng6 - Can't reexport the named export 'graphql' from non EcmaScript module #10744

Closed
@DmitryEfimenko

Description

@DmitryEfimenko

Versions

Angular CLI: 6.0.0
Node: 9.8.0
OS: win32 x64
Angular: 6.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/flex-layout              5.0.0-beta.14
@angular/pwa                      0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

  • ng new fresh
  • cd fresh
  • npm i graphql@latest
  • add the following to the app.module.ts:
import { graphql } from 'graphql';
...
export class AppModule {
  constructor() {
    // it does not matter what it is below as long as we're using something from `graphql`
    const t = graphql();
  }
}
  • npm start

Observed behavior

ERROR in ./node_modules/graphql/index.mjs
2:0-49 Can't reexport the named export 'graphql' from non EcmaScript module (only default export is available)
ERROR in ./node_modules/graphql/index.mjs
2:0-49 Can't reexport the named export 'graphqlSync' from non EcmaScript module (only default export is available)
...
// continues reporting the same error for all .mjs files

Desired behavior

Build should work

Mention any other details that might be useful (optional)

I don't know much about .mjs, but it appears it might be used instead of .js in some cases: http://2ality.com/2017/05/es-module-specifiers.html

It appears this might be an issue of Webpack 4 configuration. See this for details.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions