Commit Graph

1375 Commits

Author SHA1 Message Date
David Aurelio 35e5b486c3 Make `ResolveFn` sync
Summary: now that `ResolutionRequest.resolveDependency` is synchronous, we can also make `ResolveFn` synchronous.

Reviewed By: fkgozali

Differential Revision: D5528094

fbshipit-source-id: 0b40df29024b809a99b7e577716b24e9fa499578
2017-07-31 17:46:01 -07:00
David Aurelio 0272069002 Only write assets referenced in a bundle
Summary: Adds filtering to the assets written from a Buck build, so that we don’t write all assets present in libs, but rather only the ones included in the bundle.

Reviewed By: cpojer

Differential Revision: D5522844

fbshipit-source-id: fcca3567b726dfab1ecf9560932fd6e1a174b31f
2017-07-31 10:12:11 -07:00
Jean Lauliac e032e6621f metro-bundler: upgrade all jest refs to delta.4
Reviewed By: mjesun

Differential Revision: D5503722

fbshipit-source-id: ca5d1e684e6b909804ae2be8c2055439dda611f5
2017-07-28 13:02:53 -07:00
Jean Lauliac f332dbee47 metro-bundler: Resolver @format
Reviewed By: cpojer

Differential Revision: D5514920

fbshipit-source-id: 59b8ab3555aca1703b22049382f39d1d67401c4f
2017-07-28 13:02:53 -07:00
David Aurelio 2dda50893f Saner entry point
Summary: makes flow typing for the entry point more sound and fixes two issues

Reviewed By: BYK

Differential Revision: D5507650

fbshipit-source-id: 6b03f7de792ffcece4d0d61950e136a61ea7db2e
2017-07-27 18:15:34 -07:00
Dmitry Zakharov 43457e6674 Make intentions clearer in code of require.js
Reviewed By: javache

Differential Revision: D5479898

fbshipit-source-id: de73d5cffed4200b81f1d8335a3962a37702df63
2017-07-27 13:59:47 -07:00
Jean Lauliac 1a75751a3b metro-bundler: hash enableBabelRCLookup in global cache
Reviewed By: mjesun

Differential Revision: D5502800

fbshipit-source-id: f6cb01e57a3a385c256f1e77420ca670fe77e5de
2017-07-27 12:29:58 -07:00
Jean Lauliac c37f730c57 metro-bundler: 0.11.0
Reviewed By: davidaurelio

Differential Revision: D5494606

fbshipit-source-id: 2049fe162b76fa6ffeec9f87871276057d84f892
2017-07-27 11:51:18 -07:00
Jean Lauliac 14b88b6ad4 metro-bundler: @format lib/
Reviewed By: cpojer

Differential Revision: D5493458

fbshipit-source-id: 05ac2895125b1419996a66f3ef155bc2cec11c02
2017-07-26 12:24:22 -07:00
Christoph Nakazawa 521e25bded Improve Metro's TransformError message for transform errors.
Reviewed By: davidaurelio

Differential Revision: D5470538

fbshipit-source-id: dea3e798c26964bb789917e73bb06a7629af7aa4
2017-07-25 13:54:43 -07:00
Jean Lauliac ce0da03a05 metro-bundler: moar @format
Reviewed By: mjesun

Differential Revision: D5484885

fbshipit-source-id: f9ae126931f0c9f611ee5b5b96243656e86f4ba4
2017-07-24 22:37:19 -07:00
Jean Lauliac 9f1cce4e89 metro-bundler: bundle test: fix test for no polyfills
Reviewed By: mjesun

Differential Revision: D5481856

fbshipit-source-id: b5516d7d74ba15886f1126f6d881a66559d0fb1e
2017-07-24 22:37:19 -07:00
Jean Lauliac 5ba56250b5 metro-bundler: remove hardcoded AssetRegistry path
Reviewed By: davidaurelio

Differential Revision: D5452553

