lib/sewing_kit/webpack/manifest/base.rb in sewing_kit-0.32.0.pre.beta.pre.4 vs lib/sewing_kit/webpack/manifest/base.rb in sewing_kit-0.91.0
- old
+ new
@@ -7,25 +7,33 @@
class Base
def initialize
@metadata = nil
end
- # :nodoc:
- def asset_dependencies(entrypoint_name)
- current_metadata = metadata
- if current_metadata.key?('development')
- current_metadata['development']['hangTight']
- else
- current_metadata['entrypoints'][entrypoint_name]
- end
- end
-
def clear_cache!
@metadata = nil
end
def manifest
- metadata['assets']
+ current_metadata = metadata
+
+ if current_metadata.is_a?(Array)
+ all_assets = current_metadata.flat_map do |data|
+ data['assets']['all'].values
+ end
+
+ # sewing-kit asset manifests return a numerically indexed hash, not a true array,
+ # so we need to change it back to a hash for compatibility
+ asset_hash = all_assets.each_with_index
+ .collect { |asset, index| [index, asset] }
+ .to_h
+
+ {
+ "all" => asset_hash,
+ }
+ else
+ current_metadata['assets']
+ end
end
def self.load_metadata_from_node
begin
stdout, stderr, status = Open3.capture3('node_modules/.bin/sewing-kit', 'manifest', "--mode=#{mode}")