requirejs-rails 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # v0.5.3
2
+
3
+ - Upgrade to RequireJS and r.js 1.0.4
4
+ - Pulled #22, fix for asset compliation failure with no config/requirejs.yml.
5
+ Thanks @arehberg!
6
+
7
+ # v0.5.2
8
+
9
+ - Upgrade to RequireJS and r.js 1.0.3
10
+
1
11
  # v0.5.1
2
12
 
3
13
  - This is a quick turn to fix an issue that could trigger an Anonymous mismatched define() error from require.js and/or r.js.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- requirejs-rails (0.5.2)
4
+ requirejs-rails (0.5.3)
5
5
  railties (~> 3.1.1)
6
6
 
7
7
  GEM
data/bin/r.js CHANGED
@@ -1,5 +1,5 @@
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 = /\.js$/,
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 = /require\(\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
 
@@ -32,7 +32,7 @@ module Requirejs::Rails
32
32
 
33
33
  self.run_config = {
34
34
  "baseUrl" => "/assets",
35
- "modules" => [ { name: 'application' } ]
35
+ "modules" => [ { 'name' => 'application' } ]
36
36
  }
37
37
  self.run_config.merge!(self.user_config)
38
38
  self.run_config_json = self.run_config.to_json
@@ -44,9 +44,9 @@ module Requirejs::Rails
44
44
  def module_path_for(name)
45
45
  self.target_dir+(name+'.js')
46
46
  end
47
-
47
+
48
48
  def get_binding
49
49
  return binding()
50
- end
50
+ end
51
51
  end
52
- end
52
+ end
@@ -1,5 +1,5 @@
1
1
  module Requirejs
2
2
  module Rails
3
- VERSION = "0.5.2"
3
+ VERSION = "0.5.3"
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@ class RequirejsRailsTest < ActiveSupport::TestCase
13
13
  test "require.js version" do
14
14
  require_js = Pathname.new(__FILE__+'/../../vendor/assets/javascripts/require.js').cleanpath.read
15
15
  context = ExecJS.compile(require_js)
16
- assert_equal "1.0.3", context.eval("require.version")
16
+ assert_equal "1.0.4", context.eval("require.version")
17
17
  end
18
18
  end
19
19
 
@@ -1,5 +1,5 @@
1
1
  /** vim: et:ts=4:sw=4:sts=4
2
- * @license RequireJS 1.0.3 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
2
+ * @license RequireJS 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
  */
@@ -11,7 +11,7 @@
11
11
  var requirejs, require, define;
12
12
  (function () {
13
13
  //Change this version number for each release.
14
- var version = "1.0.3",
14
+ var version = "1.0.4",
15
15
  commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
16
16
  cjsRequireRegExp = /require\(\s*["']([^'"\s]+)["']\s*\)/g,
17
17
  currDirRegExp = /^\.\//,
@@ -323,7 +323,15 @@ var requirejs, require, define;
323
323
  url = urlMap[normalizedName];
324
324
  if (!url) {
325
325
  //Calculate url for the module, if it has a name.
326
- url = context.nameToUrl(normalizedName, null, parentModuleMap);
326
+ //Use name here since nameToUrl also calls normalize,
327
+ //and for relative names that are outside the baseUrl
328
+ //this causes havoc. Was thinking of just removing
329
+ //parentModuleMap to avoid extra normalization, but
330
+ //normalize() still does a dot removal because of
331
+ //issue #142, so just pass in name here and redo
332
+ //the normalization. Paths outside baseUrl are just
333
+ //messy to support.
334
+ url = context.nameToUrl(name, null, parentModuleMap);
327
335
 
328
336
  //Store the URL mapping for later.
329
337
  urlMap[normalizedName] = url;
@@ -628,7 +636,7 @@ var requirejs, require, define;
628
636
  prefix = map.prefix,
629
637
  plugin = prefix ? plugins[prefix] ||
630
638
  (plugins[prefix] = defined[prefix]) : null,
631
- manager, created, pluginManager;
639
+ manager, created, pluginManager, prefixMap;
632
640
 
633
641
  if (fullName) {
634
642
  manager = managerCallbacks[fullName];
@@ -666,7 +674,18 @@ var requirejs, require, define;
666
674
  //If there is a plugin needed, but it is not loaded,
667
675
  //first load the plugin, then continue on.
668
676
  if (prefix && !plugin) {
669
- pluginManager = getManager(makeModuleMap(prefix), true);
677
+ prefixMap = makeModuleMap(prefix);
678
+
679
+ //Clear out defined and urlFetched if the plugin was previously
680
+ //loaded/defined, but not as full module (as in a build
681
+ //situation). However, only do this work if the plugin is in
682
+ //defined but does not have a module export value.
683
+ if (prefix in defined && !defined[prefix]) {
684
+ delete defined[prefix];
685
+ delete urlFetched[prefixMap.url];
686
+ }
687
+
688
+ pluginManager = getManager(prefixMap, true);
670
689
  pluginManager.add(function (plugin) {
671
690
  //Create a new manager for the normalized
672
691
  //resource ID and have it call this manager when
@@ -1737,7 +1756,8 @@ var requirejs, require, define;
1737
1756
  node = context && context.config && context.config.xhtml ?
1738
1757
  document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") :
1739
1758
  document.createElement("script");
1740
- node.type = type || "text/javascript";
1759
+ node.type = type || (context && context.config.scriptType) ||
1760
+ "text/javascript";
1741
1761
  node.charset = "utf-8";
1742
1762
  //Use async so Gecko does not block on executing the script if something
1743
1763
  //like a long-polling comet tag is being run first. Gecko likes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: requirejs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-24 00:00:00.000000000 Z
12
+ date: 2012-01-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70284287973680 !ruby/object:Gem::Requirement
16
+ requirement: &70255892536860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70284287973680
24
+ version_requirements: *70255892536860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70284287973100 !ruby/object:Gem::Requirement
27
+ requirement: &70255892536240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70284287973100
35
+ version_requirements: *70255892536240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &70284287972560 !ruby/object:Gem::Requirement
38
+ requirement: &70255892535640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70284287972560
46
+ version_requirements: *70255892535640
47
47
  description: This gem provides RequireJS support for your Rails 3 application.
48
48
  email:
49
49
  - whitley@bangpath.org
@@ -122,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  segments:
124
124
  - 0
125
- hash: -2856611743431953633
125
+ hash: 4295797509367259253
126
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  segments:
133
133
  - 0
134
- hash: -2856611743431953633
134
+ hash: 4295797509367259253
135
135
  requirements:
136
136
  - node.js is required for 'rake assets:precompile', used to run the r.js build
137
137
  - If needed, jQuery should be v1.7 or greater (jquery-rails >= 1.0.17).