Commit Graph

1750 Commits

Author SHA1 Message Date
Jean Lauliac 730104b8ee metro: ModuleResolution: cleanup unnecessary code for file extensions
Reviewed By: davidaurelio

Differential Revision: D6602014

fbshipit-source-id: 86aa7b33370cabbbd2e2602131cd71145629516c
2017-12-20 01:59:06 -08:00
Jean Lauliac c9023fd907 metro: cleanup UnableToResolveError
Summary: I want to get rid of `TModule` and stuff so that we can eventually reunite this with `jest-resolve`. This is a continuation of the cleanup I started a long time ago.

Reviewed By: davidaurelio

Differential Revision: D6601657

fbshipit-source-id: 62c1806783323ee50e9a09146c73006c721eb891
2017-12-20 01:59:06 -08:00
Rafael Oleza 056ea9b5bf Fix lint error
Reviewed By: davidaurelio

Differential Revision: D6598510

fbshipit-source-id: c4c6a340d72090c9184471985674a25c6cde6238
2017-12-19 04:15:49 -08:00
Rafael Oleza dfb5d95a0d Fix flow error when calling hash.digest()
Reviewed By: cpojer

Differential Revision: D6598742

fbshipit-source-id: 47bd6f0ee0d54c61c2ff9b201005e7366d9df76d
2017-12-19 04:15:47 -08:00
Rafael Oleza 3b497585f1 Make collectDependencies smarter when evaluating the require argument
Reviewed By: BYK

Differential Revision: D6592104

fbshipit-source-id: d90a93c51cb04e38cc172eb8eda932f64fce0075
2017-12-18 12:40:27 -08:00
Miguel Jimenez Esun 57cfa19518 Update to Jest 22.0.0
Reviewed By: cpojer

Differential Revision: D6591693

fbshipit-source-id: ac3d6320445372a5694e7618ed52eb2f391d0bad
2017-12-18 05:20:08 -08:00
Peter van der Zee c32aef25c9 Update metro version to v0.24.1
Reviewed By: rafeca

Differential Revision: D6579060

fbshipit-source-id: f36a87bce9633370a02b8991cec4aced05ca72d1
2017-12-15 10:45:27 -08:00
Peter van der Zee ed269d0f8a Bump metro and all packages to v0.24.0
Reviewed By: rafeca

Differential Revision: D6578653

fbshipit-source-id: 99ec17bcb7c1f4daeb868c3755a9e6e668d1ae61
2017-12-15 10:45:27 -08:00
Peter van der Zee 1d1c23160f Add metro-core to the package.jsons that use it
Reviewed By: rafeca

Differential Revision: D6578053

fbshipit-source-id: b9d4e2e5820854ffe0e9cb54a78436d0ef2917ce
2017-12-15 06:39:55 -08:00
Peter van der Zee 4586152ebf Move Logger to metro-core
Reviewed By: rafeca

Differential Revision: D6568129

fbshipit-source-id: fc367c45e22ef58436331e1a6347ec16f1f155a0
2017-12-15 06:39:55 -08:00
Peter van der Zee 1d12090bc3 Move unused sleep module out of repo
Reviewed By: rafeca

Differential Revision: D6566682

fbshipit-source-id: 48cff465ace25d6d38b8574006e0c54081b8fbde
2017-12-15 06:39:55 -08:00
Peter van der Zee d7e0111bb6 Eliminate cyclic dependency for the sake of BundleOptions
Reviewed By: rafeca

Differential Revision: D6556262

fbshipit-source-id: da710f619e486a43a759b03cae61d6bc20ce5e87
2017-12-15 06:39:55 -08:00
Peter van der Zee 9485a37fe0 Move formatBanner to metro-core
Reviewed By: rafeca

Differential Revision: D6555773

fbshipit-source-id: 9d10a3d03c88eeaa2d6845518da3dacab8b556b0
2017-12-15 06:39:55 -08:00
Peter van der Zee a96e99fae5 Move Terminal to metro-core
Reviewed By: rafeca

Differential Revision: D6532920

fbshipit-source-id: d1463aa0759a6b6d5cc46b05157518a4ce3eb9bf
2017-12-15 06:39:55 -08:00
Sam Goldman 539ddc50f4 Use `declare module.exports` syntax for flow libdefs
Summary:
**Summary**

We added this to Flow in v0.25 (about 2 years ago), but never actually
deprecated the legacy `declare var exports` syntax. Hoping to do that
soon, so clearing up uses that I can find.

**Test plan**

flow
Closes https://github.com/facebook/metro/pull/108

Reviewed By: cpojer

Differential Revision: D6577785

Pulled By: samwgoldman

