requirejs-rails 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -2
- data/app/helpers/requirejs_helper.rb +29 -35
- data/bin/r.js +13983 -14144
- data/lib/requirejs/rails/config.rb +2 -0
- data/lib/requirejs/rails/engine.rb +25 -4
- data/lib/requirejs/rails/rjs_driver.js.erb +12 -1
- data/lib/requirejs/rails/version.rb +1 -1
- data/lib/requirejs/rails/view.rb +9 -0
- data/lib/tasks/requirejs-rails_tasks.rake +2 -14
- data/vendor/assets/javascripts/almond.js +62 -58
- data/vendor/assets/javascripts/require.js +65 -49
- metadata +4 -4
- data/lib/requirejs/rails/view_proxy.rb +0 -14
@@ -16,6 +16,7 @@ module Requirejs
|
|
16
16
|
LOGICAL_PATH_PATTERNS = [
|
17
17
|
Regexp.new("\\.html\\z"),
|
18
18
|
Regexp.new("\\.js\\z"),
|
19
|
+
Regexp.new("\\.es6\\z"),
|
19
20
|
Regexp.new("\\.txt\\z"),
|
20
21
|
BOWER_PATH_PATTERN
|
21
22
|
]
|
@@ -99,6 +100,7 @@ module Requirejs
|
|
99
100
|
uglify2
|
100
101
|
useStrict
|
101
102
|
wrap
|
103
|
+
wrapShim
|
102
104
|
}
|
103
105
|
end
|
104
106
|
|
@@ -36,7 +36,12 @@ module Requirejs
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
manifest_directory = config.assets.manifest
|
39
|
+
manifest_directory = if config.assets.manifest
|
40
|
+
File.basename(config.assets.manifest) =~ /\./ ? File.dirname(config.assets.manifest) : config.assets.manifest
|
41
|
+
else
|
42
|
+
File.join(::Rails.public_path, config.assets.prefix)
|
43
|
+
end
|
44
|
+
|
40
45
|
manifest_path = File.join(manifest_directory, "rjs_manifest.yml")
|
41
46
|
config.requirejs.manifest_path = Pathname.new(manifest_path)
|
42
47
|
end
|
@@ -50,12 +55,28 @@ module Requirejs
|
|
50
55
|
end
|
51
56
|
end
|
52
57
|
|
58
|
+
# Are we running in the precompilation Rake task? If so, we need to adjust certain environmental configuration
|
59
|
+
# values.
|
60
|
+
if defined?(Rake) && Rake.application.top_level_tasks.include?("requirejs:precompile:all")
|
61
|
+
initializer "requirejs.modify_environment_config", after: "load_environment_config", group: :all do |app|
|
62
|
+
app.configure do
|
63
|
+
# If we don't set this to true, sprockets-rails will assign `Rails.application.assets` to `nil`.
|
64
|
+
config.assets.compile = true
|
65
|
+
|
66
|
+
# Don't compress JavaScripts fed into the r.js optimizer.
|
67
|
+
config.assets.js_compressor = false
|
68
|
+
|
69
|
+
# Don't use any cache to retrieve assets.
|
70
|
+
config.assets.cache = nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
53
75
|
if ::Rails::VERSION::MAJOR >= 4
|
54
76
|
config.after_initialize do |app|
|
55
77
|
config = app.config
|
56
|
-
|
57
|
-
|
58
|
-
if config.requirejs.manifest_path.exist? && rails_manifest
|
78
|
+
if config.requirejs.manifest_path.exist?
|
79
|
+
rails_manifest = ::Sprockets::Railtie.build_manifest(app)
|
59
80
|
rjs_digests = YAML.load(ERB.new(File.new(config.requirejs.manifest_path).read).result)
|
60
81
|
rails_manifest.assets.merge!(rjs_digests)
|
61
82
|
ActionView::Base.instance_eval do
|
@@ -4,7 +4,16 @@ cdn_pattern = Regexp.new("\\Ahttps?://")
|
|
4
4
|
|
5
5
|
modifiedHash = build_config.select { |k, _| k != "modules" }
|
6
6
|
pathsHash = modifiedHash["paths"]
|
7
|
-
|
7
|
+
|
8
|
+
case loader
|
9
|
+
when :requirejs
|
10
|
+
modifiedHash['dir'] = build_dir.to_s
|
11
|
+
when :almond
|
12
|
+
almond_module = build_config['modules'][0]
|
13
|
+
modifiedHash.merge!(almond_module)
|
14
|
+
modifiedHash['out'] = build_dir + (module_name_for(almond_module) + '.js')
|
15
|
+
end
|
16
|
+
|
8
17
|
modifiedHash["paths"] = Hash[
|
9
18
|
pathsHash.map do |k, v|
|
10
19
|
[k, v.is_a?(Array) || cdn_pattern.match(v) ? "empty:" : v]
|
@@ -14,10 +23,12 @@ modifiedHash["paths"] = Hash[
|
|
14
23
|
JSON.pretty_generate(modifiedHash)
|
15
24
|
%>;
|
16
25
|
|
26
|
+
<% unless loader == :almond %>
|
17
27
|
baseConfig.modules = [
|
18
28
|
<% build_config["modules"].each do |m| %>
|
19
29
|
<%= JSON.pretty_generate(m) %>,
|
20
30
|
<% end %>
|
21
31
|
];
|
32
|
+
<% end %>
|
22
33
|
|
23
34
|
requirejs.optimize(baseConfig);
|
@@ -88,14 +88,6 @@ OS X Homebrew users can use 'brew install node'.
|
|
88
88
|
"requirejs:clean"] do
|
89
89
|
requirejs.config.source_dir.mkpath
|
90
90
|
|
91
|
-
# Save the original JS compressor and cache, which will be restored later.
|
92
|
-
|
93
|
-
original_js_compressor = requirejs.env.js_compressor
|
94
|
-
requirejs.env.js_compressor = false
|
95
|
-
|
96
|
-
original_cache = requirejs.env.cache
|
97
|
-
requirejs.env.cache = nil
|
98
|
-
|
99
91
|
requirejs.env.each_logical_path(requirejs.config.logical_path_patterns) do |logical_path|
|
100
92
|
m = ::Requirejs::Rails::Config::BOWER_PATH_PATTERN.match(logical_path)
|
101
93
|
|
@@ -118,10 +110,6 @@ OS X Homebrew users can use 'brew install node'.
|
|
118
110
|
end
|
119
111
|
end
|
120
112
|
end
|
121
|
-
|
122
|
-
# Restore the original JS compressor and cache.
|
123
|
-
requirejs.env.js_compressor = original_js_compressor
|
124
|
-
requirejs.env.cache = original_cache
|
125
113
|
end
|
126
114
|
|
127
115
|
task generate_rjs_driver: ["requirejs:setup"] do
|
@@ -162,8 +150,8 @@ OS X Homebrew users can use 'brew install node'.
|
|
162
150
|
built_asset_path = requirejs.config.build_dir.join(asset_name)
|
163
151
|
|
164
152
|
# Compute the digest based on the contents of the compiled file, *not* on the contents of the RequireJS module.
|
165
|
-
file_digest =
|
166
|
-
hex_digest =
|
153
|
+
file_digest = requirejs.env.file_digest(built_asset_path.to_s)
|
154
|
+
hex_digest = file_digest.unpack("H*").first
|
167
155
|
digest_name = asset.logical_path.gsub(path_extension_pattern) { |ext| "-#{hex_digest}#{ext}" }
|
168
156
|
|
169
157
|
digest_asset_path = requirejs.config.target_dir + digest_name
|
@@ -1,11 +1,9 @@
|
|
1
1
|
/**
|
2
|
-
* @license almond 0.3.
|
3
|
-
*
|
4
|
-
* see: http://github.com/jrburke/almond for details
|
2
|
+
* @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
|
3
|
+
* Released under MIT license, http://github.com/requirejs/almond/LICENSE
|
5
4
|
*/
|
6
5
|
//Going sloppy to avoid 'use strict' string cost, but strict practices should
|
7
6
|
//be followed.
|
8
|
-
/*jslint sloppy: true */
|
9
7
|
/*global setTimeout: false */
|
10
8
|
|
11
9
|
var requirejs, require, define;
|
@@ -33,60 +31,58 @@ var requirejs, require, define;
|
|
33
31
|
*/
|
34
32
|
function normalize(name, baseName) {
|
35
33
|
var nameParts, nameSegment, mapValue, foundMap, lastIndex,
|
36
|
-
foundI, foundStarMap, starI, i, j, part,
|
34
|
+
foundI, foundStarMap, starI, i, j, part, normalizedBaseParts,
|
37
35
|
baseParts = baseName && baseName.split("/"),
|
38
36
|
map = config.map,
|
39
37
|
starMap = (map && map['*']) || {};
|
40
38
|
|
41
39
|
//Adjust any relative paths.
|
42
|
-
if (name
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
40
|
+
if (name) {
|
41
|
+
name = name.split('/');
|
42
|
+
lastIndex = name.length - 1;
|
43
|
+
|
44
|
+
// If wanting node ID compatibility, strip .js from end
|
45
|
+
// of IDs. Have to do this here, and not in nameToUrl
|
46
|
+
// because node allows either .js or non .js to map
|
47
|
+
// to same file.
|
48
|
+
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
|
49
|
+
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
|
50
|
+
}
|
54
51
|
|
55
|
-
|
56
|
-
|
57
|
-
//baseName
|
58
|
-
//
|
59
|
-
|
60
|
-
|
61
|
-
//
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
52
|
+
// Starts with a '.' so need the baseName
|
53
|
+
if (name[0].charAt(0) === '.' && baseParts) {
|
54
|
+
//Convert baseName to array, and lop off the last part,
|
55
|
+
//so that . matches that 'directory' and not name of the baseName's
|
56
|
+
//module. For instance, baseName of 'one/two/three', maps to
|
57
|
+
//'one/two/three.js', but we want the directory, 'one/two' for
|
58
|
+
//this normalization.
|
59
|
+
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
|
60
|
+
name = normalizedBaseParts.concat(name);
|
61
|
+
}
|
62
|
+
|
63
|
+
//start trimDots
|
64
|
+
for (i = 0; i < name.length; i++) {
|
65
|
+
part = name[i];
|
66
|
+
if (part === '.') {
|
67
|
+
name.splice(i, 1);
|
68
|
+
i -= 1;
|
69
|
+
} else if (part === '..') {
|
70
|
+
// If at the start, or previous value is still ..,
|
71
|
+
// keep them so that when converted to a path it may
|
72
|
+
// still work when converted to a path, even though
|
73
|
+
// as an ID it is less than ideal. In larger point
|
74
|
+
// releases, may be better to just kick out an error.
|
75
|
+
if (i === 0 || (i === 1 && name[2] === '..') || name[i - 1] === '..') {
|
76
|
+
continue;
|
77
|
+
} else if (i > 0) {
|
78
|
+
name.splice(i - 1, 2);
|
79
|
+
i -= 2;
|
80
80
|
}
|
81
81
|
}
|
82
|
-
//end trimDots
|
83
|
-
|
84
|
-
name = name.join("/");
|
85
|
-
} else if (name.indexOf('./') === 0) {
|
86
|
-
// No baseName, so this is ID is resolved relative
|
87
|
-
// to baseUrl, pull off the leading dot.
|
88
|
-
name = name.substring(2);
|
89
82
|
}
|
83
|
+
//end trimDots
|
84
|
+
|
85
|
+
name = name.join('/');
|
90
86
|
}
|
91
87
|
|
92
88
|
//Apply map config if available.
|
@@ -199,32 +195,39 @@ var requirejs, require, define;
|
|
199
195
|
return [prefix, name];
|
200
196
|
}
|
201
197
|
|
198
|
+
//Creates a parts array for a relName where first part is plugin ID,
|
199
|
+
//second part is resource ID. Assumes relName has already been normalized.
|
200
|
+
function makeRelParts(relName) {
|
201
|
+
return relName ? splitPrefix(relName) : [];
|
202
|
+
}
|
203
|
+
|
202
204
|
/**
|
203
205
|
* Makes a name map, normalizing the name, and using a plugin
|
204
206
|
* for normalization if necessary. Grabs a ref to plugin
|
205
207
|
* too, as an optimization.
|
206
208
|
*/
|
207
|
-
makeMap = function (name,
|
209
|
+
makeMap = function (name, relParts) {
|
208
210
|
var plugin,
|
209
211
|
parts = splitPrefix(name),
|
210
|
-
prefix = parts[0]
|
212
|
+
prefix = parts[0],
|
213
|
+
relResourceName = relParts[1];
|
211
214
|
|
212
215
|
name = parts[1];
|
213
216
|
|
214
217
|
if (prefix) {
|
215
|
-
prefix = normalize(prefix,
|
218
|
+
prefix = normalize(prefix, relResourceName);
|
216
219
|
plugin = callDep(prefix);
|
217
220
|
}
|
218
221
|
|
219
222
|
//Normalize according
|
220
223
|
if (prefix) {
|
221
224
|
if (plugin && plugin.normalize) {
|
222
|
-
name = plugin.normalize(name, makeNormalize(
|
225
|
+
name = plugin.normalize(name, makeNormalize(relResourceName));
|
223
226
|
} else {
|
224
|
-
name = normalize(name,
|
227
|
+
name = normalize(name, relResourceName);
|
225
228
|
}
|
226
229
|
} else {
|
227
|
-
name = normalize(name,
|
230
|
+
name = normalize(name, relResourceName);
|
228
231
|
parts = splitPrefix(name);
|
229
232
|
prefix = parts[0];
|
230
233
|
name = parts[1];
|
@@ -271,13 +274,14 @@ var requirejs, require, define;
|
|
271
274
|
};
|
272
275
|
|
273
276
|
main = function (name, deps, callback, relName) {
|
274
|
-
var cjsModule, depName, ret, map, i,
|
277
|
+
var cjsModule, depName, ret, map, i, relParts,
|
275
278
|
args = [],
|
276
279
|
callbackType = typeof callback,
|
277
280
|
usingExports;
|
278
281
|
|
279
282
|
//Use name if no relName
|
280
283
|
relName = relName || name;
|
284
|
+
relParts = makeRelParts(relName);
|
281
285
|
|
282
286
|
//Call the callback to define the module, if necessary.
|
283
287
|
if (callbackType === 'undefined' || callbackType === 'function') {
|
@@ -286,7 +290,7 @@ var requirejs, require, define;
|
|
286
290
|
//Default to [require, exports, module] if no deps
|
287
291
|
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
|
288
292
|
for (i = 0; i < deps.length; i += 1) {
|
289
|
-
map = makeMap(deps[i],
|
293
|
+
map = makeMap(deps[i], relParts);
|
290
294
|
depName = map.f;
|
291
295
|
|
292
296
|
//Fast path CommonJS standard dependencies.
|
@@ -342,7 +346,7 @@ var requirejs, require, define;
|
|
342
346
|
//deps arg is the module name, and second arg (if passed)
|
343
347
|
//is just the relName.
|
344
348
|
//Normalize module name, if it contains . or ..
|
345
|
-
return callDep(makeMap(deps, callback).f);
|
349
|
+
return callDep(makeMap(deps, makeRelParts(callback)).f);
|
346
350
|
} else if (!deps.splice) {
|
347
351
|
//deps is a config object, not an array.
|
348
352
|
config = deps;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
/** vim: et:ts=4:sw=4:sts=4
|
2
|
-
* @license RequireJS 2.
|
3
|
-
*
|
4
|
-
* see: http://github.com/jrburke/requirejs for details
|
2
|
+
* @license RequireJS 2.3.5 Copyright jQuery Foundation and other contributors.
|
3
|
+
* Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
|
5
4
|
*/
|
6
5
|
//Not using strict: uneven strict support in browsers, #392, and causes
|
7
6
|
//problems with requirejs.exec()/transpiler plugins that may not be strict.
|
@@ -9,18 +8,17 @@
|
|
9
8
|
/*global window, navigator, document, importScripts, setTimeout, opera */
|
10
9
|
|
11
10
|
var requirejs, require, define;
|
12
|
-
(function (global) {
|
11
|
+
(function (global, setTimeout) {
|
13
12
|
var req, s, head, baseElement, dataMain, src,
|
14
13
|
interactiveScript, currentlyAddingScript, mainScript, subPath,
|
15
|
-
version = '2.
|
16
|
-
commentRegExp =
|
14
|
+
version = '2.3.5',
|
15
|
+
commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg,
|
17
16
|
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
|
18
17
|
jsSuffixRegExp = /\.js$/,
|
19
18
|
currDirRegExp = /^\.\//,
|
20
19
|
op = Object.prototype,
|
21
20
|
ostring = op.toString,
|
22
21
|
hasOwn = op.hasOwnProperty,
|
23
|
-
ap = Array.prototype,
|
24
22
|
isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
|
25
23
|
isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
|
26
24
|
//PS3 indicates loaded and complete, but need to wait for complete
|
@@ -37,6 +35,11 @@ var requirejs, require, define;
|
|
37
35
|
globalDefQueue = [],
|
38
36
|
useInteractive = false;
|
39
37
|
|
38
|
+
//Could match something like ')//comment', do not lose the prefix to comment.
|
39
|
+
function commentReplace(match, singlePrefix) {
|
40
|
+
return singlePrefix || '';
|
41
|
+
}
|
42
|
+
|
40
43
|
function isFunction(it) {
|
41
44
|
return ostring.call(it) === '[object Function]';
|
42
45
|
}
|
@@ -437,7 +440,9 @@ var requirejs, require, define;
|
|
437
440
|
//Account for relative paths if there is a base name.
|
438
441
|
if (name) {
|
439
442
|
if (prefix) {
|
440
|
-
if (
|
443
|
+
if (isNormalized) {
|
444
|
+
normalizedName = name;
|
445
|
+
} else if (pluginModule && pluginModule.normalize) {
|
441
446
|
//Plugin is loaded, use its normalize method.
|
442
447
|
normalizedName = pluginModule.normalize(name, function (name) {
|
443
448
|
return normalize(name, parentName, applyMap);
|
@@ -861,10 +866,21 @@ var requirejs, require, define;
|
|
861
866
|
|
862
867
|
if (this.depCount < 1 && !this.defined) {
|
863
868
|
if (isFunction(factory)) {
|
864
|
-
|
869
|
+
//If there is an error listener, favor passing
|
870
|
+
//to that instead of throwing an error. However,
|
871
|
+
//only do it for define()'d modules. require
|
872
|
+
//errbacks should not be called for failures in
|
873
|
+
//their callbacks (#699). However if a global
|
874
|
+
//onError is set, use that.
|
875
|
+
if ((this.events.error && this.map.isDefine) ||
|
876
|
+
req.onError !== defaultOnError) {
|
877
|
+
try {
|
878
|
+
exports = context.execCb(id, factory, depExports, exports);
|
879
|
+
} catch (e) {
|
880
|
+
err = e;
|
881
|
+
}
|
882
|
+
} else {
|
865
883
|
exports = context.execCb(id, factory, depExports, exports);
|
866
|
-
} catch (e) {
|
867
|
-
err = e;
|
868
884
|
}
|
869
885
|
|
870
886
|
// Favor return value over exports. If node/cjs in play,
|
@@ -881,30 +897,12 @@ var requirejs, require, define;
|
|
881
897
|
}
|
882
898
|
|
883
899
|
if (err) {
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
// their callbacks (#699). However if a global
|
889
|
-
// onError is set, use that.
|
890
|
-
if ((this.events.error && this.map.isDefine) ||
|
891
|
-
req.onError !== defaultOnError) {
|
892
|
-
err.requireMap = this.map;
|
893
|
-
err.requireModules = this.map.isDefine ? [this.map.id] : null;
|
894
|
-
err.requireType = this.map.isDefine ? 'define' : 'require';
|
895
|
-
return onError((this.error = err));
|
896
|
-
} else if (typeof console !== 'undefined' &&
|
897
|
-
console.error) {
|
898
|
-
// Log the error for debugging. If promises could be
|
899
|
-
// used, this would be different, but making do.
|
900
|
-
console.error(err);
|
901
|
-
} else {
|
902
|
-
// Do not want to completely lose the error. While this
|
903
|
-
// will mess up processing and lead to similar results
|
904
|
-
// as bug 1440, it at least surfaces the error.
|
905
|
-
req.onError(err);
|
906
|
-
}
|
900
|
+
err.requireMap = this.map;
|
901
|
+
err.requireModules = this.map.isDefine ? [this.map.id] : null;
|
902
|
+
err.requireType = this.map.isDefine ? 'define' : 'require';
|
903
|
+
return onError((this.error = err));
|
907
904
|
}
|
905
|
+
|
908
906
|
} else {
|
909
907
|
//Just a literal value
|
910
908
|
exports = factory;
|
@@ -976,7 +974,8 @@ var requirejs, require, define;
|
|
976
974
|
//prefix and name should already be normalized, no need
|
977
975
|
//for applying map config again either.
|
978
976
|
normalizedMap = makeModuleMap(map.prefix + '!' + name,
|
979
|
-
this.map.parentMap
|
977
|
+
this.map.parentMap,
|
978
|
+
true);
|
980
979
|
on(normalizedMap,
|
981
980
|
'defined', bind(this, function (value) {
|
982
981
|
this.map.normalizedMap = normalizedMap;
|
@@ -1288,6 +1287,14 @@ var requirejs, require, define;
|
|
1288
1287
|
}
|
1289
1288
|
}
|
1290
1289
|
|
1290
|
+
// Convert old style urlArgs string to a function.
|
1291
|
+
if (typeof cfg.urlArgs === 'string') {
|
1292
|
+
var urlArgs = cfg.urlArgs;
|
1293
|
+
cfg.urlArgs = function(id, url) {
|
1294
|
+
return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
|
1295
|
+
};
|
1296
|
+
}
|
1297
|
+
|
1291
1298
|
//Save off the paths since they require special processing,
|
1292
1299
|
//they are additive.
|
1293
1300
|
var shim = config.shim,
|
@@ -1664,13 +1671,12 @@ var requirejs, require, define;
|
|
1664
1671
|
|
1665
1672
|
//Join the path parts together, then figure out if baseUrl is needed.
|
1666
1673
|
url = syms.join('/');
|
1667
|
-
url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
|
1674
|
+
url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'));
|
1668
1675
|
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
|
1669
1676
|
}
|
1670
1677
|
|
1671
|
-
return config.urlArgs
|
1672
|
-
|
1673
|
-
config.urlArgs) : url;
|
1678
|
+
return config.urlArgs && !/^blob\:/.test(url) ?
|
1679
|
+
url + config.urlArgs(moduleName, url) : url;
|
1674
1680
|
},
|
1675
1681
|
|
1676
1682
|
//Delegates to req.load. Broken out as a separate function to
|
@@ -1724,8 +1730,8 @@ var requirejs, require, define;
|
|
1724
1730
|
each(value.depMaps, function(depMap) {
|
1725
1731
|
if (depMap.id === data.id) {
|
1726
1732
|
parents.push(key);
|
1733
|
+
return true;
|
1727
1734
|
}
|
1728
|
-
return true;
|
1729
1735
|
});
|
1730
1736
|
}
|
1731
1737
|
});
|
@@ -1891,9 +1897,6 @@ var requirejs, require, define;
|
|
1891
1897
|
if (isBrowser) {
|
1892
1898
|
//In the browser so use a script tag
|
1893
1899
|
node = req.createNode(config, moduleName, url);
|
1894
|
-
if (config.onNodeCreated) {
|
1895
|
-
config.onNodeCreated(node, config, moduleName, url);
|
1896
|
-
}
|
1897
1900
|
|
1898
1901
|
node.setAttribute('data-requirecontext', context.contextName);
|
1899
1902
|
node.setAttribute('data-requiremodule', moduleName);
|
@@ -1909,11 +1912,11 @@ var requirejs, require, define;
|
|
1909
1912
|
if (node.attachEvent &&
|
1910
1913
|
//Check if node.attachEvent is artificially added by custom script or
|
1911
1914
|
//natively supported by browser
|
1912
|
-
//read https://github.com/
|
1915
|
+
//read https://github.com/requirejs/requirejs/issues/187
|
1913
1916
|
//if we can NOT find [native code] then it must NOT natively supported.
|
1914
1917
|
//in IE8, node.attachEvent does not have toString()
|
1915
1918
|
//Note the test for "[native code" with no closing brace, see:
|
1916
|
-
//https://github.com/
|
1919
|
+
//https://github.com/requirejs/requirejs/issues/273
|
1917
1920
|
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
|
1918
1921
|
!isOpera) {
|
1919
1922
|
//Probably IE. IE (at least 6-8) do not fire
|
@@ -1941,6 +1944,12 @@ var requirejs, require, define;
|
|
1941
1944
|
}
|
1942
1945
|
node.src = url;
|
1943
1946
|
|
1947
|
+
//Calling onNodeCreated after all properties on the node have been
|
1948
|
+
//set, but before it is placed in the DOM.
|
1949
|
+
if (config.onNodeCreated) {
|
1950
|
+
config.onNodeCreated(node, config, moduleName, url);
|
1951
|
+
}
|
1952
|
+
|
1944
1953
|
//For some cache cases in IE 6-8, the script executes before the end
|
1945
1954
|
//of the appendChild execution, so to tie an anonymous define
|
1946
1955
|
//call to the module name (which is stored on the node), hold on
|
@@ -1962,6 +1971,11 @@ var requirejs, require, define;
|
|
1962
1971
|
//are in play, the expectation is that a build has been done so
|
1963
1972
|
//that only one script needs to be loaded anyway. This may need
|
1964
1973
|
//to be reevaluated if other use cases become common.
|
1974
|
+
|
1975
|
+
// Post a task to the event loop to work around a bug in WebKit
|
1976
|
+
// where the worker gets garbage-collected after calling
|
1977
|
+
// importScripts(): https://webkit.org/b/153317
|
1978
|
+
setTimeout(function() {}, 0);
|
1965
1979
|
importScripts(url);
|
1966
1980
|
|
1967
1981
|
//Account for anonymous modules
|
@@ -2007,8 +2021,10 @@ var requirejs, require, define;
|
|
2007
2021
|
//Preserve dataMain in case it is a path (i.e. contains '?')
|
2008
2022
|
mainScript = dataMain;
|
2009
2023
|
|
2010
|
-
//Set final baseUrl if there is not already an explicit one
|
2011
|
-
if
|
2024
|
+
//Set final baseUrl if there is not already an explicit one,
|
2025
|
+
//but only do so if the data-main value is not a loader plugin
|
2026
|
+
//module ID.
|
2027
|
+
if (!cfg.baseUrl && mainScript.indexOf('!') === -1) {
|
2012
2028
|
//Pull off the directory of data-main for use as the
|
2013
2029
|
//baseUrl.
|
2014
2030
|
src = mainScript.split('/');
|
@@ -2069,7 +2085,7 @@ var requirejs, require, define;
|
|
2069
2085
|
if (callback.length) {
|
2070
2086
|
callback
|
2071
2087
|
.toString()
|
2072
|
-
.replace(commentRegExp,
|
2088
|
+
.replace(commentRegExp, commentReplace)
|
2073
2089
|
.replace(cjsRequireRegExp, function (match, dep) {
|
2074
2090
|
deps.push(dep);
|
2075
2091
|
});
|
@@ -2126,4 +2142,4 @@ var requirejs, require, define;
|
|
2126
2142
|
|
2127
2143
|
//Set up with config info.
|
2128
2144
|
req(cfg);
|
2129
|
-
}(this));
|
2145
|
+
}(this, (typeof setTimeout === 'undefined' ? undefined : setTimeout)));
|