Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV-only requires in FB bundles #10176

Closed
gaearon opened this issue Jul 13, 2017 · 2 comments
Closed

DEV-only requires in FB bundles #10176

gaearon opened this issue Jul 13, 2017 · 2 comments

Comments

@gaearon
Copy link
Collaborator

gaearon commented Jul 13, 2017

I see ReactDOMFiber-prod starts with

var invariant = require("fbjs/lib/invariant"), EventListener = require("fbjs/lib/EventListener"), React = require("React"), warning = require("fbjs/lib/warning"), ExecutionEnvironment = require("fbjs/lib/ExecutionEnvironment");

require("fbjs/lib/camelizeStyleName");

var hyphenateStyleName = require("fbjs/lib/hyphenateStyleName"), memoizeStringOnly = require("fbjs/lib/memoizeStringOnly");

require("prop-types");

var emptyFunction = require("fbjs/lib/emptyFunction"), containsNode = require("fbjs/lib/containsNode"), focusNode = require("fbjs/lib/focusNode"), getActiveElement = require("fbjs/lib/getActiveElement"), shallowEqual = require("fbjs/lib/shallowEqual");

require("prop-types/checkPropTypes");

Notice how require("prop-types") shouldn't be there. We probably require it and then don’t use it in PROD. We need some mechanism to express a module is pure from side effects, and have Rollup DCE this require.

@gaearon
Copy link
Collaborator Author

gaearon commented Jul 14, 2017

Preliminary conclusion: we decided that we’d write a Babel plugin that removes require/imports that are not referenced and fall into a whitelist of known modules without side effects. This seems easier than hooking into Rollup.

@gaearon
Copy link
Collaborator Author

gaearon commented Jan 2, 2018

Not a problem anymore.

"use strict";
var invariant = require("fbjs/lib/invariant"),
  React = require("React"),
  ExecutionEnvironment = require("fbjs/lib/ExecutionEnvironment"),
  emptyFunction = require("fbjs/lib/emptyFunction"),
  getActiveElement = require("fbjs/lib/getActiveElement"),
  shallowEqual = require("fbjs/lib/shallowEqual"),
  containsNode = require("fbjs/lib/containsNode"),
  emptyObject = require("fbjs/lib/emptyObject"),
  TouchEventUtils = require("fbjs/lib/TouchEventUtils");

I probably fixed it in #11389, specifically in 1bd389f.

@gaearon gaearon closed this as completed Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants