Skip to content

Language plugin support. #2293

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/babel-plugin-relay/BabelPluginRelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export type RelayPluginOptions = {
snakeCase?: boolean,
substituteVariables?: boolean,
validator?: Validator<any>,
// Directory as specified by outputDir when running relay-compiler
artifactDirectory?: string,
};

export type BabelState = {
Expand Down
16 changes: 14 additions & 2 deletions packages/babel-plugin-relay/__tests__/BabelPluginRelay-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ describe('BabelPluginRelay', () => {
function transformerWithOptions(
options: RelayPluginOptions,
environment: 'development' | 'production' = 'production',
filename?: string,
): string => string {
return (text, filename) => {
return (text, providedFileName) => {
const previousEnv = process.env.BABEL_ENV;
try {
process.env.BABEL_ENV = environment;
return babel.transform(text, {
compact: false,
filename,
filename: filename || providedFileName,
parserOpts: {plugins: ['jsx']},
plugins: [[BabelPluginRelay, options]],
}).code;
Expand Down Expand Up @@ -84,6 +85,17 @@ describe('BabelPluginRelay', () => {
}),
);

generateTestsFromFixtures(
`${__dirname}/fixtures-modern-artifact-directory`,
transformerWithOptions(
{
artifactDirectory: '/test/artifacts',
},
'production',
'/testing/Container.js',
),
);

describe('`development` option', () => {
it('tests the hash when `development` is set', () => {
expect(
Expand Down
Loading