Skip to content

Commit

Permalink
Fix dependency issue when using @rollup/plugin-commonjs (#5797)
Browse files Browse the repository at this point in the history
  • Loading branch information
DSergiu authored Oct 19, 2021
1 parent ea5a0e7 commit c35086a
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 10 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.3.0",
"@hapi/hapi": "20.2.1",
"@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.84",
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');
});
});
8 changes: 8 additions & 0 deletions packages/apollo-server-core/src/gql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This currently provides the ability to have syntax highlighting as well as
// consistency between client and server gql tags
import type { DocumentNode } from 'graphql';
import gqlTag from 'graphql-tag';
export const gql: (
template: TemplateStringsArray | string,
...substitutions: any[]
) => DocumentNode = gqlTag;
Loading

0 comments on commit c35086a

Please sign in to comment.