mirror of https://github.com/status-im/metro.git
Add require.getModules
Summary: In order to aid with debugging inline requires we add a method that will give us the modules. **Summary** I was looking for a way to see what modules had been loaded when I was working with inline requires. I had tried using beginEvent on Systrace, but I was worried that there were modules that I might have missed (I'm not certain if all the loaded files are polyfills before the entryFile is invoked for instance). By adding getModules() it simplifies seeing what modules are loaded. **Test plan** At the root of my app `index.ios.js`: ``` import App from './App'; import { AppRegistry } from 'react-native'; AppRegistry.registerComponent('App', () => App); // after 3 seconds the initial app data should have loaded, so lets take a look: setTimeout(() => { console.log(require.getModules()); }, 3000); ``` **NOTE** If there is a way to get to this easily (via the debugger or some other mechanism) I would be happy to use that instead and add documentation for it. Closes https://github.com/facebook/metro-bundler/pull/37 Differential Revision: D6008180 Pulled By: cpojer fbshipit-source-id: 850103bbce166bf65a0cbd710582198c66273db5
This commit is contained in:
parent
c4307d7170
commit
475a580569
|
@ -234,6 +234,10 @@ function moduleThrewError(id, error: any) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
require.Systrace = {beginEvent: () => {}, endEvent: () => {}};
|
require.Systrace = {beginEvent: () => {}, endEvent: () => {}};
|
||||||
|
|
||||||
|
require.getModules = () => {
|
||||||
|
return modules;
|
||||||
|
};
|
||||||
|
|
||||||
// HOT MODULE RELOADING
|
// HOT MODULE RELOADING
|
||||||
var createHotReloadingObject = function() {
|
var createHotReloadingObject = function() {
|
||||||
const hot: HotModuleReloadingData = {
|
const hot: HotModuleReloadingData = {
|
||||||
|
|
|
@ -159,6 +159,10 @@ if (__DEV__) {
|
||||||
(function () {
|
(function () {
|
||||||
_require.Systrace = { beginEvent: function beginEvent() {}, endEvent: function endEvent() {} };
|
_require.Systrace = { beginEvent: function beginEvent() {}, endEvent: function endEvent() {} };
|
||||||
|
|
||||||
|
_require.getModules = function () {
|
||||||
|
return modules;
|
||||||
|
};
|
||||||
|
|
||||||
createHotReloadingObject = function createHotReloadingObject() {
|
createHotReloadingObject = function createHotReloadingObject() {
|
||||||
var hot = {
|
var hot = {
|
||||||
acceptCallback: null,
|
acceptCallback: null,
|
||||||
|
@ -437,6 +441,10 @@ if (__DEV__) {
|
||||||
(function () {
|
(function () {
|
||||||
_require.Systrace = { beginEvent: function beginEvent() {}, endEvent: function endEvent() {} };
|
_require.Systrace = { beginEvent: function beginEvent() {}, endEvent: function endEvent() {} };
|
||||||
|
|
||||||
|
_require.getModules = function () {
|
||||||
|
return modules;
|
||||||
|
};
|
||||||
|
|
||||||
createHotReloadingObject = function createHotReloadingObject() {
|
createHotReloadingObject = function createHotReloadingObject() {
|
||||||
var hot = {
|
var hot = {
|
||||||
acceptCallback: null,
|
acceptCallback: null,
|
||||||
|
|
Loading…
Reference in New Issue