Skip to content

Commit

Permalink
Replace explicit externalPackages with test of non-relativity.
Browse files Browse the repository at this point in the history
We don't currently have any external packages that we want to bundle into
@apollo/client, so we can get away with considering any non-relative
import to be external. The results of this test exactly match the current
contents of externalPackages, so it should be safe to remove that Set.

This should save us from making mistakes like the one I fixed in #6624,
and if we ever do want to bundle something from node_modules into the
@apollo/client bundle again, we can easily carve out an exception.
  • Loading branch information
benjamn committed Jul 24, 2020
1 parent 4638b51 commit f76db47
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,15 @@ const entryPoints = require('./entryPoints');

const distDir = './dist';

const externalPackages = new Set([
'@wry/context',
'@wry/equality',
'fast-json-stable-stringify',
'graphql-tag',
'graphql/execution/execute',
'graphql/language/printer',
'graphql/language/visitor',
'hoist-non-react-statics',
'optimism',
'prop-types',
'react',
'subscriptions-transport-ws',
'symbol-observable',
'ts-invariant',
'tslib',
'zen-observable',
]);
function isExternal(id) {
return !(id.startsWith("./") || id.startsWith("../"));
}

function prepareCJS(input, output) {
return {
input,
external(id) {
return externalPackages.has(id);
return isExternal(id);
},
output: {
file: output,
Expand Down Expand Up @@ -77,8 +62,7 @@ function prepareBundle({
return {
input: `${dir}/index.js`,
external(id, parentId) {
return externalPackages.has(id) ||
entryPoints.check(id, parentId);
return isExternal(id) || entryPoints.check(id, parentId);
},
output: {
file: `${dir}/${bundleName}.cjs.js`,
Expand Down

0 comments on commit f76db47

Please sign in to comment.