Apollo-client: Apollo-boost uses commonjs module imports instead of es2015

Created on 17 Aug 2018  路  3Comments  路  Source: apollographql/apollo-client

I was trying to optimise bundling of an application built using apollo-boost, removed all the runtime dependencies on graphql library but the bundle would still contain the library.

Intended outcome:

Webpack to tree-shake graphql-tag and graphql in an application using apollo-boost but not using gql.

Actual outcome:

Full graphql library is still bundled because of

[47] ./node_modules/graphql-tag/src/index.js 5.13 KiB {1} [built]
     cjs require graphql-tag [24] ./node_modules/apollo-boost/lib/index.js 34:20-42
// node_modules/apollo-boost/lib/index.js:34
var graphql_tag_1 = require("graphql-tag");
exports.gql = graphql_tag_1.default;

This is happening because https://github.com/apollographql/apollo-client/blob/master/packages/apollo-boost/tsconfig.json uses

"module": "commonjs",

However the rest of the packages in the repository use

"extends": "../../tsconfig.base",

That contains

"module": "es2015"

How to reproduce the issue:
Doesn't require reproducing.

Versions

  System:
    OS: Linux 4.14 NixOS 18.09pre149044.6afd19e699c (Jellyfish) 18.09pre149044.6afd19e699c (Jellyfish)
  Binaries:
    Node: 8.11.3 - ~/.nix-profile/bin/node
    Yarn: 1.9.4 - ~/.nix-profile/bin/yarn
    npm: 5.6.0 - ~/.nix-profile/bin/npm
  npmPackages:
    apollo-boost: ^0.1.13 => 0.1.13

Most helpful comment

This is being worked on in https://github.com/apollographql/apollo-client/pull/3817. We should have that PR merged shortly. Thanks!

All 3 comments

This is being worked on in https://github.com/apollographql/apollo-client/pull/3817. We should have that PR merged shortly. Thanks!

@hwillson Cool! Thanks for the great work!

This should have been closed with #3817.

Was this page helpful?
0 / 5 - 0 ratings