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

[WIP] Language plugin #5

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1f89fd4
[language-plugin] Move JS/Flow code into language dir.
alloy Jan 15, 2018
37c7c33
[language-plugin] Add interface and JS/Flow implementation.
alloy Jan 15, 2018
06bf77f
[language-plugin] Don’t leave GraphQL tag caching up to plugins.
alloy Jan 17, 2018
c4b2d5c
[language-plugin] Don’t leave fragment name validation up to plugins.
alloy Jan 19, 2018
72e0f9f
[language-plugin] Move ‘format module’ code to plugin.
alloy Jan 19, 2018
d70de4a
[package] Update versions to 1.4.1-plugin.2
alloy Jan 19, 2018
5f809fb
[language-plugin] Move Flow generator tests to right location.
alloy Jan 19, 2018
194b34d
[language-plugin] Move type generator options to plugin interface.
alloy Jan 19, 2018
8c9fd6a
[language-plugin] Pass file path to GraphQL tag finder.
alloy Jan 19, 2018
49c5392
[language-plugin] Load ES6 modules in uniform way.
alloy Jan 19, 2018
43aeafb
[language-plugin] Prefix plugin packages.
alloy Jan 19, 2018
a6ec97e
[package] Bump to 1.4.1-plugin.3
alloy Jan 19, 2018
b064b0d
Add CLI option to set outputDir of RelayFileWriter
kastermester Jan 20, 2018
f019a1c
Prettier format.
kastermester Jan 20, 2018
ac5cf98
Merge pull request #6 from kastermester/language-plugin-with-output-dir
alloy Jan 20, 2018
442873a
[bin] Fix type error due to prettier formatting.
alloy Jan 20, 2018
631374c
[Compiler] Improve bin interface.
alloy Jan 20, 2018
85f2381
[Compiler] Default artifactDirectory to .babelrc setting.
alloy Jan 20, 2018
de2e910
[Compiler] Revert defaulting artifactDirectory to .babelrc
alloy Jan 20, 2018
be12958
Merge pull request #7 from alloy/language-plugin-output-dir
alloy Jan 20, 2018
5b3a1cc
[package] Bump to 1.4.1-plugin.4
alloy Jan 20, 2018
ab0d4a1
[language-plugin] The plugin has no need for the artifact dir.
alloy Jan 20, 2018
505aad3
[package] Bump to 1.4.1-plugin.5
alloy Jan 20, 2018
11c29b2
[BabelPlugin] Ensure import path is always relative.
alloy Jan 20, 2018
d17bfdb
[package] Bump to 1.4.1-plugin.6
alloy Jan 20, 2018
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "relay",
"description": "A framework for building data-driven React applications.",
"version": "1.4.1",
"version": "1.4.1-plugin.2",
"license": "MIT",
"homepage": "https://facebook.github.io/relay/",
"bugs": "https://github.com/facebook/relay/issues",
Expand Down
2 changes: 2 additions & 0 deletions packages/babel-plugin-relay/BabelPluginRelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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