Skip to content

Commit

Permalink
PREAPPS-7505 added apollo-client as external dependancy
Browse files Browse the repository at this point in the history
  • Loading branch information
sitaram-mulik-synacor authored and silentsakky committed Jan 3, 2024
1 parent 3b4ad25 commit 67e9909
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"clean": "rimraf dist",
"build": "npm-run-all clean generateSchemaTypes rollup:* -p build:ts minify:* copySchema",
"build:ts": "tsc --emitDeclarationOnly --declaration --outDir \"dist\"",
"build:analyze": "visualize=true npm run build",
"copySchema": "copyfiles -f src/schema/schema.graphql dist",
"rollup:cjs": "cross-var rollup -c rollup.config.js -m -f cjs -n $npm_package_amdName $npm_package_source -o $npm_package_main",
"rollup:umd": "cross-var rollup -c rollup.config.js -m -f umd -n $npm_package_amdName $npm_package_source -o $npm_package_umd_main",
Expand Down Expand Up @@ -61,8 +62,8 @@
"@graphql-codegen/typescript": "^4.0.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-graphql": "^1.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^11.1.5",
"@types/graphql": "^14.5.0",
"@types/lodash": "^4.14.182",
Expand All @@ -81,6 +82,7 @@
"rimraf": "^5.0.1",
"rollup": "^2.75.0",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup-plugin-visualizer": "^5.11.0",
"tslib": "^2.5.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
Expand Down
27 changes: 13 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ import graphql from '@rollup/plugin-graphql';
import localResolve from 'rollup-plugin-local-resolve';
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import pkg from './package.json';
import { visualizer } from 'rollup-plugin-visualizer';

let FORMAT = process.env.FORMAT;
const FORMAT = process.env.FORMAT;

// graphql-tools currently has a rollup build failure, so always call it an external until they fix it
// otherwise, make all npm production dependencies external, plus their subpath usages
// throughout the codebase, which rollup doesn't automatically pick up on
let external = FORMAT==='es' ?
Object.keys(pkg.dependencies)
.concat(
['castArray', 'get','isError', 'isObject', 'mapValues', 'reduce', 'omitBy', 'uniqBy', 'concat', 'uniqBy', 'differenceBy', 'forEach'].map(v => 'lodash/'+v),
['graphql']) :
[];
const externalDeps = [
'@apollo/client',
'graphql',
'lodash',
'mitt'
];

const getExternalDeps = id => externalDeps.find(pkgName => id.includes('/node_modules/' + pkgName + '/'));

export default {
external,
...(FORMAT==='es' && { external: getExternalDeps }),
context: 'commonjsGlobal', // what should "this" be at the top level when it is used by another module
plugins: [
graphql(),
Expand All @@ -34,9 +32,10 @@ export default {
extensions: ['.ts'],
exclude: 'node_modules/**',
babelHelpers: 'bundled'
})
}),
...(process.env.visualize ? [visualizer({ open: true }) ] : [])
],
output: {
exports: FORMAT==='es' ? null : 'named'
},
}
};

0 comments on commit 67e9909

Please sign in to comment.