sprockets-commoner 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee42f65a12ad9e9a4b5dedb998af38e8fcdd2f4d
4
- data.tar.gz: 020f3d0f782c8a1fcc6afd382a5162e667328e32
3
+ metadata.gz: 0e07853296174bca18616b5f0a8021b4830b33de
4
+ data.tar.gz: f3a207b0a0b047889f21c1d75d5a3f1b2d491822
5
5
  SHA512:
6
- metadata.gz: 180123fc5d46f1bb21f9a60938e42fb8fd2d2662087e5473a53a6c13f276068825d4a2c8c34f05e5b4247f2f3844801e91afaab020b85df9afb328d957930f06
7
- data.tar.gz: 2c3938f74a7664b7c1b78aedeb76036b960ed3eb82650af95b9183a943e7a1fd2d5c29ec86787a337291bc70fbbdee265c932dc7fa41e9203ceeff02b16b0688
6
+ metadata.gz: 081005224d924d04f646d027e6c618efc591bc157533f21b805ff48ec85ec7ccc199ffe4aaa4561d12fed8ab22ecaa067758b8f343d18ef75f864e4531a44a47
7
+ data.tar.gz: 1d24a89e58c518190f34c6192c3a132d7f53235d533b518080afcbb02cef51afa1acf3a300c5f2964acbeddff95683d2d2ee37b8a2be0dd6a208cf632ba4e84d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.2
4
+
5
+ * Don't cache Babel output as this can lead to bugs.
6
+ * Avoid imports of files that won't be processed by Commoner, to defend against bugs.
7
+ * Exclude vendor/bundle by default.
8
+
3
9
  ## v0.2.1
4
10
 
5
11
  * Fix bug with `browser` field stubbing out modules.
@@ -9,6 +15,14 @@
9
15
 
10
16
  * Add support for requiring JSON files.
11
17
 
18
+ ## v0.1.2
19
+
20
+ * Backport fixes from v0.2.2
21
+
22
+ ## v0.1.1
23
+
24
+ * Backport fixes from v0.2.1.
25
+
12
26
  ## v0.1.0
13
27
 
14
28
  * Initial version.
data/README.md CHANGED
@@ -61,8 +61,8 @@ Rails.application.config.assets.configure do |env|
61
61
  # include, exclude, and babel_exclude patterns can be path prefixes or regexes.
62
62
  # Explicitely list paths to include. The default is `[env.root]`
63
63
  include: ['app/assets/javascripts/subdirectory'],
64
- # List files to ignore and not process require calls or apply any Babel transforms to. Default is empty.
65
- exclude: [/ignored/],
64
+ # List files to ignore and not process require calls or apply any Babel transforms to. Default is ['vendor/bundle'].
65
+ exclude: ['vendor/bundle', /ignored/],
66
66
  # Anything listed in babel_exclude has its require calls resolved, but no transforms listed in .babelrcs applied.
67
67
  # Default is [/node_modules/]
68
68
  babel_exclude: [/node_modules/]
data/bin/console ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'sprockets'
5
+ require 'sprockets/commoner'
6
+
7
+ require 'pry'
8
+
9
+ Pry.start
@@ -4,10 +4,14 @@ require 'open3'
4
4
  module Sprockets
5
5
  module Commoner
6
6
  class Processor < Schmooze::Base
7
+
8
+ ExcludedFileError = Class.new(::StandardError)
9
+
7
10
  BABELRC_FILE = '.babelrc'.freeze
8
11
  PACKAGE_JSON = 'package.json'.freeze
9
12
  JS_PACKAGE_PATH = File.expand_path('../../../js', __dir__)
10
13
  ALLOWED_EXTENSIONS = /\.js(?:on)?(?:\.erb)?\z/
14
+ COFFEE_EXTENSION = /\.coffee(:?\.erb)?\z/
11
15
 
12
16
  dependencies babel: 'babel-core', commoner: 'babel-plugin-sprockets-commoner-internal'
13
17
 
@@ -44,7 +48,7 @@ module Sprockets
44
48
  end
45
49
 
46
50
  attr_reader :include, :exclude, :babel_exclude
47
- def initialize(root, include: [root], exclude: [], babel_exclude: [/node_modules/])
51
+ def initialize(root, include: [root], exclude: ['vendor/bundle'], babel_exclude: [/node_modules/])
48
52
  @include = include.map {|path| expand_to_root(path, root) }
49
53
  @exclude = exclude.map {|path| expand_to_root(path, root) }
50
54
  @babel_exclude = babel_exclude.map {|path| expand_to_root(path, root) }
@@ -52,12 +56,6 @@ module Sprockets
52
56
  end
53
57
 
54
58
  def call(input)
55
- @cache_key ||= [
56
- self.class.name,
57
- version,
58
- VERSION,
59
- ].freeze
60
-
61
59
  filename = input[:filename]
62
60
 
63
61
  return unless should_process?(filename)
@@ -70,12 +68,13 @@ module Sprockets
70
68
 
71
69
  babel_config = babelrc_data(filename)
72
70
 
73
- result = input[:cache].fetch([filename, @cache_key, input[:data], babel_config]) do
74
- transform(input[:data], options(input), paths: @env.paths)
75
- end
71
+ result = transform(input[:data], options(input), paths: @env.paths)
76
72
 
77
73
  if result['metadata'].has_key?('required')
78
74
  result['metadata']['required'].each do |r|
75
+ unless COFFEE_EXTENSION =~ r || should_process?(r)
76
+ raise ExcludedFileError, "#{r} was imported from #{filename} but this file won't be processed by Sprockets::Commoner"
77
+ end
79
78
  asset = resolve(r, accept: input[:content_type], pipeline: :self)
80
79
  @required.insert(insertion_index, asset)
81
80
  end
@@ -1,5 +1,5 @@
1
1
  module Sprockets
2
2
  module Commoner
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
  spec.add_dependency "sprockets", ">= 3", "< 4"
30
- spec.add_dependency "schmooze", "~> 0.1.5"
30
+ spec.add_dependency "schmooze", "~> 0.1.6"
31
31
 
32
32
  spec.add_development_dependency "rake", "~> 10.0"
33
33
  spec.add_development_dependency "minitest", "~> 5.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprockets-commoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-06 00:00:00.000000000 Z
11
+ date: 2016-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.1.5
39
+ version: 0.1.6
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.1.5
46
+ version: 0.1.6
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +130,7 @@ files:
130
130
  - LICENSE.txt
131
131
  - README.md
132
132
  - Rakefile
133
+ - bin/console
133
134
  - circle.yml
134
135
  - js/babel-plugin-sprockets-commoner-internal/.gitignore
135
136
  - js/babel-plugin-sprockets-commoner-internal/README.md