Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process ESM .js modules in ./dist with Rollup, again. (apollographql#…
…6657) This partially reverts commit 627bd1b from PR apollographql#6656. PR apollographql#6656 removed a function called `prepareESM`, which was no longer needed for the sake of running `rollup-plugin-invariant`, but which had another benefit: Rollup would replace imports/exports like // Example exports from ./dist/index.js: export * from './core' export * from './react' with their fully-expanded (and file-extensioned) equivalents: ... export { makeVar } from './cache/inmemory/reactiveVars.js'; export { defaultDataIdFromObject } from './cache/inmemory/policies.js'; export { InMemoryCache } from './cache/inmemory/inMemoryCache.js'; export { ApolloClient } from './core/ApolloClient.js'; ... Although this may look like more code, it effectively saves the bundler/browser work by reducing indirection, and including the .js file extensions makes this code a little more browser- and Rollup-friendly (that is, you shouldn't have to use @rollup/plugin-node-resolve to bundle @apollo/client with Rollup). The expanded imports/exports are also closer to the ESM code shipped with @apollo/[email protected], so restoring this behavior helps with the goal of keeping the changes in apollographql#6656 backwards-compatible for v3.1.0. Note that the CommonJS bundles used by Node.js are built before this step, so this expansion of imports does not affect Node.js.
- Loading branch information