Skip to content

Commit 0663343

Browse files
committed
Fixes requirejs#42, allow for preserveLicenseComments=false, default is true.
1 parent e03f08e commit 0663343

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

build/example.build.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,13 @@
284284
//called dirExclusionRegExp before the 1.0.2 release.
285285
//As of 1.0.3, this value can also be a string that is converted to a
286286
//RegExp via new RegExp().
287-
fileExclusionRegExp: /^\./
287+
fileExclusionRegExp: /^\./,
288+
289+
//By default, comments that have a license in them are preserved in the
290+
//output. However, for a larger built files there could be a lot of
291+
//comment files that may be better served by having a smaller comment
292+
//at the top of the file that points to the list of all the licenses.
293+
//This option will turn off the auto-preservation, but you will need
294+
//work out how best to surface the license information.
295+
preserveLicenseComments: true
288296
})

build/jslib/build.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function (lang, logger, file, parse, optimize, pragma,
2525
isBuild: true,
2626
optimizeAllPluginResources: false,
2727
findNestedDependencies: false,
28+
preserveLicenseComments: true,
2829
//By default, all files/directories are copied, unless
2930
//they match this regexp, by default just excludes .folders
3031
dirExclusionRegExp: file.dirExclusionRegExp

build/jslib/optimize.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ function (lang, logger, envOptimize, file, parse,
165165
'" not found for this environment');
166166
}
167167

168-
//Pull out any license comments for prepending after optimization.
169-
optimize.licenseCommentRegExp.lastIndex = 0;
170-
while ((match = optimize.licenseCommentRegExp.exec(fileContents))) {
171-
comment = match[0];
172-
//Only keep the comments if they are license comments.
173-
if (comment.indexOf('@license') !== -1 ||
174-
comment.indexOf('/*!') === 0) {
175-
licenseContents += comment + '\n';
168+
if (config.preserveLicenseComments) {
169+
//Pull out any license comments for prepending after optimization.
170+
optimize.licenseCommentRegExp.lastIndex = 0;
171+
while ((match = optimize.licenseCommentRegExp.exec(fileContents))) {
172+
comment = match[0];
173+
//Only keep the comments if they are license comments.
174+
if (comment.indexOf('@license') !== -1 ||
175+
comment.indexOf('/*!') === 0) {
176+
licenseContents += comment + '\n';
177+
}
176178
}
177179
}
178180

dist/r-edge.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license r.js 1.0.2+ 20111216 4:50pm Pacific Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2+
* @license r.js 1.0.2+ 20111216 5pm Pacific Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
33
* Available via the MIT or new BSD license.
44
* see: http://github.com/jrburke/requirejs for details
55
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
2020

2121
var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
2222
nodeDefine, exists, reqMain, loadedOptimizedLib,
23-
version = '1.0.2+ 20111216 4:50pm Pacific',
23+
version = '1.0.2+ 20111216 5pm Pacific',
2424
jsSuffixRegExp = /\.js$/,
2525
commandOption = '',
2626
//Used by jslib/rhino/args.js
@@ -7546,14 +7546,16 @@ function (lang, logger, envOptimize, file, parse,
75467546
'" not found for this environment');
75477547
}
75487548

7549-
//Pull out any license comments for prepending after optimization.
7550-
optimize.licenseCommentRegExp.lastIndex = 0;
7551-
while ((match = optimize.licenseCommentRegExp.exec(fileContents))) {
7552-
comment = match[0];
7553-
//Only keep the comments if they are license comments.
7554-
if (comment.indexOf('@license') !== -1 ||
7555-
comment.indexOf('/*!') === 0) {
7556-
licenseContents += comment + '\n';
7549+
if (config.preserveLicenseComments) {
7550+
//Pull out any license comments for prepending after optimization.
7551+
optimize.licenseCommentRegExp.lastIndex = 0;
7552+
while ((match = optimize.licenseCommentRegExp.exec(fileContents))) {
7553+
comment = match[0];
7554+
//Only keep the comments if they are license comments.
7555+
if (comment.indexOf('@license') !== -1 ||
7556+
comment.indexOf('/*!') === 0) {
7557+
licenseContents += comment + '\n';
7558+
}
75577559
}
75587560
}
75597561

@@ -8120,6 +8122,7 @@ function (lang, logger, file, parse, optimize, pragma,
81208122
isBuild: true,
81218123
optimizeAllPluginResources: false,
81228124
findNestedDependencies: false,
8125+
preserveLicenseComments: true,
81238126
//By default, all files/directories are copied, unless
81248127
//they match this regexp, by default just excludes .folders
81258128
dirExclusionRegExp: file.dirExclusionRegExp

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy