From c7c60ec5a37d1a1d1aae616096ac6b10f543357c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Tue, 11 Dec 2018 10:20:03 +0000 Subject: [PATCH 1/3] change type of languagePlugin from `any` to `PluginInterface` --- src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 1ed3f17..5e27b81 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ import { Runner } from 'relay-compiler' import RelayLanguagePluginJavaScript from 'relay-compiler/lib/RelayLanguagePluginJavaScript' +import type { PluginInterface } from 'relay-compiler/lib/RelayLanguagePluginInterface' import RelaySourceModuleParser from 'relay-compiler/lib/RelaySourceModuleParser' import { DotGraphQLParser } from 'graphql-compiler' @@ -46,7 +47,7 @@ class RelayCompilerWebpackPlugin { extensions: Array, include: Array, exclude: Array, - languagePlugin?: Function + languagePlugin?: () => PluginInterface }) { if (!options) { throw new Error('You must provide options to RelayCompilerWebpackPlugin.') @@ -119,7 +120,7 @@ class RelayCompilerWebpackPlugin { baseDir: string, getParser?: Function, sourceParserName: string, - languagePlugin: any, + languagePlugin: PluginInterface, schema: string | GraphQLSchema, include: Array, exclude: Array, @@ -161,7 +162,7 @@ class RelayCompilerWebpackPlugin { }: { baseDir: string, sourceParserName: string, - languagePlugin: any + languagePlugin: PluginInterface }) { return { [languagePlugin.outputExtension]: { From 26f0f389a8531076c5cc75779e167fa1b15dca55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Tue, 11 Dec 2018 10:20:29 +0000 Subject: [PATCH 2/3] pass runner.compile the language plugin output extension --- src/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 5e27b81..6353112 100644 --- a/src/index.js +++ b/src/index.js @@ -36,9 +36,9 @@ class RaiseErrorsReporter { } class RelayCompilerWebpackPlugin { - parserConfigs: {} - - writerConfigs: {} + parserConfigs: {}; + writerConfigs: {}; + languagePlugin: PluginInterface; constructor (options: { schema: string | GraphQLSchema, @@ -105,6 +105,8 @@ class RelayCompilerWebpackPlugin { sourceParserName, languagePlugin: language }) + + this.languagePlugin = language } createParserConfigs ({ @@ -187,7 +189,7 @@ class RelayCompilerWebpackPlugin { onlyValidate: false, skipPersist: true }) - return runner.compile('js') + return runner.compile(this.languagePlugin.outputExtension) } catch (error) { errors.push(error) } From 3401a3402ffe99d6ee3ed41baada45fb711b9b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Tue, 11 Dec 2018 14:22:02 +0000 Subject: [PATCH 3/3] commit built javascript --- dist/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 370d104..569f649 100644 --- a/dist/index.js +++ b/dist/index.js @@ -52,6 +52,8 @@ class RelayCompilerWebpackPlugin { _defineProperty(this, "writerConfigs", void 0); + _defineProperty(this, "languagePlugin", void 0); + if (!options) { throw new Error('You must provide options to RelayCompilerWebpackPlugin.'); } @@ -93,6 +95,7 @@ class RelayCompilerWebpackPlugin { sourceParserName, languagePlugin: language }); + this.languagePlugin = language; } createParserConfigs({ @@ -161,7 +164,7 @@ class RelayCompilerWebpackPlugin { onlyValidate: false, skipPersist: true }); - return runner.compile('js'); + return runner.compile(_this.languagePlugin.outputExtension); } catch (error) { errors.push(error); }