Skip to content

Commit

Permalink
Don't include @babel packages in generated bundles (#2764)
Browse files Browse the repository at this point in the history
Summary:
See background in #2759.

Before this change, the `relay-compiler` binary pulls in `lodash`:

```
dist/relay-compiler/bin/relay-compiler
23734:module.exports = require("lodash/clone");
26487:module.exports = require("lodash/uniq");
27035:module.exports = require("lodash/isPlainObject");
27041:module.exports = require("lodash/isRegExp");
28413:module.exports = require("lodash/isInteger");
28419:module.exports = require("lodash/repeat");
```

And, only these files in `dist/` reference `lodash`:

```
$ rg lodash dist/ -l
dist/relay-compiler/relay-compiler.js
dist/relay-compiler/relay-compiler.min.js
dist/relay-compiler/bin/relay-compiler
```

After this change, no files in `dist/` contain references to `lodash`. This seems consistent with what's contained in Relay packages before they were upgraded to Babel 7 (where the `@` was added) in #2536.
Pull Request resolved: #2764

Reviewed By: alunyov

Differential Revision: D15793295

Pulled By: kassens

fbshipit-source-id: 14e9cc6d83a57d6853d8e41e82296d15f27750b2
  • Loading branch information
Wyatt Anderson authored and facebook-github-bot committed Jun 12, 2019
1 parent 537ad75 commit 70453f2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ const PRODUCTION_HEADER =

const buildDist = function(filename, opts, isProduction) {
const webpackOpts = {
externals: [/^[-/a-zA-Z0-9]+$/],
externals: [
/^[-/a-zA-Z0-9]+$/,
/^@babel\/.+$/,
],
target: opts.target,
node: {
fs: 'empty',
Expand Down Expand Up @@ -250,6 +253,7 @@ const builds = [
entry: 'index.js',
output: 'relay-test-utils',
libraryName: 'RelayTestUtils',
libraryTarget: 'commonjs2',
target: 'node',
noMinify: true, // Note: uglify can't yet handle modern JS
},
Expand Down

0 comments on commit 70453f2

Please sign in to comment.