profile
viewpoint
Kenton Jacobsen brokentone vogue.com New York, NY

brokentone/Var-Dump-Beautifier 3

Easily view and access PHP variables within a var dump

brokentone/PHP-exercises 2

A collection of a few excercises to learn PHP and version control

brokentone/PHP-simpleOAuth 2

A really simple and light class for dealing with OAuth 1.0a requests and signing

brokentone/SociallyAbstract 2

A PHP library for social media service abstraction

brokentone/FB-Stream-Publish 1

Just a class to allow stream publish functionality in PHP

brokentone/Homestar-Walkaround 1

Just some python I'm playing around with while trying to learn. Nothing fancy, just a simple but awesome adventure game

brokentone/babel-7-async-default 0

Temp repo showing async default issue in babel-7-alpha

brokentone/Co-Authors-Plus 0

Multiple bylines and Guest Authors for WordPress

brokentone/commonmark 0

Markdown parser for PHP based on the CommonMark spec.

brokentone/disc 0

:chart_with_upwards_trend: Visualise the module tree of browserify project bundles and track down bloat.

starteduhyo/castella

started time in 2 hours

startedtech-conferences/confs.tech

started time in 2 days

startedformatjs/formatjs

started time in 7 days

startedmeltingice/psd.js

started time in 7 days

startediamkun/dayjs

started time in 8 days

startedCNwoman-bot/evil-man

started time in 8 days

startedwbkd/react-flow

started time in 9 days

startedrxhanson/Rectangle

started time in 11 days

issue commentfacebook/fbjs

[security] upgrade to latest version of isomorphic-fetch

Any updates on this?

redonkulus

comment created time in 12 days

startedacf-extended/ACF-Extended

started time in 13 days

fork yrosen/wds-blocks

A library of Gutenberg blocks.

fork in 13 days

startedpmndrs/valtio

started time in 13 days

startedvanGalilea/react-native-testing

started time in 13 days

pull request commentfacebook/fbjs

fix(jest): update cache function for new Jest 27 API

An alternative would be to use https://github.com/facebook/jest/tree/e5816610eaa6d8aa6b4742909d7495be77f8f347/packages/jest-create-cache-key-function which will handle both 26 and 27 version of the signature

SimenB

comment created time in 15 days

PR opened facebook/fbjs

fix(jest): update cache function for new Jest 27 API

See https://github.com/facebook/jest/pull/10834

+2 -0

0 comment

1 changed file

pr created time in 15 days

startednaver/egjs-flicking

started time in 19 days

startedsickcodes/Docker-OSX

started time in 19 days

startedTencent/vap

started time in 19 days

PR opened facebook/fbjs

Eliminate usage of @flow weak in keyMirrorRecursive

@flow weak is deprecated. Replace single instance with @flow instead and add suppression on error which was previously hidden.

+3 -2

0 comment

1 changed file

pr created time in 19 days

pull request commentfacebook/fbjs

bump ua-parser-js to fix RegExp DoS vulnerability

@lorenzocestaro is this ready to merge?

lorenzocestaro

comment created time in 19 days

push eventfacebook/fbjs

Naman Aggarwal

commit sha 4d1751311d3f67af2dcce2e40df8512a23c7b9c6

