Skip to content

Commit

Permalink
More tweaking; reordering code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Jolley committed Jan 17, 2010
1 parent a5a2126 commit 8c58606
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 40 deletions.
5 changes: 2 additions & 3 deletions Buildfile
Expand Up @@ -75,9 +75,8 @@ mode :all do
:theme => 'sproutcore/standard_theme',

# use default bootstrap framework
:bootstrap_inline => 'sproutcore/bootstrap:javascript',
:bootstrap_env => true, # include an ENV global variable
:build_platform => :classic,
:bootstrap_inline => 'sproutcore/bootstrap:javascript',
:bootstrap_env => true, # include an ENV global variable

:use_packed => true,

Expand Down
32 changes: 15 additions & 17 deletions buildtasks/manifest.rake
Expand Up @@ -306,36 +306,34 @@ namespace :manifest do
# sort entries
pf = (entry_name == 'javascript.js') ? %w(source/lproj/strings.js source/core.js source/utils.js) : []

# if we're using modules, then add a generated entries module as well
has_exports = !!entries.find { |e| e.module_name == 'index' }

if CONFIG.use_modules && !has_exports && !!((entries.size == 0) || (entries.find { |e| e.use_modules }))
package_exports = MANIFEST.add_entry 'package_exports.js',
:build_task => 'build:package_exports',
# add a bundle_info.js if needed
if CONFIG.use_loader && ((entries.size == 0) || (entries.find { |e| e.use_loader }))
package_info = MANIFEST.add_entry 'package_info.js',
:build_task => 'build:package_info',
:resource => resource_name,
:entry_type => :javascript,
:source_entries => entries.dup,
:module_name => 'index',
:composite => true
entries << package_exports

entries << package_info
end
# add a package_info.js if the loader is enabled for this package
package_info = nil
if CONFIG.use_loader
package_info = MANIFEST.add_entry 'package_info.js',
:build_task => 'build:package_info',

# if we're using modules, then add a generated entries module as well
has_exports = !!entries.find { |e| e.module_name == 'package' }
if CONFIG.use_modules && !has_exports && ((entries.size == 0) || (entries.find { |e| e.use_modules }))
package_exports = MANIFEST.add_entry 'package_exports.js',
:build_task => 'build:package_exports',
:resource => resource_name,
:entry_type => :javascript,
:source_entries => entries.dup,
:composite => true

entries << package_info
entries << package_exports
end

ordered_entries = SC::Helpers::EntrySorter.sort(entries, pf)

composite_entry = MANIFEST.add_composite entry_name,
MANIFEST.add_composite entry_name,
:build_task => 'build:combine',
:source_entries => entries,
:top_level_lazy_instantiation => CONFIG.lazy_instantiation,
Expand Down
4 changes: 2 additions & 2 deletions lib/sproutcore/builders/package.rb
Expand Up @@ -56,7 +56,7 @@ def build(dst_path)
has_main = false

lines = []
lines << "#{loader_name}.module('#{package_name}:index', function(require, exports, module) {\n"
lines << "#{loader_name}.module('#{package_name}:package', function(require, exports, module) {\n"
lines << "var m;\n"
entries.each do |e|
next if e.package_exports.nil?
Expand All @@ -78,7 +78,7 @@ def build(dst_path)
# if this is a loadable target (i.e. an app), and a main() is defined,
# then try to call it automatically when the package becomes ready.
if entry.target.loadable?
lines << "\n#{loader_name}.main('#{package_name}', 'main');\n\n"
lines << "\n#{loader_name}.async('#{package_name}').then(function() {\n #{loader_name}.require('#{package_name}:package').main();\n});\n\n"
end


Expand Down
2 changes: 1 addition & 1 deletion lib/sproutcore/helpers/static_helper.rb
Expand Up @@ -147,7 +147,7 @@ def bootstrap
if target.config.bootstrap_env
env = {
'mode' => SC.env.build_mode,
'platform' => target.config.build_platform
'platform' => 'browser' # make an option later
}.to_json
ret << %(<script type="text/javascript">\nENV = #{env};\n</script>)
end
Expand Down
21 changes: 4 additions & 17 deletions lib/sproutcore/models/manifest.rb
Expand Up @@ -375,23 +375,10 @@ def bundle_info(opts ={})
# get scripts
if opts[:scripts].nil? || opts[:scripts]
should_combine = target.config.combine_javascript

scripts = nil
scripts = package_info_entry.ordered_entries if package_info_entry

# backup method
if scripts.nil?
e = entry_for('javascript.js') || entry_for('javascript.js', :hidden => true)
scripts = e.nil? ? [] : (should_combine ? [e] : e.ordered_entries)
scripts ||= []
end

scripts = scripts.compact.select do |e|
(e.filename == 'package_info.js') ||
(e.filename == 'package_exports.js') ||
e.use_loader
end

e = entry_for('javascript.js') || entry_for('javascript.js', :hidden => true)
scripts = e.nil? ? [] : (should_combine ? [e] : e.ordered_entries)
scripts ||= []
scripts = scripts.compact.select { |e| e.use_loader }
scripts = scripts.map { |e|
{ 'id' => e.script_id, 'url' => e.cacheable_url }
}.compact
Expand Down
10 changes: 10 additions & 0 deletions lib/sproutcore/models/manifest_entry.rb
Expand Up @@ -159,6 +159,16 @@ def hyperdomain_prefix(url)
end


# Returns a unique ID representing this item when loaded as a script.
# Useful for module loading. Includes the build number, target name,
# language, and filename
def script_id
ret = [manifest.language, target.build_number, self.filename].join('/')
ret = [target.target_name.to_s[1..-1], ret].join(':')
ret = [ret, self.timestamp].join('?') if target.config.timestamp_urls
return ret
end

# Returns a unique ID representing this item when loaded as a script.
# Useful for module loading. Includes the build number, target name,
# language, and filename
Expand Down

0 comments on commit 8c58606

Please sign in to comment.