Skip to content

Commit cc4cf76

Browse files
XiNiHafacebook-github-bot
authored andcommitted
Remove bundler setup (#4935)
Summary: This PR removes the bundler setup for all of the npm packages in this repo, as discussed with captbaritone in [Discord](https://discord.com/channels/625400653321076807/1342499490011025460/1346175975628734494). While this wouldn't affect the vast majority of use cases, I believe it should technically be considered a breaking change, as it breaks CDN usages and direct CJS requires pointing at outputs. Pull Request resolved: #4935 Reviewed By: tyao1 Differential Revision: D70794723 Pulled By: captbaritone fbshipit-source-id: a4110cf14da26d81995f89a55e3b19c1c2abab32
1 parent 9f7fb21 commit cc4cf76

File tree

3 files changed

+14
-845
lines changed

3 files changed

+14
-845
lines changed

gulpfile.js

+1-137
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ const del = require('del');
3333
const fs = require('fs');
3434
const gulp = require('gulp');
3535
const babel = require('gulp-babel');
36-
const header = require('gulp-header');
3736
const rename = require('gulp-rename');
38-
const gulpUtil = require('gulp-util');
3937
const path = require('path');
40-
const webpack = require('webpack');
41-
const webpackStream = require('webpack-stream');
4238

4339
const RELEASE_COMMIT_SHA = process.env.RELEASE_COMMIT_SHA;
4440
if (RELEASE_COMMIT_SHA && RELEASE_COMMIT_SHA.length !== 40) {
@@ -52,10 +48,6 @@ const VERSION = RELEASE_COMMIT_SHA
5248
? `0.0.0-main-${RELEASE_COMMIT_SHA.substr(0, 8)}`
5349
: process.env.npm_package_version;
5450

55-
const DEVELOPMENT_HEADER = `/**
56-
* Relay v${VERSION}
57-
*/
58-
`;
5951
const PRODUCTION_HEADER = `/**
6052
* Relay v${VERSION}
6153
*
@@ -66,39 +58,6 @@ const PRODUCTION_HEADER = `/**
6658
*/
6759
`;
6860

69-
const buildDist = function (filename, opts, isProduction) {
70-
const webpackOpts = {
71-
externals: [/^[-/a-zA-Z0-9]+$/, /^@babel\/.+$/],
72-
target: opts.target,
73-
output: {
74-
filename: filename,
75-
libraryTarget: opts.libraryTarget,
76-
library: opts.libraryName,
77-
},
78-
plugins: [
79-
new webpack.DefinePlugin({
80-
'process.env.NODE_ENV': JSON.stringify(
81-
isProduction ? 'production' : 'development',
82-
),
83-
}),
84-
],
85-
};
86-
if (isProduction && !opts.noMinify) {
87-
// See more chunks configuration here: https://gist.github.com/sokra/1522d586b8e5c0f5072d7565c2bee693
88-
webpackOpts.optimization = {
89-
minimize: true,
90-
};
91-
}
92-
return webpackStream(webpackOpts, webpack, function (err, stats) {
93-
if (err) {
94-
throw new gulpUtil.PluginError('webpack', err);
95-
}
96-
if (stats.compilation.errors.length) {
97-
throw new gulpUtil.PluginError('webpack', stats.toString());
98-
}
99-
});
100-
};
101-
10261
// Paths from package-root
10362
const PACKAGES = 'packages';
10463
const DIST = 'dist';
@@ -119,15 +78,6 @@ const builds = [
11978
index: 'BabelPluginRelay.js',
12079
macro: 'BabelPluginRelay.macro.js',
12180
},
122-
bundles: [
123-
{
124-
entry: 'BabelPluginRelay.js',
125-
output: 'babel-plugin-relay',
126-
libraryName: 'BabelPluginRelay',
127-
libraryTarget: 'commonjs2',
128-
target: 'node',
129-
},
130-
],
13181
},
13282
{
13383
package: 'react-relay',
@@ -137,79 +87,25 @@ const builds = [
13787
legacy: 'legacy.js',
13888
ReactRelayContext: 'ReactRelayContext.js',
13989
},
140-
bundles: [
141-
{
142-
entry: 'index.js',
143-
output: 'react-relay',
144-
libraryName: 'ReactRelay',
145-
libraryTarget: 'umd',
146-
},
147-
{
148-
entry: 'hooks.js',
149-
output: 'react-relay-hooks',
150-
libraryName: 'ReactRelayHooks',
151-
libraryTarget: 'umd',
152-
},
153-
{
154-
entry: 'legacy.js',
155-
output: 'react-relay-legacy',
156-
libraryName: 'ReactRelayLegacy',
157-
libraryTarget: 'umd',
158-
},
159-
],
16090
},
16191
{
16292
package: 'relay-runtime',
16393
exports: {
16494
index: 'index.js',
16595
experimental: 'experimental.js',
16696
},
167-
bundles: [
168-
{
169-
entry: 'index.js',
170-
output: 'relay-runtime',
171-
libraryName: 'RelayRuntime',
172-
libraryTarget: 'umd',
173-
},
174-
{
175-
entry: 'experimental.js',
176-
output: 'relay-runtime-experimental',
177-
libraryName: 'ReactRelayExperimental',
178-
libraryTarget: 'umd',
179-
},
180-
],
18197
},
18298
{
18399
package: 'relay-test-utils',
184100
exports: {
185101
index: 'index.js',
186102
},
187-
bundles: [
188-
{
189-
entry: 'index.js',
190-
output: 'relay-test-utils',
191-
libraryName: 'RelayTestUtils',
192-
libraryTarget: 'commonjs2',
193-
target: 'node',
194-
noMinify: true, // Note: uglify can't yet handle modern JS
195-
},
196-
],
197103
},
198104
{
199105
package: 'relay-test-utils-internal',
200106
exports: {
201107
index: 'index.js',
202108
},
203-
bundles: [
204-
{
205-
entry: 'index.js',
206-
output: 'relay-test-utils-internal',
207-
libraryName: 'RelayTestUtilsInternal',
208-
libraryTarget: 'commonjs2',
209-
target: 'node',
210-
noMinify: true, // Note: uglify can't yet handle modern JS
211-
},
212-
],
213109
},
214110
];
215111

@@ -295,40 +191,8 @@ const exportsFiles = gulp.series(
295191
),
296192
);
297193

298-
const bundlesTasks = [];
299-
builds.forEach(build => {
300-
build.bundles.forEach(bundle => {
301-
bundlesTasks.push(function bundleTask() {
302-
return gulp
303-
.src(path.join(DIST, build.package, 'lib', bundle.entry))
304-
.pipe(
305-
buildDist(bundle.output + '.js', bundle, /* isProduction */ false),
306-
)
307-
.pipe(header(DEVELOPMENT_HEADER))
308-
.pipe(gulp.dest(path.join(DIST, build.package)));
309-
});
310-
});
311-
});
312-
const bundles = gulp.series(bundlesTasks);
313-
314-
const bundlesMinTasks = [];
315-
builds.forEach(build => {
316-
build.bundles.forEach(bundle => {
317-
bundlesMinTasks.push(function bundlesMinTask() {
318-
return gulp
319-
.src(path.join(DIST, build.package, 'lib', bundle.entry))
320-
.pipe(
321-
buildDist(bundle.output + '.min.js', bundle, /* isProduction */ true),
322-
)
323-
.pipe(header(PRODUCTION_HEADER))
324-
.pipe(gulp.dest(path.join(DIST, build.package)));
325-
});
326-
});
327-
});
328-
const bundlesMin = gulp.series(bundlesMinTasks);
329-
330194
const clean = () => del(DIST);
331-
const dist = gulp.series(exportsFiles, bundles, bundlesMin);
195+
const dist = gulp.series(exportsFiles);
332196
const watch = gulp.series(dist, () =>
333197
gulp.watch(INCLUDE_GLOBS, {cwd: PACKAGES}, dist),
334198
);

package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@
6666
"gulp": "4.0.2",
6767
"gulp-babel": "8.0.0",
6868
"gulp-chmod": "3.0.0",
69-
"gulp-header": "2.0.9",
7069
"gulp-rename": "^2.0.0",
71-
"gulp-util": "3.0.8",
7270
"hermes-eslint": "0.25.1",
7371
"invariant": "^2.2.4",
7472
"jest": "^29.7.0",
@@ -80,9 +78,7 @@
8078
"react": "0.0.0-experimental-7670501b-20241124",
8179
"react-dom": "0.0.0-experimental-7670501b-20241124",
8280
"react-refresh": "0.0.0-experimental-7670501b-20241124",
83-
"react-test-renderer": "0.0.0-experimental-7670501b-20241124",
84-
"webpack": "^5.89.0",
85-
"webpack-stream": "^7.0.0"
81+
"react-test-renderer": "0.0.0-experimental-7670501b-20241124"
8682
},
8783
"resolutions": {
8884
"glob-watcher": "^6.0.0"

0 commit comments

Comments
 (0)