1
1
/**
2
- * @license r.js 1.0.3 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2
+ * @license r.js 1.0.4 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
3
* Available via the MIT or new BSD license.
4
4
* see: http://github.com/jrburke/requirejs for details
5
5
*/
@@ -20,7 +20,7 @@ var requirejs, require, define;
20
20
21
21
var fileName , env , fs , vm , path , exec , rhinoContext , dir , nodeRequire ,
22
22
nodeDefine , exists , reqMain , loadedOptimizedLib ,
23
- version = '1.0.3 ' ,
23
+ version = '1.0.4 ' ,
24
24
jsSuffixRegExp = / \. j s $ / ,
25
25
commandOption = '' ,
26
26
//Used by jslib/rhino/args.js
@@ -101,7 +101,7 @@ var requirejs, require, define;
101
101
}
102
102
103
103
/** vim: et:ts=4:sw=4:sts=4
104
- * @license RequireJS 1.0.3 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
104
+ * @license RequireJS 1.0.4 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
105
105
* Available via the MIT or new BSD license.
106
106
* see: http://github.com/jrburke/requirejs for details
107
107
*/
@@ -113,7 +113,7 @@ var requirejs, require, define;
113
113
114
114
( function ( ) {
115
115
//Change this version number for each release.
116
- var version = "1.0.3 " ,
116
+ var version = "1.0.4 " ,
117
117
commentRegExp = / ( \/ \* ( [ \s \S ] * ?) \* \/ | ( [ ^ : ] | ^ ) \/ \/ ( .* ) $ ) / mg,
118
118
cjsRequireRegExp = / r e q u i r e \( \s * [ " ' ] ( [ ^ ' " \s ] + ) [ " ' ] \s * \) / g,
119
119
currDirRegExp = / ^ \. \/ / ,
@@ -425,7 +425,15 @@ var requirejs, require, define;
425
425
url = urlMap [ normalizedName ] ;
426
426
if ( ! url ) {
427
427
//Calculate url for the module, if it has a name.
428
- url = context . nameToUrl ( normalizedName , null , parentModuleMap ) ;
428
+ //Use name here since nameToUrl also calls normalize,
429
+ //and for relative names that are outside the baseUrl
430
+ //this causes havoc. Was thinking of just removing
431
+ //parentModuleMap to avoid extra normalization, but
432
+ //normalize() still does a dot removal because of
433
+ //issue #142, so just pass in name here and redo
434
+ //the normalization. Paths outside baseUrl are just
435
+ //messy to support.
436
+ url = context . nameToUrl ( name , null , parentModuleMap ) ;
429
437
430
438
//Store the URL mapping for later.
431
439
urlMap [ normalizedName ] = url ;
@@ -730,7 +738,7 @@ var requirejs, require, define;
730
738
prefix = map . prefix ,
731
739
plugin = prefix ? plugins [ prefix ] ||
732
740
( plugins [ prefix ] = defined [ prefix ] ) : null ,
733
- manager , created , pluginManager ;
741
+ manager , created , pluginManager , prefixMap ;
734
742
735
743
if ( fullName ) {
736
744
manager = managerCallbacks [ fullName ] ;
@@ -768,7 +776,18 @@ var requirejs, require, define;
768
776
//If there is a plugin needed, but it is not loaded,
769
777
//first load the plugin, then continue on.
770
778
if ( prefix && ! plugin ) {
771
- pluginManager = getManager ( makeModuleMap ( prefix ) , true ) ;
779
+ prefixMap = makeModuleMap ( prefix ) ;
780
+
781
+ //Clear out defined and urlFetched if the plugin was previously
782
+ //loaded/defined, but not as full module (as in a build
783
+ //situation). However, only do this work if the plugin is in
784
+ //defined but does not have a module export value.
785
+ if ( prefix in defined && ! defined [ prefix ] ) {
786
+ delete defined [ prefix ] ;
787
+ delete urlFetched [ prefixMap . url ] ;
788
+ }
789
+
790
+ pluginManager = getManager ( prefixMap , true ) ;
772
791
pluginManager . add ( function ( plugin ) {
773
792
//Create a new manager for the normalized
774
793
//resource ID and have it call this manager when
@@ -1839,7 +1858,8 @@ var requirejs, require, define;
1839
1858
node = context && context . config && context . config . xhtml ?
1840
1859
document . createElementNS ( "http://www.w3.org/1999/xhtml" , "html:script" ) :
1841
1860
document . createElement ( "script" ) ;
1842
- node . type = type || "text/javascript" ;
1861
+ node . type = type || ( context && context . config . scriptType ) ||
1862
+ "text/javascript" ;
1843
1863
node . charset = "utf-8" ;
1844
1864
//Use async so Gecko does not block on executing the script if something
1845
1865
//like a long-polling comet tag is being run first. Gecko likes
@@ -7669,7 +7689,7 @@ function (lang, logger, envOptimize, file, parse,
7669
7689
logger . trace ( "Uglifying file: " + fileName ) ;
7670
7690
7671
7691
try {
7672
- ast = parser . parse ( fileContents , config ) ;
7692
+ ast = parser . parse ( fileContents , config . strict_semicolons ) ;
7673
7693
ast = processor . ast_mangle ( ast , config ) ;
7674
7694
ast = processor . ast_squeeze ( ast , config ) ;
7675
7695
@@ -7852,8 +7872,13 @@ function (file, pragma, parse) {
7852
7872
//and to make sure this file is first, so that define calls work.
7853
7873
//This situation mainly occurs when the build is done on top of the output
7854
7874
//of another build, where the first build may include require somewhere in it.
7855
- if ( ! layer . existingRequireUrl && parse . definesRequire ( url , contents ) ) {
7856
- layer . existingRequireUrl = url ;
7875
+ try {
7876
+ if ( ! layer . existingRequireUrl && parse . definesRequire ( url , contents ) ) {
7877
+ layer . existingRequireUrl = url ;
7878
+ }
7879
+ } catch ( e1 ) {
7880
+ throw new Error ( 'Parse error using UglifyJS ' +
7881
+ 'for file: ' + url + '\n' + e1 ) ;
7857
7882
}
7858
7883
7859
7884
if ( moduleName in context . plugins ) {
@@ -7870,12 +7895,17 @@ function (file, pragma, parse) {
7870
7895
//Parse out the require and define calls.
7871
7896
//Do this even for plugins in case they have their own
7872
7897
//dependencies that may be separate to how the pluginBuilder works.
7873
- if ( ! context . needFullExec [ moduleName ] ) {
7874
- contents = parse ( moduleName , url , contents , {
7875
- insertNeedsDefine : true ,
7876
- has : context . config . has ,
7877
- findNestedDependencies : context . config . findNestedDependencies
7878
- } ) ;
7898
+ try {
7899
+ if ( ! context . needFullExec [ moduleName ] ) {
7900
+ contents = parse ( moduleName , url , contents , {
7901
+ insertNeedsDefine : true ,
7902
+ has : context . config . has ,
7903
+ findNestedDependencies : context . config . findNestedDependencies
7904
+ } ) ;
7905
+ }
7906
+ } catch ( e2 ) {
7907
+ throw new Error ( 'Parse error using UglifyJS ' +
7908
+ 'for file: ' + url + '\n' + e2 ) ;
7879
7909
}
7880
7910
7881
7911
require . _cachedFileContents [ url ] = contents ;
@@ -7939,8 +7969,8 @@ function (file, pragma, parse) {
7939
7969
} else if ( map . url && require . _isSupportedBuildUrl ( map . url ) ) {
7940
7970
//If the url has not been added to the layer yet, and it
7941
7971
//is from an actual file that was loaded, add it now.
7972
+ url = normalizeUrlWithBase ( context , map . fullName , map . url ) ;
7942
7973
if ( ! layer . pathAdded [ url ] && layer . buildPathMap [ fullName ] ) {
7943
- url = normalizeUrlWithBase ( context , map . fullName , map . url ) ;
7944
7974
//Remember the list of dependencies for this layer.
7945
7975
layer . buildFilePaths . push ( url ) ;
7946
7976
layer . pathAdded [ url ] = true ;
@@ -8697,6 +8727,10 @@ function (lang, logger, file, parse, optimize, pragma,
8697
8727
throw new Error ( "ERROR: 'baseUrl' option missing." ) ;
8698
8728
}
8699
8729
8730
+ if ( ! config . out && ! config . dir ) {
8731
+ throw new Error ( 'Missing either an "out" or "dir" config value.' ) ;
8732
+ }
8733
+
8700
8734
if ( config . out && ! config . cssIn ) {
8701
8735
//Just one file to optimize.
8702
8736
0 commit comments