fbshipit-source-id: 2ef499cebb70ce3d9312cca6e084815394ab6169
2017-12-15 02:46:50 -08:00
Burak Yigit Kaya 82b508296d Fallback to Haste name if file path cannot be found when bundling
Reviewed By: rafeca

Differential Revision: D6567420

fbshipit-source-id: 84821b31b45bc7eeb302eef83531cc9a4e666406
2017-12-14 11:46:14 -08:00
Jean Lauliac 86914666e5 metro-buck: check validity of segments
Reviewed By: davidaurelio

Differential Revision: D6496312

fbshipit-source-id: 586dc8d9f64d13cfddaf6bfe768e8f7b3442561a
2017-12-14 09:59:47 -08:00
Brian Shin d2075f3743 Add inline support code for PlatformOS
Reviewed By: mjesun

Differential Revision: D6491061

fbshipit-source-id: e51b50e8a5b1c497946f8dfa3a95bd7599877018
2017-12-13 09:45:20 -08:00
Brian Shin 1a37164dac Extract some platform related code to a separate file
Reviewed By: davidaurelio

Differential Revision: D6491060

fbshipit-source-id: e8d040495b549e1925932b4ded4b44dd1f81fff6
2017-12-13 09:45:20 -08:00
Rafael Oleza db47372f06 Pass runBeforeMainModule option correctly when building prod bundles
Summary:
On D6248242, runBeforeMainModule was changed to `getModulesRunBeforeMainModule`, but the entry point used by opensource to build prod bundles was not updated. We couldn't catch this since we don't use this codepath internally

Fixes https://github.com/facebook/metro/issues/73

Reviewed By: mjesun

Differential Revision: D6556097

fbshipit-source-id: 889eaf825c7c3cdebe1ca4fc9831020a4a7d56dc
2017-12-13 08:30:59 -08:00
Nat Mote 26159b6638 Update to Flow v0.61.0
Reviewed By: gabelevi

Differential Revision: D6540122

fbshipit-source-id: 0ded15d3b368555d12c693feb4bf491bd9092355
2017-12-12 10:44:53 -08:00
Jean Lauliac 26c7a96f44 metro: JSTransformer/worker: report the filename when a dynamic dep is encountered
Reviewed By: rafeca

Differential Revision: D6544291

fbshipit-source-id: 618851850b50d49a29c767ba0d21a7bad522c4ca
2017-12-12 06:14:30 -08:00
Jean Lauliac 2bd9a503a1 metro: collectDependencies: fix error message
Reviewed By: rafeca

Differential Revision: D6544283

fbshipit-source-id: d2e7144ae6f77f312e02ef7720212e9505bd002e
2017-12-12 06:14:30 -08:00
Rafael Oleza 6f0d786e57 Simplify the inlineRequires transform option on incremental builds
Reviewed By: davidaurelio

Differential Revision: D6533845

fbshipit-source-id: ae38defafe70344d0bb0b80d2266dff0e9b273b1
2017-12-11 13:00:00 -08:00
Rafael Oleza 5e65dfcf81 Consolidate eslint config + fix some issues
Reviewed By: davidaurelio

Differential Revision: D6519564

fbshipit-source-id: 0cd894e92dfde451f8ee69d6c7c3d4cbd73b83ea
2017-12-11 12:32:20 -08:00
Jean Lauliac f044f42030 metro-buck: add e2e testing of command
Reviewed By: davidaurelio

Differential Revision: D6533842

fbshipit-source-id: b641559eb3085bac57ab3a1cc80a3f2f86b7ec92
2017-12-11 11:16:21 -08:00
Maël Nison f66eb477ba Adds an indirection layer to enhance the Metro middleware
Reviewed By: BYK

Differential Revision: D6436722

fbshipit-source-id: d864960e2eb7c8c2a96e9869c0b340cc6257808e
2017-12-11 10:15:08 -08:00
Rafael Oleza fa08cb3c99 Add metro-source-map dependency to metro package
Differential Revision: D6532856

fbshipit-source-id: c6df2ad47e2befbff809103da4dcea7b5eb71dad
2017-12-11 10:01:47 -08:00
Adam Ernst 62dcb400ca Back out D6509723
Reviewed By: danzimm

Differential Revision: D6529249

fbshipit-source-id: 71c4ca9f83edfd030f77f3b67290b5751384c731
2017-12-09 13:46:35 -08:00
David Aurelio ae5ebc8078 No compound assignement operators
Summary:
Addresses a performance regression introduced by automatic linting: Compound assignment operators are much slower than keeping assignment separate on `let` bindings in certain versions of v8.

This reverts the relevant changes and configures eslint to *disallow* these operators explicitly in `metro-source-map`.

