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); } diff --git a/src/index.js b/src/index.js index 1ed3f17..6353112 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' @@ -35,9 +36,9 @@ class RaiseErrorsReporter { } class RelayCompilerWebpackPlugin { - parserConfigs: {} - - writerConfigs: {} + parserConfigs: {}; + writerConfigs: {}; + languagePlugin: PluginInterface; constructor (options: { schema: string | GraphQLSchema, @@ -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.') @@ -104,6 +105,8 @@ class RelayCompilerWebpackPlugin { sourceParserName, languagePlugin: language }) + + this.languagePlugin = language } createParserConfigs ({ @@ -119,7 +122,7 @@ class RelayCompilerWebpackPlugin { baseDir: string, getParser?: Function, sourceParserName: string, - languagePlugin: any, + languagePlugin: PluginInterface, schema: string | GraphQLSchema, include: Array, exclude: Array, @@ -161,7 +164,7 @@ class RelayCompilerWebpackPlugin { }: { baseDir: string, sourceParserName: string, - languagePlugin: any + languagePlugin: PluginInterface }) { return { [languagePlugin.outputExtension]: { @@ -186,7 +189,7 @@ class RelayCompilerWebpackPlugin { onlyValidate: false, skipPersist: true }) - return runner.compile('js') + return runner.compile(this.languagePlugin.outputExtension) } catch (error) { errors.push(error) }