@@ -33,12 +33,8 @@ const del = require('del');
3333const fs = require ( 'fs' ) ;
3434const gulp = require ( 'gulp' ) ;
3535const babel = require ( 'gulp-babel' ) ;
36- const header = require ( 'gulp-header' ) ;
3736const rename = require ( 'gulp-rename' ) ;
38- const gulpUtil = require ( 'gulp-util' ) ;
3937const path = require ( 'path' ) ;
40- const webpack = require ( 'webpack' ) ;
41- const webpackStream = require ( 'webpack-stream' ) ;
4238
4339const RELEASE_COMMIT_SHA = process . env . RELEASE_COMMIT_SHA ;
4440if ( 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- ` ;
5951const 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 - z A - Z 0 - 9 ] + $ / , / ^ @ b a b e l \/ .+ $ / ] ,
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
10362const PACKAGES = 'packages' ;
10463const 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-
330194const clean = ( ) => del ( DIST ) ;
331- const dist = gulp . series ( exportsFiles , bundles , bundlesMin ) ;
195+ const dist = gulp . series ( exportsFiles ) ;
332196const watch = gulp . series ( dist , ( ) =>
333197 gulp . watch ( INCLUDE_GLOBS , { cwd : PACKAGES } , dist ) ,
334198) ;
0 commit comments