fbshipit-source-id: e0a6f56d3bc03f4ba7f34fbee1ae418495dcc6cd
2017-07-24 17:07:30 -07:00
Jean Lauliac 74e78ee43f metro-bundler: @format node-haste subdir
Summary: Format everything, one subdir at a time.

Reviewed By: mjesun

Differential Revision: D5481590

fbshipit-source-id: 6d9157e6857d61b8116bcf9285bd4be415c5ba01
2017-07-24 15:30:30 -07:00
James Ide 0f3d7117d4 Add an option to enable/disable .babelrc lookup
Summary:
By default, when Babel transforms a file, it looks for .babelrc in the file's directory and all parent directories until it finds a .babelrc file. This means that when Metro tries to transform `<PROJECT_ROOT>/node_modules/dep/mod.js`, it searches for `<PROJECT_ROOT>/node_modules/dep/.babelrc`. If that .babelrc actually exists, Babel will try to apply it.

In practice, this often causes problems because packages that include .babelrc often do so unintentionally -- they don't intend for the package consumer to look at that .babelrc file. One thing we've done a lot is `rm` all .babelrc files under node_modules -- this commit effectively achieves the same in a less destructive way by telling Babel not to look up .babelrc files. (To clarify, Metro will still apply the .babelrc file in the project root.)

Since the current behavior is to look at .babelrc files, this commit keeps that behavior for now. We'll consider overriding the default behavior (that is, making Babel not lookup .babelrc files) in the default configuration of Expo/RN projects. If this goes well and we empirically find that people are having a better time, we may want to consider flipping this option's default in Metro, so that Metro tells Babel not to look up .babelrc files by default.
Closes https://github.com/facebook/metro-bundler/pull/31

Differential Revision: D5469620

Pulled By: jeanlauliac

fbshipit-source-id: fe7a1042feafff843e1a6d8cc9487eb6ff8e8358
2017-07-24 13:43:26 -07:00
Jean Lauliac 42d61ea63a metro-bundler: global cache: add uri info to the FetchFailedError
Reviewed By: davidaurelio

Differential Revision: D5451939

fbshipit-source-id: 8fa460f714919488ab7a592e123e91adde4ed4c2
2017-07-24 12:09:46 -07:00
Jean Lauliac fd6c2a4013 v0.10.0
Summary: Closes https://github.com/facebook/metro-bundler/pull/32

Differential Revision: D5469676

Pulled By: jeanlauliac

fbshipit-source-id: 68cf83d43582fa0543e28810df48915911760ce3
2017-07-21 04:54:57 -07:00
Janic Duplessis 16bb5571c6 Add Content-Length header to *.bundle responses
Summary:
The main goal of this is to be able to show bundle download progress in a follow up PR for react-native.

**Test plan**
Tested that it is possible to show bundle download progress in react-native using this header and added unit test.
Closes https://github.com/facebook/metro-bundler/pull/28

Reviewed By: davidaurelio

Differential Revision: D5443344

Pulled By: jeanlauliac

fbshipit-source-id: 63fd655c964d7df526125fbe55eb9c7cccd7dba9
2017-07-21 03:51:48 -07:00
Jean Lauliac 3cc83da403 metro-bundler: Server: report ambiguous module resolution better
Reviewed By: mjesun

Differential Revision: D5444129

fbshipit-source-id: 311d20c7ee4c00ec2d4c52d83bd6c5a94221b552
2017-07-20 10:21:49 -07:00
Miguel Jimenez Esun 3cbc2f3ec4 Revert D5388655: BREAKING: Add regenerator-runtime on demand, based on the files
Differential Revision: D5388655

