Skip to content

issue repro with @apollo/client + typescript + webpack

Notifications You must be signed in to change notification settings

Billy-/apollo-client-test

Repository files navigation

Issue Repro for @apollo/client with TypeScript and Webpack

git clone git@github.com:Billy-/apollo-client-test.git
npm i
npm run dev

Two issues:

  1. Lots of warnings due to missing/broken sourcemaps

  2. The client crashes due to React being undefined at https://github.com/apollographql/apollo-client/blob/d470c964db46728d8a5dfc63990859c550fa1656/src/react/context/ApolloContext.ts#L32

I noticed that in the webpack output all the React imports inside @apollo/client are importing from @apollo/client/react/index.js for some reason:

Webpacked output for ApolloContext
/***/ "../node_modules/@apollo/client/react/context/ApolloContext.js":
/*!*********************************************************************!*\
  !*** ../node_modules/@apollo/client/react/context/ApolloContext.js ***!
  \*********************************************************************/
/*! exports provided: getApolloContext, resetApolloContext */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getApolloContext", function() { return getApolloContext; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resetApolloContext", function() { return resetApolloContext; });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "../node_modules/@apollo/client/react/index.js");


var contextSymbol = typeof Symbol === 'function' && Symbol.for ?
    Symbol.for('__APOLLO_CONTEXT__') :
    '__APOLLO_CONTEXT__';
function resetApolloContext() {
    Object.defineProperty(react__WEBPACK_IMPORTED_MODULE_0__["default"], contextSymbol, {
        value: react__WEBPACK_IMPORTED_MODULE_0__["default"].createContext({}),
        enumerable: false,
        configurable: true,
        writable: false,
    });
}
function getApolloContext() {
    if (!react__WEBPACK_IMPORTED_MODULE_0__["default"][contextSymbol]) {
        resetApolloContext();
    }
    return react__WEBPACK_IMPORTED_MODULE_0__["default"][contextSymbol];
}




/***/ }),

About

issue repro with @apollo/client + typescript + webpack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published