/**
 * Copyright (c) 2013-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
'use strict';

module.exports = function sizes(pureExternalModules) {
  return {
    name: 'scripts/rollup/plugins/strip-unused-imports',
    transformBundle(code) {
      pureExternalModules.forEach(module => {
        const regExp = new RegExp(
          `(?<!= *)require\\(["']${module}["']\\)[,;]`,
          'g'
        );
        code = code.replace(regExp, '');
      });
      return {code};
    },
  };
};

@@ -222,11 +222,24 @@
 on s
-ize
+tripUnusedImport
 s(pu
@@ -401,16 +401,316 @@
 le =%3E %7B%0A
+        // Ideally this would use a negative lookbehind: (?%3C!= *)%0A        // But this isn't supported by the Node %3C= 8.9.%0A        // So instead we try to handle the most common cases:%0A        // 1. foo,bar=require(%22bar%22),baz%0A        // 2. foo;bar = require('bar');baz%0A        // 3.   require('bar');%0A
         
@@ -748,22 +748,25 @@
       %60(
-?%3C!= *
+%5B,;%5D%7C %7B2%7D
 )require
@@ -857,16 +857,18 @@
 egExp, '
+$1
 ');%0A    

Remove negative lookbehind from Rollup plugin that broke Node <= v8.9 (#13538)