fbshipit-source-id: 2f92d6ae69f4772195aeca7493f53209388b3ad0
2017-07-19 12:14:28 -07:00
Miguel Jimenez Esun d7521c53ae BREAKING: Add regenerator-runtime on demand, based on the files
Summary:
Adding a Babel plugin that will analyze the file looking for any potential candidate to use `regenerator-runtime`, and if so, will inject dynamically the module. The module is injected per file, so we avoid polluting the global environment. The plugin is also able to inject the `require` call beforehand, so that the inliner can pick them and inline them.

The Babel plugin is part of `react-native-babel-preset`, so as long as you are using this preset you are safe. If not, you should include the specific transformer into your list of plugins, as `react-native-babel-preset/transforms/transform-regenerator-runtime-insertion.js`.

Reviewed By: davidaurelio

Differential Revision: D5388655

fbshipit-source-id: dc403f3d5e2d807529eb8569a85c45fec36a6a3e
2017-07-19 11:11:16 -07:00
Jean Lauliac 6fd25bb98a metro-bundler: fix test command
Reviewed By: cpojer

Differential Revision: D5452722

fbshipit-source-id: d0253150555bfbc1cbf5ef0331767855bc37d517
2017-07-19 10:21:08 -07:00
Jean Lauliac d23a665647 Revert "fix the test command"
This reverts commit 8c716f0029.
2017-07-19 17:31:41 +01:00
Jean Lauliac 84e0fe4606 Revert "attempt at fixing yarn install in CircleCI"
This reverts commit 669f432dfb.
2017-07-19 17:31:28 +01:00
Jean Lauliac 1ae97c72a2 fix inner yarn.lock
Summary:
I corrupted the yarn.lock when trying to downgrade that module. This change brings the correct resolution in the `yarn.lock`.
Closes https://github.com/facebook/metro-bundler/pull/29

Differential Revision: D5452305

Pulled By: jeanlauliac

fbshipit-source-id: 54026cfd9cf269e2b432dd92f16bd6db9fa4603c
2017-07-19 09:14:47 -07:00
Jean Lauliac 669f432dfb attempt at fixing yarn install in CircleCI 2017-07-19 15:54:12 +01:00
Jean Lauliac 8c716f0029 fix the test command 2017-07-19 15:38:33 +01:00
Jean Lauliac 7f68aa8493 metro-bundler: TerminalReporter: fix comment
Reviewed By: davidaurelio

Differential Revision: D5442902

fbshipit-source-id: bb9ccc05c4a6a69027448bad42880313732304a1
2017-07-18 10:31:48 -07:00
Jean Lauliac e023fe12d2 metro-bundler: downgrade block-scoping Babel plugin
Summary: Downgrade the locked version of Babel block scoping, kinda temporarily until we upgrade internally. This makes in on par with the version we use internally, so that the `basic_bundle` test had the same results on both infrastructures. This doesn't change a single thing for `metro-bundler` consumers, because this `yarn.lock` file is only used for testing/CI, not when the library is installed as part of a project.

Reviewed By: cpojer

Differential Revision: D5442368

fbshipit-source-id: f3033e450855f7d61ac775a46719d7b1743960c5
2017-07-18 08:13:02 -07:00
Jean Lauliac 9815cd6e6f metro-bunder: fix DependencyGraph-test for new jest-haste-map duplicates API
Summary: Now we have a nice specific error type for duplicates errors. This changeset have been commited before but was reverted as part of a stack, so here we go again.

Reviewed By: cpojer

Differential Revision: D5442363

fbshipit-source-id: 068c8decaf20cd4f9a73d9d54984030c79cff606
2017-07-18 08:13:02 -07:00
Jean Lauliac be9219b852 metro-bundler: Resolver: explicit option list
Summary: I appears `Object.assign` is not properly typed-checked by Flow, and silently so, so I propose we switch to an explicit list until we find an alternative solution. I prefer to have strong typing especially for options, and as the lack of typing has caused breakage before.

Reviewed By: cpojer

Differential Revision: D5442319

