Commit Graph

1366 Commits

Author SHA1 Message Date
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
David Aurelio 7111cf6e4e Bump dependencies
Summary: Bump dependencies to the same version that react native uses

Reviewed By: jeanlauliac

Differential Revision: D5364009

fbshipit-source-id: 302db951a5509584da13a18a7fab6965e0b1e394
2017-07-06 14:36:22 -07:00
Jean Lauliac e3a9e82b69 metro-bundler: remove image-size
Summary:
It appears this is not needed to build or anything, only for metro-bundler itself.

Closes https://github.com/facebook/metro-bundler/issues/20.

Reviewed By: cpojer

Differential Revision: D5370513

fbshipit-source-id: 563b5716ca9ab1b58fc7ae1f757efc61cf946168
2017-07-06 02:08:34 -07:00
David Aurelio efa753c2e4 Restore file header for RAM bundles
Summary: Restores the ability to write the expected header for indexed RAM bundles by avoiding to stringify buffers as utf8. Some minor cleanups included

Reviewed By: javache

Differential Revision: D5351839

fbshipit-source-id: 056661b064336ff74571b9f44c16d709fc59145b
2017-06-30 11:07:02 -07:00
Jean Lauliac b96d886982 metro-bundler: upgrade jest-haste-map
Reviewed By: cpojer

Differential Revision: D5346860

fbshipit-source-id: 16e9eeeb28804af81428745fda4ffc05a461845c
2017-06-29 08:36:14 -07:00
Christopher Chedeau e0ea0aae1d Codemod prettier to 1.5.2
Differential Revision: D5339725

fbshipit-source-id: 631338436a7d69b0ab0721507bdab4ae4e207065
2017-06-28 13:00:25 -07:00
Christopher Chedeau 138ae9623c Update prettier to 1.5.2
Differential Revision: D5338894

fbshipit-source-id: c3ccd927b7f4ddcb36d744b84f66c85f8dea0686
2017-06-28 13:00:25 -07:00
David Aurelio 429c1e8032 Use `jest-docblock`
Summary:
Remove our internal docbloc module and use `jest-docblock` instead.

The development server is using `jest-haste-map` exclusively, which in turn relies on `jest-docblock`, which differs slightly from our own docblock module.

Depending on only one version greatly reduces the number of edge cases

Reviewed By: cpojer

Differential Revision: D5328472

fbshipit-source-id: 4a31d8159519e01a83fda04b76e8f14f0beb16af
2017-06-27 03:51:37 -07:00
Chris Blappert f7ad406c23 Packager postprocessing hook
Reviewed By: davidaurelio

Differential Revision: D5244060

fbshipit-source-id: 3f5f9ab9aeeb63eca13d6dab089c2bda42f70c33
2017-06-26 10:36:25 -07:00
David Aurelio 3cf8242128 Trim doc block annotations after parsing
Summary:
Trims doc block annotations. This mitigates problems with leading and trailing spaces in `providesModule` annotations.

This module doesn’t have tests, but it is exclusively used for `providesModule` annotations right now.

Reviewed By: mjesun

Differential Revision: D5319814

fbshipit-source-id: de55df5b4b199738f9b01151eb86f3c863485b15
2017-06-26 06:11:42 -07:00