@samitouri / QOS-React / commits / 8b7082eced

Add license headers on build bundles (#10490)

* Add license headers on build bundles * Add the filename IMO to header * Preserve headers in production bundles * Use ECMASCRIPT5_STRICT to preserve "use strict"

guoyong yi committed Sep 8, 2017 at 02:38 UTC 8b7082eced4405fdd9243c5f4495148935d3e7d6
2 files changed +18 -9
scripts/rollup/build.js
+7 -5
@@ -82,14 +82,16 @@ function getBanner(bundleType, hasteName, filename) {
82 // UMDs are not wrapped in conditions.
83 case UMD_DEV:
84 case UMD_PROD:
85 - return Header.getUMDHeader(filename, reactVersion);
85 + return Header.getHeader(filename, reactVersion);
86 // CommonJS DEV bundle is guarded to help weak dead code elimination.
87 case NODE_DEV:
88 + let banner = Header.getHeader(filename, reactVersion);
89 // Wrap the contents of the if-DEV check with an IIFE.
90 // Block-level function definitions can cause problems for strict mode.
90 - return `'use strict';\n\n\nif (process.env.NODE_ENV !== "production") {\n(function() {\n`;
91 + banner += `'use strict';\n\n\nif (process.env.NODE_ENV !== "production") {\n(function() {\n`;
92 + return banner;
93 case NODE_PROD:
92 - return '';
94 + return Header.getHeader(filename, reactVersion);
95 // All FB and RN bundles need Haste headers.
96 // DEV bundle is guarded to help weak dead code elimination.
97 case FB_DEV:
@@ -344,8 +346,8 @@ function getPlugins(
346 commonjs(getCommonJsConfig(bundleType)),
347 closure({
348 compilationLevel: 'SIMPLE',
347 - languageIn: 'ES5',
348 - languageOut: 'ES5',
349 + languageIn: 'ECMASCRIPT5_STRICT',
350 + languageOut: 'ECMASCRIPT5_STRICT',
351 env: 'CUSTOM',
352 warningLevel: 'QUIET',
353 assumeFunctionWrapper: true,
scripts/rollup/header.js
+11 -4
@@ -15,14 +15,21 @@ function getProvidesHeader(hasteFinalName) {
15 `;
16 }
17
18 -function getUMDHeader(filename, reactVersion) {
19 - return `/**
20 - * ${filename} v${reactVersion}
18 +function getHeader(filename, reactVersion) {
19 + return `/** @license React v${reactVersion}
20 + * ${filename}
21 + *
22 + * Copyright 2013-present, Facebook, Inc.
23 + * All rights reserved.
24 + *
25 + * This source code is licensed under the BSD-style license found in the
26 + * LICENSE file in the root directory of this source tree. An additional grant
27 + * of patent rights can be found in the PATENTS file in the same directory.
28 */
29 `;
30 }
31
32 module.exports = {
33 getProvidesHeader,
27 - getUMDHeader,
34 + getHeader,
35 };