Skip to content

Commit

Permalink
Bye, JS Compiler, we love you! (#3634)
Browse files Browse the repository at this point in the history
Summary:
In the next major Relay Release (v13) the new rust version of the compiler will be the only version.

This PR:
- Removes JS compiler.
- `relay-compiler-experimental` is moved to `relay-compiler`.
- Updates `gulpfile` to publish the latest release from the main branch to `reley-compiler` instead of `relay-compiler-experimental`.

In the following PRs, we will also update documentation, etc.

![Thank you, bye](https://media.giphy.com/media/YSHCkTrb4M8mcV9jxr/giphy.gif)

Pull Request resolved: #3634

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**Static Docs Preview: relay**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/1636727028/relay/)|

|**Modified Pages**|

Reviewed By: kassens

Differential Revision: D32380358

Pulled By: alunyov

fbshipit-source-id: ae10b3bc9d7cd8f0f968bba13a34e1e83d20afd5
  • Loading branch information
alunyov authored and facebook-github-bot committed Nov 12, 2021
1 parent 16c84f7 commit 4467ae8
Show file tree
Hide file tree
Showing 711 changed files with 136 additions and 86,641 deletions.
222 changes: 113 additions & 109 deletions compiler/Cargo.lock

Large diffs are not rendered by default.

61 changes: 8 additions & 53 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,6 @@ const builds = [
},
],
},
{
package: 'relay-compiler',
exports: {
index: 'index.js',
},
bundles: [
{
entry: 'index.js',
output: 'relay-compiler',
libraryName: 'RelayCompiler',
libraryTarget: 'commonjs2',
target: 'node',
noMinify: true, // Note: uglify can't yet handle modern JS
},
],
bins: [
{
entry: 'RelayCompilerBin.js',
output: 'relay-compiler',
libraryTarget: 'commonjs2',
target: 'node',
},
],
},
{
package: 'relay-runtime',
exports: {
Expand Down Expand Up @@ -328,23 +304,6 @@ const exportsFiles = gulp.series(
),
);

const binsTasks = [];
builds.forEach((build) => {
if (build.bins) {
build.bins.forEach((bin) => {
binsTasks.push(function binsTask() {
return gulp
.src(path.join(DIST, build.package, 'lib', 'bin', bin.entry))
.pipe(buildDist(bin.output, bin, /* isProduction */ false))
.pipe(header(SCRIPT_HASHBANG + PRODUCTION_HEADER))
.pipe(chmod(0o755))
.pipe(gulp.dest(path.join(DIST, build.package, 'bin')));
});
});
}
});
const bins = gulp.series(binsTasks);

const bundlesTasks = [];
builds.forEach((build) => {
build.bundles.forEach((bundle) => {
Expand Down Expand Up @@ -378,30 +337,30 @@ builds.forEach((build) => {
const bundlesMin = gulp.series(bundlesMinTasks);

const clean = () => del(DIST);
const dist = gulp.series(exportsFiles, bins, bundles, bundlesMin);
const dist = gulp.series(exportsFiles, bundles, bundlesMin);
const watch = gulp.series(dist, () =>
gulp.watch(INCLUDE_GLOBS, {cwd: PACKAGES}, dist),
);

const experimentalCompiler = gulp.parallel(
const relayCompiler = gulp.parallel(
function copyLicense() {
return gulp
.src(['LICENSE'])
.pipe(gulp.dest(path.join(DIST, 'relay-compiler-experimental')));
.pipe(gulp.dest(path.join(DIST, 'relay-compiler')));
},
function copyPackageFiles() {
return gulp
.src(['package.json', 'cli.js', 'index.js'], {
cwd: path.join(PACKAGES, 'relay-compiler-experimental'),
cwd: path.join(PACKAGES, 'relay-compiler'),
})
.pipe(gulp.dest(path.join(DIST, 'relay-compiler-experimental')));
.pipe(gulp.dest(path.join(DIST, 'relay-compiler')));
},
function copyCompilerBins() {
return gulp
.src('**', {
cwd: path.join('artifacts'),
})
.pipe(gulp.dest(path.join(DIST, 'relay-compiler-experimental')));
.pipe(gulp.dest(path.join(DIST, 'relay-compiler')));
},
);

Expand All @@ -414,7 +373,7 @@ const setMainVersion = async () => {
throw new Error('Expected the RELEASE_COMMIT_SHA env variable to be set.');
}
const packages = builds.map((build) => build.package);
packages.push('relay-compiler-experimental');
packages.push('relay-compiler');
packages.forEach((pkg) => {
const pkgJsonPath = path.join('.', 'dist', pkg, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf8'));
Expand Down Expand Up @@ -444,10 +403,6 @@ const cleanbuild = gulp.series(clean, dist);
exports.clean = clean;
exports.dist = dist;
exports.watch = watch;
exports.mainrelease = gulp.series(
cleanbuild,
experimentalCompiler,
setMainVersion,
);
exports.mainrelease = gulp.series(cleanbuild, relayCompiler, setMainVersion);
exports.cleanbuild = cleanbuild;
exports.default = cleanbuild;
26 changes: 0 additions & 26 deletions packages/relay-compiler-experimental/index.js

This file was deleted.

15 changes: 0 additions & 15 deletions packages/relay-compiler-experimental/package.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/relay-compiler/.gitignore

This file was deleted.

18 changes: 0 additions & 18 deletions packages/relay-compiler/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
# Relay Compiler

Relay-Compiler is a code-generation toolkit for GraphQL. It contains the core functionalities of GraphQL code-gen, including file parsing, validation, syntax tree parsing and transformation.

The GraphQL-Compiler package [exports library code](./GraphQLCompilerPublic.js) which you may use to find the modules you need, or to extend the compiler with your own custom input and output. Note, the internal APIs of the GraphQL-Compiler are under constant iteration, so rolling your own version may lead to incompatibilities with future releases.

The following graph illustrates the high-level architecture of a complete GraphQL code-generation pipeline:

![CodegenPipeline](https://github.com/facebook/relay/raw/main/packages/relay-compiler/docs/Architecture.png)

To understand the underlying workflow of the core compilation step, which is what happens in the "GraphQL Compiler" block in the above graph, please refer [HERE](./ARCHITECTURE.md).

You can build your own version of the Compiler by adding your own `FileWriter`, and by swapping or adding a `FileParser` and additional `IRTransforms` (IR, which stands for `Intermediate Representation`, a special-purpose syntax tree format designed for transformability).

* The GraphQL-Compiler package provides a [`DotGraphQLParser`](./core/DotGraphQLParser.js), which can be used to parse general `.graphql` files, and a [`GraphQLTextParser`](../relay-test-utils-internal/parseGraphQLText.js), which can be used to parse GraphQL text in any source files with customized tags. You can also write your own `FileParser` at your discretion.

* You can add additional `IRTransforms` by extending the basic [`RelayIRTransforms`](./core/RelayIRTransforms.js).

* A sample `FileWriter` can be found [HERE](./codegen/RelayFileWriter.js).

To actually run your compiler, you will also need a script to assemble all the above components. A sample file can be found [HERE](./bin/RelayCompilerBin.js).
168 changes: 0 additions & 168 deletions packages/relay-compiler/bin/RelayCompilerBin.js

This file was deleted.

Loading

1 comment on commit 4467ae8

@alloy
Copy link
Contributor

@alloy alloy commented on 4467ae8 Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Please sign in to comment.