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 319ee0d
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 1 deletion.
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
30 changes: 30 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,30 @@
const rollup = require('rollup');
import json from '@rollup/plugin-json';
import commonjs from '@rollup/plugin-commonjs';

describe('@rollup/plugin-commonjs', () => {

it('bundles into es6 without circular dependencies issues', async () => {
const outputOptions = {
exports: 'named',
name: 'apollo',
file: "./tmp/rollup.mjs",
format: "umd",
sourcemapExcludeSources: false
};
const bundle = await rollup.rollup({
input: "./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');
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
SchemaReport,
SchemaReportMutationVariables,
SchemaReportMutation,
ReportSchemaResponse,
ReportSchemaResponse,
} from './operations';

export const schemaReportGql = print(gql`
Expand Down

0 comments on commit 319ee0d

Please sign in to comment.