requirejs-rails 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/bin/r.js +2026 -448
- data/lib/requirejs/rails/version.rb +2 -2
- data/lib/tasks/requirejs-rails_tasks.rake +18 -12
- data/vendor/assets/javascripts/require.js +16 -9
- metadata +2 -2
@@ -32,6 +32,7 @@ namespace :requirejs do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
requirejs = ActiveSupport::OrderedOptions.new
|
35
|
+
path_extension_pattern = Regexp.new("\\.(\\w+)\\z")
|
35
36
|
|
36
37
|
task clean: ["requirejs:setup"] do
|
37
38
|
FileUtils.remove_entry_secure(requirejs.config.source_dir, true)
|
@@ -71,17 +72,14 @@ OS X Homebrew users can use 'brew install node'.
|
|
71
72
|
end
|
72
73
|
|
73
74
|
namespace :precompile do
|
74
|
-
task all: ["requirejs:precompile:
|
75
|
-
"requirejs:precompile:generate_rjs_driver",
|
76
|
-
"requirejs:precompile:run_rjs",
|
77
|
-
"requirejs:precompile:digestify_and_compress"]
|
75
|
+
task all: ["requirejs:precompile:digestify_and_compress"]
|
78
76
|
|
79
77
|
# Invoke another ruby process if we're called from inside
|
80
78
|
# assets:precompile so we don't clobber the environment
|
81
79
|
#
|
82
80
|
# We depend on test_node here so we'll fail early and hard if node
|
83
81
|
# isn't available.
|
84
|
-
task external
|
82
|
+
task :external do
|
85
83
|
ruby_rake_task "requirejs:precompile:all"
|
86
84
|
end
|
87
85
|
|
@@ -110,7 +108,7 @@ OS X Homebrew users can use 'brew install node'.
|
|
110
108
|
asset.write_to(file)
|
111
109
|
end
|
112
110
|
else
|
113
|
-
bower_logical_path = Pathname.new(logical_path).dirname.
|
111
|
+
bower_logical_path = "#{Pathname.new(logical_path).dirname.to_s}.js"
|
114
112
|
asset = requirejs.env.find_asset(bower_logical_path)
|
115
113
|
|
116
114
|
if asset
|
@@ -131,7 +129,9 @@ OS X Homebrew users can use 'brew install node'.
|
|
131
129
|
end
|
132
130
|
|
133
131
|
task run_rjs: ["requirejs:setup",
|
134
|
-
"requirejs:test_node"
|
132
|
+
"requirejs:test_node",
|
133
|
+
"requirejs:precompile:prepare_source",
|
134
|
+
"requirejs:precompile:generate_rjs_driver"] do
|
135
135
|
requirejs.config.build_dir.mkpath
|
136
136
|
requirejs.config.target_dir.mkpath
|
137
137
|
requirejs.config.driver_path.dirname.mkpath
|
@@ -144,28 +144,34 @@ OS X Homebrew users can use 'brew install node'.
|
|
144
144
|
|
145
145
|
# Copy each built asset, identified by a named module in the
|
146
146
|
# build config, to its Sprockets digestified name.
|
147
|
-
task digestify_and_compress: ["requirejs:
|
147
|
+
task digestify_and_compress: ["requirejs:precompile:run_rjs"] do
|
148
148
|
requirejs.config.build_config["modules"].each do |m|
|
149
149
|
module_name = requirejs.config.module_name_for(m)
|
150
150
|
paths = requirejs.config.build_config["paths"] || {}
|
151
|
+
module_script_name = "#{module_name}.js"
|
151
152
|
|
152
153
|
# Is there a `paths` entry for the module?
|
153
154
|
if !paths[module_name]
|
154
|
-
asset_name =
|
155
|
+
asset_name = module_script_name
|
155
156
|
else
|
156
|
-
asset_name =
|
157
|
+
asset_name = "#{paths[module_name]}.js"
|
157
158
|
end
|
158
159
|
|
159
160
|
asset = requirejs.env.find_asset(asset_name)
|
160
161
|
|
161
162
|
built_asset_path = requirejs.config.build_dir.join(asset_name)
|
162
|
-
|
163
|
+
|
164
|
+
# Compute the digest based on the contents of the compiled file, *not* on the contents of the RequireJS module.
|
165
|
+
file_digest = ::Rails.application.assets.file_digest(built_asset_path)
|
166
|
+
hex_digest = Sprockets::DigestUtils.pack_hexdigest(file_digest)
|
167
|
+
digest_name = asset.logical_path.gsub(path_extension_pattern) { |ext| "-#{hex_digest}#{ext}" }
|
168
|
+
|
163
169
|
digest_asset_path = requirejs.config.target_dir + digest_name
|
164
170
|
|
165
171
|
# Ensure that the parent directory `a/b` for modules with names like `a/b/c` exist.
|
166
172
|
digest_asset_path.dirname.mkpath
|
167
173
|
|
168
|
-
requirejs.manifest[
|
174
|
+
requirejs.manifest[module_script_name] = digest_name
|
169
175
|
FileUtils.cp built_asset_path, digest_asset_path
|
170
176
|
|
171
177
|
# Create the compressed versions
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/** vim: et:ts=4:sw=4:sts=4
|
2
|
-
* @license RequireJS 2.1.
|
2
|
+
* @license RequireJS 2.1.19 Copyright (c) 2010-2015, 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
|
*/
|
@@ -12,7 +12,7 @@ var requirejs, require, define;
|
|
12
12
|
(function (global) {
|
13
13
|
var req, s, head, baseElement, dataMain, src,
|
14
14
|
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
15
|
-
version = '2.1.
|
15
|
+
version = '2.1.19',
|
16
16
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
|
17
17
|
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
18
18
|
jsSuffixRegExp = /\.js$/,
|
@@ -589,7 +589,7 @@ var requirejs, require, define;
|
|
589
589
|
id: mod.map.id,
|
590
590
|
uri: mod.map.url,
|
591
591
|
config: function () {
|
592
|
-
return
|
592
|
+
return getOwn(config.config, mod.map.id) || {};
|
593
593
|
},
|
594
594
|
exports: mod.exports || (mod.exports = {})
|
595
595
|
});
|
@@ -1117,6 +1117,9 @@ var requirejs, require, define;
|
|
1117
1117
|
this.depCount += 1;
|
1118
1118
|
|
1119
1119
|
on(depMap, 'defined', bind(this, function (depExports) {
|
1120
|
+
if (this.undefed) {
|
1121
|
+
return;
|
1122
|
+
}
|
1120
1123
|
this.defineDep(i, depExports);
|
1121
1124
|
this.check();
|
1122
1125
|
}));
|
@@ -1233,7 +1236,8 @@ var requirejs, require, define;
|
|
1233
1236
|
while (defQueue.length) {
|
1234
1237
|
args = defQueue.shift();
|
1235
1238
|
if (args[0] === null) {
|
1236
|
-
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
|
1239
|
+
return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' +
|
1240
|
+
args[args.length - 1]));
|
1237
1241
|
} else {
|
1238
1242
|
//args are id, deps, factory. Should be normalized by the
|
1239
1243
|
//define() function.
|
@@ -1320,7 +1324,7 @@ var requirejs, require, define;
|
|
1320
1324
|
each(cfg.packages, function (pkgObj) {
|
1321
1325
|
var location, name;
|
1322
1326
|
|
1323
|
-
pkgObj = typeof pkgObj === 'string' ? {
|
1327
|
+
pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
|
1324
1328
|
|
1325
1329
|
name = pkgObj.name;
|
1326
1330
|
location = pkgObj.location;
|
@@ -1347,7 +1351,7 @@ var requirejs, require, define;
|
|
1347
1351
|
//late to modify them, and ignore unnormalized ones
|
1348
1352
|
//since they are transient.
|
1349
1353
|
if (!mod.inited && !mod.map.unnormalized) {
|
1350
|
-
mod.map = makeModuleMap(id);
|
1354
|
+
mod.map = makeModuleMap(id, null, true);
|
1351
1355
|
}
|
1352
1356
|
});
|
1353
1357
|
|
@@ -1483,6 +1487,7 @@ var requirejs, require, define;
|
|
1483
1487
|
var map = makeModuleMap(id, relMap, true),
|
1484
1488
|
mod = getOwn(registry, id);
|
1485
1489
|
|
1490
|
+
mod.undefed = true;
|
1486
1491
|
removeScript(id);
|
1487
1492
|
|
1488
1493
|
delete defined[id];
|
@@ -1493,7 +1498,7 @@ var requirejs, require, define;
|
|
1493
1498
|
//in array so that the splices do not
|
1494
1499
|
//mess up the iteration.
|
1495
1500
|
eachReverse(defQueue, function(args, i) {
|
1496
|
-
if(args[0] === id) {
|
1501
|
+
if (args[0] === id) {
|
1497
1502
|
defQueue.splice(i, 1);
|
1498
1503
|
}
|
1499
1504
|
});
|
@@ -1852,6 +1857,9 @@ var requirejs, require, define;
|
|
1852
1857
|
if (isBrowser) {
|
1853
1858
|
//In the browser so use a script tag
|
1854
1859
|
node = req.createNode(config, moduleName, url);
|
1860
|
+
if (config.onNodeCreated) {
|
1861
|
+
config.onNodeCreated(node, config, moduleName, url);
|
1862
|
+
}
|
1855
1863
|
|
1856
1864
|
node.setAttribute('data-requirecontext', context.contextName);
|
1857
1865
|
node.setAttribute('data-requiremodule', moduleName);
|
@@ -1980,7 +1988,7 @@ var requirejs, require, define;
|
|
1980
1988
|
//like a module name.
|
1981
1989
|
mainScript = mainScript.replace(jsSuffixRegExp, '');
|
1982
1990
|
|
1983
|
-
|
1991
|
+
//If mainScript is still a path, fall back to dataMain
|
1984
1992
|
if (req.jsExtRegExp.test(mainScript)) {
|
1985
1993
|
mainScript = dataMain;
|
1986
1994
|
}
|
@@ -2066,7 +2074,6 @@ var requirejs, require, define;
|
|
2066
2074
|
jQuery: true
|
2067
2075
|
};
|
2068
2076
|
|
2069
|
-
|
2070
2077
|
/**
|
2071
2078
|
* Executes the text. Normally just uses eval, but can be modified
|
2072
2079
|
* to use a better, environment-specific call. Only used for transpiling
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: requirejs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Whitley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|