Skip to content

Commit

Permalink
Please use very old javascript syntax - said IE (#1886)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Aug 5, 2020
1 parent b508641 commit b99f40a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/webpack-loader-runtime/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DefinitionNode } from 'graphql';

export const uniqueCode = `
const names = {};
var names = {};
function unique(defs) {
return defs.filter((def) => {
return defs.filter(function (def) {
if (def.kind !== 'FragmentDefinition') return true;
const name = def.name.value;
var name = def.name.value;
if (names[name]) {
return false;
} else {
Expand Down
7 changes: 3 additions & 4 deletions packages/webpack-loader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ function expandImports(source: string, options: Options) {
const lines = source.split(/\r\n|\r|\n/);
let outputCode = options.importHelpers
? `
const { useUnique } = require('@graphql-tools/webpack-loader-runtime');
const unique = useUnique();
var useUnique = require('@graphql-tools/webpack-loader-runtime').useUnique;
var unique = useUnique();
`
: `
${uniqueCode}
Expand Down Expand Up @@ -75,7 +74,7 @@ export default function graphqlLoader(source: string) {
}

const headerCode = `
const doc = ${JSON.stringify(doc)};
var doc = ${JSON.stringify(doc)};
`;

let outputCode = '';
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack-loader/tests/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('basic query', () => {
`;
const doc = useLoader(docStr, {});

const docLine = `const doc = ${JSON.stringify(parse(docStr, { noLocation: true }))};`;
const docLine = `var doc = ${JSON.stringify(parse(docStr, { noLocation: true }))};`;
const exportLine = `module.exports = doc`;

expect(doc).toContain(docLine);
Expand Down Expand Up @@ -43,7 +43,7 @@ test('basic query with esModules on', () => {
esModule: true
});

const docLine = `const doc = ${JSON.stringify(parse(docStr, { noLocation: true }))};`;
const docLine = `var doc = ${JSON.stringify(parse(docStr, { noLocation: true }))};`;
const exportLine = `export default doc`;

expect(doc).toContain(docLine);
Expand Down

0 comments on commit b99f40a

Please sign in to comment.