Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please use very old javascript syntax in webpack loader - said IE #1886

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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