Skip to content

Commit

Permalink
Add rollup test
Browse files Browse the repository at this point in the history
  • Loading branch information
DSergiu committed Oct 9, 2021
1 parent b2fc35e commit fd284d9
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 0 deletions.
210 changes: 210 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
"@graphql-tools/utils": "8.2.5",
"@hapi/hapi": "20.2.0",
"@josephg/resolvable": "1.0.1",
"@rollup/plugin-commonjs": "21.0.0",
"@rollup/plugin-json": "4.1.0",
"@sinonjs/fake-timers": "8.0.1",
"@types/async-retry": "1.4.3",
"@types/aws-lambda": "8.10.83",
Expand Down Expand Up @@ -123,6 +125,7 @@
"qs-middleware": "1.0.3",
"request-promise": "4.2.6",
"requisition": "1.7.0",
"rollup": "2.58.0",
"supertest": "6.1.6",
"test-listen": "1.1.0",
"ts-jest": "27.0.5",
Expand Down
27 changes: 27 additions & 0 deletions packages/apollo-server-core/src/__tests__/rollupCommonJs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const rollup = require('rollup');
import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';
import path from 'path';

describe('@rollup/plugin-commonjs', () => {
it('bundles into es6 without circular dependencies issues', async () => {
const outputOptions = {
exports: 'named',
name: 'apollo',
format: 'umd',
sourcemapExcludeSources: false,
};
const bundle = await rollup.rollup({
input: path.resolve(__dirname, '..', '..', 'dist', 'index.js'),
plugins: [json(), commonjs()],
onwarn: () => {
/* suppress warnings */
},
});
const { output } = await bundle.generate(outputOptions);
const indexBundle = output[0].code;
var varDefinedAfterBundle;
eval(`${indexBundle}; varDefinedAfterBundle = 'foo';`);
expect(varDefinedAfterBundle).toEqual('foo');
});
});

0 comments on commit fd284d9

Please sign in to comment.