Skip to content

Commit

Permalink
fix(graphql): fix ESM build (#1318)
Browse files Browse the repository at this point in the history
Use file extensions for imports
  • Loading branch information
lukastaegert authored Oct 27, 2022
1 parent 8ade726 commit 46bd37c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/graphql/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createConfig } from '../../shared/rollup.config.mjs';
export default {
...createConfig({
pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')),
external: ['graphql-tag/loader']
external: ['graphql-tag/loader.js']
}),
input: 'src/index.js',
plugins: [buble()]
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createFilter } from '@rollup/pluginutils';
import loader from 'graphql-tag/loader';
import loader from 'graphql-tag/loader.js';

import { toESModules } from './toESModules';

Expand Down
1 change: 1 addition & 0 deletions packages/graphql/test/node_modules/current-package

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

4 changes: 2 additions & 2 deletions packages/graphql/test/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const test = require('ava');
const { rollup } = require('rollup');

const { testBundle } = require('../../../util/test');
const graphql = require('current-package');

const graphql = require('..');
const { testBundle } = require('../../../util/test');

require('source-map-support').install();

Expand Down
22 changes: 22 additions & 0 deletions packages/graphql/test/test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { fileURLToPath } from 'url';

import test from 'ava';
import { rollup } from 'rollup';

import graphql from 'current-package';

import { testBundle } from '../../../util/test.js';

test.beforeEach(() => process.chdir(fileURLToPath(new URL('.', import.meta.url))));

test('works as an ES module', async (t) => {
const bundle = await rollup({
input: 'fixtures/basic/index.js',
plugins: [graphql()]
});

const { module } = await testBundle(t, bundle);

t.truthy('doc' in module.exports);
t.is(module.exports.doc.kind, 'Document');
});
7 changes: 1 addition & 6 deletions pnpm-lock.yaml

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

0 comments on commit 46bd37c

Please sign in to comment.