Skip to content

Commit

Permalink
Only work around Rollup bug for router entrypoint in new interfaces (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
emmatown authored Oct 30, 2020
1 parent b29a5c5 commit d91a638
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
19 changes: 1 addition & 18 deletions packages-next/admin-ui/src/apollo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,4 @@
* packages import the same instance of apollo.
*/

// not using export * because Rollup emits CJS code that redefines __esModule which causes problems because __esModule generally isn't a configurable property
export {
useQuery,
useMutation,
useLazyQuery,
gql,
ApolloError,
InMemoryCache,
ApolloClient,
ApolloProvider,
} from '@apollo/client';
export type {
ServerError,
ServerParseError,
QueryResult,
DocumentNode,
TypedDocumentNode,
} from '@apollo/client';
export * from '@apollo/client';
7 changes: 6 additions & 1 deletion packages-next/admin-ui/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
* packages import the same instance of next's router.
*/

// not using export * because Rollup emits CJS code that redefines __esModule which causes problems because __esModule generally isn't a configurable property
// not using export * because Rollup's CJS re-export code doesn't ignore __esModule on the exports object so it will re-define it if it exists
// and since __esModule isn't configurable(at least with the code that's _generally_ emitted by Rollup, Babel, tsc and etc.)
// an error will be thrown
// that's normally not a problem because modules generally use Object.defineProperty(exports, '__esModule', { value: true })
// which means that the property isn't enumerable but Next uses Babel's loose mode and Babel's loose mode for the CJS transform
// uses exports.__esModule = true instead of defineProperty so the property is enumerable
export { createRouter, makePublicRouterInstance, Router, useRouter, withRouter } from 'next/router';
export type { NextRouter } from 'next/router';

Expand Down

0 comments on commit d91a638

Please sign in to comment.