mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
* update rollup versioni * ignore Rollup warnings for known warning codes * add lecacy support from elas7 * rollup 1.5 * upd to ver 1.6.0 * don't throw error * use return instead of throw error * upd code in comment * fix getters test * rollup 1.7 * rollup 1.7.3 * remove comments * use rollup 1.7.4 * update yarn.lock for new rollup version * rollup version 1.9.0 * rollback to version 1.7.4 * add globalThis to eslintrc.umd * rollup 1.9.0 * upd rollup plugin versions to satisfied latest versions * add result.json update * rollup 1.9.3 * rollup 1.10.0 * ver 1.10.1 * rollup 1.11.3 * rollup ver 1.12.3 * rollup 1.13.1 * rollup 1.14.6 * rollup 1.15.6 * rollup 1.16.2 * upd tests * prettier * Rollup 1.16.3 * upd * should throw when finding getters with a different syntax from the ones generated by Rollup * add more one test * rollup-plugin-prettier updated changed stuff, revert them * don't upd all the Rollup plugins * rollup-plugin-babel 3.0.7 * upd rollup plugin versions * upd rollup-plugin-commonjs * bracket spacing * rollup 1.16.6 * rollup 1.16.7 * rename test description * rollup 1.18.0 * use externalLiveBindings: false * rollup 1.19.3 * remove remove-getters * simplify CIRCULAR_DEPENDENCY warning * simplify if logic in sizes-plugin * rollup 1.19.4 * update output for small optimizations * remove globalThis * remove results.json file * re-add globalThis
30 lines
918 B
JavaScript
30 lines
918 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* 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 stripUnusedImports(pureExternalModules) {
|
|
return {
|
|
name: 'scripts/rollup/plugins/strip-unused-imports',
|
|
renderChunk(code) {
|
|
pureExternalModules.forEach(module => {
|
|
// Ideally this would use a negative lookbehind: (?<!= *)
|
|
// But this isn't supported by the Node <= 8.9.
|
|
// So instead we try to handle the most common cases:
|
|
// 1. foo,bar=require("bar"),baz
|
|
// 2. foo;bar = require('bar');baz
|
|
// 3. require('bar');
|
|
const regExp = new RegExp(
|
|
`([,;]| {2})require\\(["']${module}["']\\)[,;]`,
|
|
'g'
|
|
);
|
|
code = code.replace(regExp, '$1');
|
|
});
|
|
return {code};
|
|
},
|
|
};
|
|
};
|