Fix require shadowing in `inline-requires` plugin (#406)

view details

push time in 20 days

PR merged facebook/fbjs

Fix require shadowing in `inline-requires` plugin CLA Signed
  1. It's possible that the require is overridden in a module (or scope) and no longer points to the CommonJS require function. The plugin doesn't respect this. For this, we will now honor the require redeclaration if in global scope.
  2. If the require function is re-declared in a sub-scope, e.g. a function. The plugin changes the semantics of the program by inlining the require call without renaming the scoped require declaration (it then accidentally calls the custom require implementation). This is fixed by renaming local scope "require" functions and calls to "_require"
+242 -14

0 comment

3 changed files

namaggarwal

pr closed time in 20 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 function getInlineableModule(node, state) {         : null;   } -  return moduleName == null || state.ignoredRequires.has(moduleName)+  // Check if require is in any parent scope+  let parentPath = path.parentPath;+  let isRequireInScope = false;+  const fnName = node.callee.name;+  while (parentPath) {+    if (parentPath.scope.getBinding(fnName) != null) {+      isRequireInScope = true;+      break;+    }+    parentPath = parentPath.parentPath;+  }

Thank you. Updated

namaggarwal

comment created time in 20 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 function getInlineableModule(node, state) {         : null;   } -  return moduleName == null || state.ignoredRequires.has(moduleName)+  // Check if require is in any parent scope+  let parentPath = path.parentPath;+  let isRequireInScope = false;+  const fnName = node.callee.name;+  while (parentPath) {+    if (parentPath.scope.getBinding(fnName) != null) {+      isRequireInScope = true;+      break;+    }+    parentPath = parentPath.parentPath;+  }

You don't have to traverse up in the tree. scope.getBinding() checks the current scope and any parent scope

https://github.com/babel/babel/blob/master/packages/babel-traverse/src/scope/index.js#L993-L1017

namaggarwal

comment created time in 20 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 module.exports = babel => ({                 return;               }               const {declarationPath, moduleName} = parseResult;+              const requireName = path.node.callee.name || path.node.callee.property.name;++              // If declaration path has require binding in the scope then+              // don't inline calls+              if(declarationPath.scope.getBinding(requireName) != null) {+                return;+              }

Done. Can you please check the updated code

namaggarwal

comment created time in 21 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 var foo = require(\\"foo\\"); " `; +exports[`inline-requires does not transform require calls if its not needed: does not transform require calls if its not needed 1`] = `+"+function test () {+  function require(condition) {+    if (!condition) {+      throw new Error('The condition is false');+    }+  }++  require('test');+}++      ↓ ↓ ↓ ↓ ↓ ↓++function test() {+  function require(condition) {+    if (!condition) {+      throw new Error('The condition is false');+    }+  }++  require('test');+}+"+`;++exports[`inline-requires ensures that the inlined require still points to the global require function even if local require is not called: ensures that the inlined require still points to the global require function even if local require is not called 1`] = `+"+const foo = require('foo');++function test() {+  function require(condition) {+    if (!condition) {+      throw new Error('Condition is falsy');+    }+  }++  foo.isOnline();

Yes, this is intentional and a different test as I wanted to test that it shouldn't rename the "require" function unnecessary

namaggarwal

comment created time in 21 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 module.exports = babel => ({               for (const referencePath of binding.referencePaths) {                 excludeMemberAssignment(moduleName, referencePath, state);                 try {+                  const requireBinding = referencePath.scope.getBinding(+                    requireName+                  );+                  if (requireBinding != null) {+                    requireBinding.scope.rename(requireName);+                  }

The check for an existing requireBinding shouldn't be necessary. referencePath.scope.rename is a no-op if the existing name has no references.

                  referencePath.scope.rename(requireName);
namaggarwal

comment created time in 21 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 module.exports = babel => ({             ignoredRequires,             inlineableCalls,             membersAssigned: new Map(),-          },+          }

Nit: Keep the comma

namaggarwal

comment created time in 21 days

Pull request review commentfacebook/fbjs

Fix require shadowing in `inline-requires` plugin

 module.exports = babel => ({                 return;               }               const {declarationPath, moduleName} = parseResult;+              const requireName = path.node.callee.name || path.node.callee.property.name;++              // If declaration path has require binding in the scope then+              // don't inline calls+              if(declarationPath.scope.getBinding(requireName) != null) {+                return;+              }

I suggest to move the logic for getting the requireName and testing if there's no override in the current or any parent scope into the getInlineableModule function

function getInlineableModule(path, state) {
  const node = path.node;
  const fnName = node.callee.name;

  const isInlineable =
    node.type === 'CallExpression' &&
    node.callee.type === 'Identifier' &&
    state.inlineableCalls.has(fnName) &&
    node['arguments'].length >= 1 && 
    path.scope.getBinding(fnName) == null;

  if (!isInlineable) {
    return null;
  }
  
  // ....

  return moduleName == null || state.ignoredRequires.has(moduleName)
    ? null
    : { moduleName, requireFnName: fnName };
}

You'll have to rewrite the two call-sites to pass a path instead of a node and to get the moduleName and requireFnName from the returned object.

namaggarwal

comment created time in 21 days

more