Reviewed By: mjesun

Differential Revision: D6520485

fbshipit-source-id: 16f35f5cd691ce6b1924480cbc30fbaa1275f730
2017-12-09 13:46:35 -08:00
Rafael Oleza c5e83dd86a Log bundling errors to scuba
Reviewed By: davidaurelio

Differential Revision: D6519623

fbshipit-source-id: a8e54639a041e300bb98d8a9744490fdeae17d1a
2017-12-09 13:30:05 -08:00
Adam Liechty f347e4ff47 Expose createModuleIdFactory as bundler option
Summary:
**Summary**

`createModuleIdFactory` is already used in `metro` internally, but is currently always a fixed function.
This enables `metro.runBuild()` to be run with a custom module ID factory.

One use case: building a base bundle, on top of which other application-specific bundles could reference modules in the base.  The application-specific IDs need to not conflict with those in the base bundle, and all references to modules in the base must resolve to the correct ID in the base bundle.  A custom ID factory can make all this possible.

**Test plan**

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->

Using `metro.runBuild(...)` with these changes, I was able to substitute in a custom ID factory

```javascript
const fs = require('fs')
const metro = require('metro')

const baseManifestFileContents = JSON.parse(fs.readFileSync('./baseManifest.json'))
// baseManifest looks like:
// { "modules": { ...
//    "react/index.js": { "id": 12 },
//    "react/cjs/react.production.min.js": { "id": 13 }, ...  } }

const opts = {
  dev: false,
  entry: 'index.js',
  out: './out.bundle',
  platform: 'ios',
  projectRoots: ['.', 'node_modules'],
  config: {
    createModuleIdFactory: createModuleIdFactory(baseManifestFileContents)
  }
}

metro.runBuild(opts)

// Creates a sample custom ID factory
function createModuleIdFactory(manifestFileContents) {
  return function createModuleIdFactory() {
    const fileToIdMap = new Map()
    let nextId = manifestFileContents ? getNextIdAfterBaseManifest(manifestFileContents) : 0

    return path => {
      const sourcePath = path
        .replace(process.cwd() + '/node_modules/', '')
        .replace(process.cwd(), '.')

      // If module is in the base manifest, return its ID
      if (manifestFileContents && manifestFileContents.modules[sourcePath]) {
        return manifestFileContents.modules[sourcePath].id
      }

      // Otherwise, get it from the map or create a new ID
      if (!fileToIdMap.has(path)) {
        fileToIdMap.set(path, nextId)
        nextId += 1
      }
      return fileToIdMap.get(path)
    }
  }

  function getNextIdAfterBaseManifest(manifestFileContents) {
    return Object.keys(manifestFileContents.modules).reduce((id, key) => {
      if (manifestFileContents.modules[key].id > id) {
        return manifestFileContents.modules[key].id
      }
      return id
    }, 0) + 1
  }
}
```

With the sample module ID factory above, the output looks like the following, where defined module IDs start at a higher number to avoid the base module IDs, but may depend on modules in the base bundle (lower numbers).

```javascript
...
__d(function(r,o,t,i,n){t.exports=r.ErrorUtils},551,[]);
__d(function(n,t,o,r,u){'use strict';var e,c=t(u[0]);e=c.now?function(){return c.now()}:function(){return Date.now()},o.exports=e},552,[553]);
...
__d(function(e,t,r,s,l){'use strict'; ...},564,[18,565,27]);
...
```
Closes https://github.com/facebook/metro/pull/100

Reviewed By: mjesun

Differential Revision: D6508351

Pulled By: rafeca

fbshipit-source-id: f2cfe5c373a6c83c8ae6c526435538633a7c9c2a
2017-12-08 06:29:23 -08:00
Rafael Oleza 53290f5b9c Update flow-bin version
Reviewed By: mjesun

Differential Revision: D6519545

fbshipit-source-id: da9f5dd6029d5bfea4b6c758ca3df9caa5c5fa35
2017-12-08 05:28:57 -08:00
Rafael Oleza 6d7ba472ee Consolidate AssetData flow types
Reviewed By: jeanlauliac

Differential Revision: D6497429

fbshipit-source-id: cd9abe2d8c5b2b7eb48d8a0335ea5bfa8ac13269
2017-12-08 04:44:26 -08:00
Rafael Oleza 452ee5962d Add metro-source-map dependency to metro package
Reviewed By: cpojer

Differential Revision: D6509723

fbshipit-source-id: da92908c9272148112a98defed328d64cc1bf791
2017-12-08 04:16:06 -08:00
Peter Elmers 826a9489ca Fix 404 on front page 'Learn more' link
Summary:
<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. The two fields below are mandatory. -->

Currently index.js points to snapshot-testing which doesn't exist. Perhaps the intent was to link to the API page so that is what I changed.

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

front page 'learn more' link should work

<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. -->
Closes https://github.com/facebook/metro/pull/107

Reviewed By: cpojer

Differential Revision: D6511913

Pulled By: pelmers

fbshipit-source-id: 2a68a817cf4a318fb7dbfd5ea9a10fbea9e72620
2017-12-07 13:01:55 -08:00
Jean Lauliac 2ecf6c9450 metro: introduce asyncRequire function
Reviewed By: davidaurelio

Differential Revision: D6498107

fbshipit-source-id: a9c4ab634e60f19b7058205eddcd248f57f63500
2017-12-07 10:49:27 -08:00
Peter van der Zee 636c0ed5c9 Kick off metro-core by moving the source-map generator
Reviewed By: rafeca

Differential Revision: D6448594

fbshipit-source-id: 8498ae8ff62e5afc6ae92c56b7c15cdaf8acd3a1
2017-12-07 09:33:50 -08:00
Adam Ernst 9e4cfb4c93 Upgrade to 1.9.1
Reviewed By: vjeux

Differential Revision: D6497877

fbshipit-source-id: 3b88b96e375ddf1fbe039a0593569bbdde40a2dc
2017-12-06 17:31:38 -08:00
Miguel Jimenez Esun 3a377ee0a7 Upgrade Jest to "21.3.0-beta.13"
Reviewed By: rafeca

Differential Revision: D6497197

fbshipit-source-id: b816f4b02cf35abee4ce4098c30291b32656ed04
2017-12-06 09:04:51 -08:00
Rafael Oleza 758ce871e6 Get rid of AssetServer
Reviewed By: mjesun

Differential Revision: D6488612

fbshipit-source-id: e6144f0e143c0008d47342077b4a2c6c15765edc
2017-12-06 07:32:47 -08:00
Rafael Oleza 5bff35f09e Remove getAssetData() method from AssetServer
Reviewed By: mjesun

Differential Revision: D6488537

fbshipit-source-id: 48c27e9cf5802c62fb25aac592ac1c5bcd6cc87f
2017-12-06 07:32:46 -08:00
Rafael Oleza 3721464107 Update opengraph image
Reviewed By: mjesun

Differential Revision: D6496190

fbshipit-source-id: 6d8e2a462743d0f3af829713f43b6059af6a9548
2017-12-06 06:15:14 -08:00
Jean Lauliac 0e6f72b1ed metro: cleanup collectDependencies
Reviewed By: rafeca

Differential Revision: D6474108

fbshipit-source-id: fd497a248d3552a75e572b1ef8365cc5424c2c00
2017-12-06 03:17:09 -08:00
Steven Luscher 31eb3a6529 Capitalized ‘Express’
Summary:
It's a brand name.
Closes https://github.com/facebook/metro/pull/103

Reviewed By: cpojer

Differential Revision: D6484138

Pulled By: steveluscher

fbshipit-source-id: 98d0aa9a2a7da1068b12a918b83c9a83bc19f4ae
2017-12-05 11:29:42 -08:00
Rafael Oleza 0e583a981f Get rid of outdated_dependencies
Reviewed By: jeanlauliac

Differential Revision: D6485979

fbshipit-source-id: 8cf21a8c531d96df93f66e1cc465fe7ae044ef8e
2017-12-05 10:45:24 -08:00
Rafael Oleza d8cb904104 Bump metro@0.23.0
Reviewed By: davidaurelio

Differential Revision: D6484402

fbshipit-source-id: e934edc5319aec3c6f36927a0c8d5b48c304719e
2017-12-05 09:28:57 -08:00
Steven Luscher 989d209e5d Corrected grammar in ‘getting started‘
Summary:
Active voice, etc.
Closes https://github.com/facebook/metro/pull/102

Reviewed By: cpojer

Differential Revision: D6484141

Pulled By: steveluscher

fbshipit-source-id: c54c6c719497ee9612b816e9a3de4ca5fea8f4a5
2017-12-05 01:43:35 -08:00
Peter van der Zee dfa05cbcd4 Enable flow type for a file and fix a related typo/bug
Reviewed By: rafeca

Differential Revision: D6473575

fbshipit-source-id: 7b96b6bfb2aff96e6d4697ad29fd96fb85d1ceda
2017-12-05 01:31:30 -08:00
Rafael Oleza 5c06a80fd7 Remove old wrapping logic
Reviewed By: davidaurelio

Differential Revision: D6439155

fbshipit-source-id: 3332b9c7952c90411d0c595f184f92aeffd4ddd2
2017-12-04 16:46:17 -08:00