fbshipit-source-id: 82b0ec760c7dea6da6f7932896243147ce12ebf9
2017-07-18 04:40:35 -07:00
Jean Lauliac f58a9fa922 metro-bundler: Resolver: handle empty blacklistRE
Reviewed By: cpojer

Differential Revision: D5442309

fbshipit-source-id: f00283bf659100d9269c85b188e2e2fd44cbdc99
2017-07-18 04:40:34 -07:00
Mehdi Mulani e4b94a4d77 Revert D5424282, D5433438, D5424365, D5417982 to unbreak React Native
fbshipit-source-id: 0b32966feabeff6b785dae52a173854e6805f150
2017-07-17 16:37:39 -07:00
Jean Lauliac 635e41027c metro-bundler: put __tests__ blacklisting into default blacklist instead
Summary: I'd like to get rid of the function as blacklist, because it's impossible to process properly at the `jest-haste-map` level (https://github.com/facebook/jest/pull/4047). The reason we use a function in Metro bundler is because we excludes all the `__tests__` modules. However, I removed this exclusion completely, and I could build our package without any problem and with no difference in the final bundle. I can only assume, then, that this line is only here for slightly increasing performance. Therefore, I think it's reasonnable to move it as part of the default blacklist shipped with Metro bundler instead.

Reviewed By: cpojer

Differential Revision: D5434351

fbshipit-source-id: dea39f6299985143d25fcb3b7b365d793acd64a9
2017-07-17 11:24:06 -07:00
Jean Lauliac 40c4317086 metro-bunder: fix DependencyGraph-test for new jest-haste-map duplicates API
Summary: Now we have a nice specific error type for duplicates errors.

Reviewed By: cpojer

Differential Revision: D5433438

fbshipit-source-id: 47cad9ca6bf0bdec91a158ccb2807b6c5571966a
2017-07-17 09:36:03 -07:00
Miguel Jimenez Esun ffbc1c80a8 Remove default polyfills from metro-bundler
Reviewed By: davidaurelio

Differential Revision: D5423673

fbshipit-source-id: a66655cd72d56eb60a8a79a298ebfbc746b5ad10
2017-07-17 03:10:18 -07:00
Miguel Jimenez Esun 3f4135e444 Update Jest to 20.1.0, chi.1
Reviewed By: davidaurelio

Differential Revision: D5423945

fbshipit-source-id: deb58ba9288883b5d671148aeaa59da6629d0de4
2017-07-14 10:07:30 -07:00
Jean Lauliac 4399621d36 metro-bundler: upgrade jest to 20.1
Summary: This put it on par with the version we use on other projects. This new version breaks assumptions about the way Promise/ticks/timers use to work, and I was not able to make it work properly synchronously. Since it's fragile anyway (because rely on Promise and feature internals), I propose the switch to async as done in this changeset. If `res.end` is not called, tests will just timeout instead.

Reviewed By: cpojer

Differential Revision: D5423823

fbshipit-source-id: 015e808a2cf2b8297a36b16feeb811a6e745a835
2017-07-14 08:11:09 -07:00
Jean Lauliac 2ee051599a metro-bundler: fix DependencyGraph-test
Reviewed By: mjesun

Differential Revision: D5423513

fbshipit-source-id: a0093bb8d26d4c16790ed90cae21350451ebe04a
2017-07-14 07:42:11 -07:00
Miguel Jimenez Esun e787159f9e Revert D5406562: Remove default polyfills from metro-bundler
Differential Revision: D5406562

fbshipit-source-id: fe8222b9f6c04117dc0e0226c34f0f39df701c0d
2017-07-13 11:23:01 -07:00
Miguel Jimenez Esun abf49f0a02 Remove default polyfills from metro-bundler
Reviewed By: davidaurelio

Differential Revision: D5406562

fbshipit-source-id: 76a8850ab8e987407421084054d1d0eb23ff645d
2017-07-13 09:13:08 -07:00
Jean Lauliac ec01441adf metro-bundler: ModuleResolution: extract _loadAsFileOrDir()
Summary: Going one step further, we can start working around the throwing version. To simply some code, I also piggybacked the addition of helper functions `resolvedAs` and `failedFor` in this changeset, hope it's okay. I can split if necessary.

Reviewed By: davidaurelio

Differential Revision: D5415196

fbshipit-source-id: 1bd5955b5733866af52fa873bcd1d9e4ce8215cf
2017-07-13 08:37:07 -07:00
Jean Lauliac 4a9c7b9f30 metro-bundler: ModuleResolution: inline loadAsDirOrThrow
Reviewed By: cpojer, davidaurelio

Differential Revision: D5407426

fbshipit-source-id: 0e45b671d6696745ea37b99071f4e5bc2a6b4106
2017-07-13 06:24:43 -07:00
Jean Lauliac bc75b94b7e metro-bundler: ModuleResolution: remove loadAsFileOrThrow
Reviewed By: cpojer

Differential Revision: D5406612

fbshipit-source-id: bd20e1c9aa23b6988ab02c8c0459335874d7d346
2017-07-13 06:24:43 -07:00
Jean Lauliac 392a129b56 package-json-sync-test: verify metro-bundler dependencies as well
Reviewed By: davidaurelio

Differential Revision: D5370620

fbshipit-source-id: fdcbcd0b9bb78f37745ace28f9f8c17b8b8fd52e
2017-07-11 03:38:03 -07:00
Christoph Nakazawa b26b048c78 Revert D5321193: BREAKING: Add regenerator-runtime on demand, based on the files
Differential Revision: D5321193

fbshipit-source-id: 9113ed78e59ae9e9f3f86ca2fda2db3bd8c0dd7c
2017-07-07 10:51:29 -07:00
David Aurelio 0e4b4f7c7b Update `throat` dependency to 3.2.0
Summary: it has flow definitions now. OMG!

Reviewed By: cpojer

Differential Revision: D5381183

fbshipit-source-id: bdb3863b24da9802eeeb8a7d08f05d629f735178
2017-07-07 09:18:27 -07:00
Miguel Jimenez Esun 298d8b3e3e BREAKING: Add regenerator-runtime on demand, based on the files
Summary:
Adding a Babel plugin that will analyze the file looking for any potential candidate to use `regenerator-runtime`, and if so, will inject dynamically the module. The module is injected per file, so we avoid polluting the global environment. The plugin is also able to inject the `require` call beforehand, so that the inliner can pick them and inline them.

The Babel plugin is part of `react-native-babel-preset`, so as long as you are using this preset you are safe. If not, you should include the specific transformer into your list of plugins, as `react-native-babel-preset/transforms/transform-regenerator-runtime-insertion.js`.

Reviewed By: davidaurelio

Differential Revision: D5321193

fbshipit-source-id: fd4805b28c8a2b986842e23570a64003370d2067
2017-07-07 07:42:13 -07:00
Jean Lauliac 029483d796 metro-bundler: tweak babel-register callsite
Summary:
This fixes https://github.com/facebook/react-native/issues/14530 on my local repro. The reason the original problem appears is because when requiring the preset itself, what I think is a bug in babel-register kicks in and it starts transforming the presets themselves. That fails because these preset don't actually have the correct transforms plugins installed/specified in their `package.json` (they do it at prepublish time).
Closes https://github.com/facebook/metro-bundler/pull/21

Reviewed By: cpojer

Differential Revision: D5380795

Pulled By: jeanlauliac

fbshipit-source-id: 023fd6b36dc7ebd26961878edd71d423ea9856b5
2017-07-07 04:10:28 -07:00
Jean Lauliac 7450484d94 metro-bundler: fix DependencyGraph-test
Reviewed By: mjesun

Differential Revision: D5371267

fbshipit-source-id: 689f7c5b2920cb15d7ba6c50c34a94344b2a686b
2017-07-07 03:23:27 -07:00