browserify-rails 0.9.3 → 1.0.0b
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 +3 -0
- data/README.md +0 -1
- data/browserify-rails.gemspec +5 -3
- data/lib/browserify-rails/browserify_processor.rb +8 -4
- data/lib/browserify-rails/railtie.rb +2 -0
- data/lib/browserify-rails/version.rb +1 -1
- data/test/browserify_processor_test.rb +16 -12
- data/test/compilation_test.rb +54 -32
- data/test/dummy/config/application.rb +2 -0
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +3 -1
- data/test/dummy/config/environments/test.rb +6 -3
- data/test/test_helper.rb +1 -0
- metadata +34 -15
- data/.travis.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c8103ff1e727b4eee4db86c1ae36f900e548d20
|
4
|
+
data.tar.gz: d2653f2f4c937bee245287349e9fa9f90bf03649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec483f2f43910396a4540b14097cecbf698fe01234205e2154aa60782dea6778e5e4beecce3c3579ae725f9a7ae5529ce5d5bb85f666004f8c13c47d253f8ce
|
7
|
+
data.tar.gz: e966c041ea4b9eb93feeaf5ebb66ef81b81064db1f1635787d0c5f9fa50b9cb1aafeffa6648584dd0f242f826387c75f0b67b3c5c3ae86ec52e4b3d1587febfe
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file going forward.
|
3
3
|
|
4
|
+
## [1.0.0b] - 2015-06-03
|
5
|
+
- update dependencies to be compatible with sass-rails and more...
|
6
|
+
|
4
7
|
## [0.9.3] - 2015-06-03
|
5
8
|
- allow parentheses in path names
|
6
9
|
- support for piping output through Exorcist to extract sourcemaps
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# browserify-rails
|
2
2
|
|
3
3
|
[](https://gitter.im/browserify-rails/browserify-rails?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
-
[](https://travis-ci.org/browserify-rails/browserify-rails)
|
5
4
|
[](http://badge.fury.io/rb/browserify-rails)
|
6
5
|
|
7
6
|
This library adds CommonJS module support to Sprockets (via Browserify).
|
data/browserify-rails.gemspec
CHANGED
@@ -18,13 +18,15 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "sprockets", "~> 2.2"
|
22
21
|
|
23
|
-
spec.
|
22
|
+
spec.add_runtime_dependency "railties", ">= 4.0.0", "< 5.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", ">= 1.3"
|
24
25
|
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rails"
|
26
|
+
spec.add_development_dependency "rails"
|
26
27
|
spec.add_development_dependency "coffee-rails"
|
27
28
|
spec.add_development_dependency "mocha"
|
28
29
|
spec.add_development_dependency "pry"
|
29
30
|
spec.add_development_dependency "test-unit"
|
31
|
+
spec.add_development_dependency "tilt"
|
30
32
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "tilt"
|
1
2
|
require "open3"
|
2
3
|
require "fileutils"
|
3
4
|
require "tempfile"
|
@@ -5,6 +6,13 @@ require "shellwords"
|
|
5
6
|
|
6
7
|
module BrowserifyRails
|
7
8
|
class BrowserifyProcessor < Tilt::Template
|
9
|
+
attr_accessor :config
|
10
|
+
|
11
|
+
def initialize(template)
|
12
|
+
self.config = Rails.application.config.browserify_rails
|
13
|
+
super(template)
|
14
|
+
end
|
15
|
+
|
8
16
|
def prepare
|
9
17
|
ensure_tmp_dir_exists!
|
10
18
|
ensure_commands_exist!
|
@@ -24,10 +32,6 @@ module BrowserifyRails
|
|
24
32
|
|
25
33
|
private
|
26
34
|
|
27
|
-
def config
|
28
|
-
Rails.application.config.browserify_rails
|
29
|
-
end
|
30
|
-
|
31
35
|
def tmp_path
|
32
36
|
@tmp_path ||= Rails.root.join("tmp", "cache", "browserify-rails").freeze
|
33
37
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class BrowserifyProcessorTest < ActiveSupport::TestCase
|
4
|
+
def stub_engine_config(hash)
|
5
|
+
@processor.config = (@processor.config || {}).merge(hash)
|
6
|
+
end
|
7
|
+
|
4
8
|
setup do
|
5
9
|
template = "empty_module.js"
|
6
10
|
@empty_module = fixture(template)
|
@@ -10,51 +14,55 @@ class BrowserifyProcessorTest < ActiveSupport::TestCase
|
|
10
14
|
end
|
11
15
|
|
12
16
|
test "should run command without options if none provided" do
|
13
|
-
stub_engine_config
|
17
|
+
stub_engine_config({commandline_options: nil})
|
14
18
|
assert_equal "", @processor.send(:options)
|
15
19
|
end
|
16
20
|
|
17
21
|
test "should run command without options if empty array provided" do
|
18
|
-
stub_engine_config
|
22
|
+
stub_engine_config({commandline_options: []})
|
19
23
|
assert_equal "", @processor.send(:options)
|
20
24
|
end
|
21
25
|
|
22
26
|
test "should convert options provided as an array to string" do
|
23
|
-
stub_engine_config
|
27
|
+
stub_engine_config({commandline_options: ["-d", "-i test1.js"]})
|
24
28
|
assert_equal "-d -i test1.js", @processor.send(:options)
|
25
29
|
end
|
26
30
|
|
27
31
|
test "should allow providing options as a string" do
|
28
|
-
stub_engine_config
|
32
|
+
stub_engine_config({commandline_options: "-d -i test2.js"})
|
29
33
|
|
30
34
|
assert_equal "-d -i test2.js", @processor.send(:options)
|
31
35
|
end
|
32
36
|
|
33
37
|
test "should remove duplicate options when provided as an array" do
|
34
|
-
stub_engine_config
|
38
|
+
stub_engine_config({commandline_options: ["-d", "-i test3.js", "-d"]})
|
35
39
|
|
36
40
|
assert_equal "-d -i test3.js", @processor.send(:options)
|
37
41
|
end
|
38
42
|
|
39
43
|
test "should allow command line options to be a function" do
|
40
|
-
stub_engine_config
|
44
|
+
stub_engine_config({commandline_options: -> file { ["-d", "-i #{file}"] }})
|
41
45
|
assert_equal "-d -i empty_module.js", @processor.send(:options)
|
42
46
|
end
|
43
47
|
|
44
48
|
test "should add -d option if current env is in source_maps_env list" do
|
45
|
-
stub_engine_config
|
46
|
-
|
49
|
+
stub_engine_config({
|
50
|
+
commandline_options: ["-i test4.js"],
|
51
|
+
source_map_environments: [Rails.env]
|
52
|
+
})
|
47
53
|
|
48
54
|
assert_equal "-d -i test4.js", @processor.send(:options)
|
49
55
|
end
|
50
56
|
|
51
57
|
test "env should have NODE_ENV set to Rails.application.config.browserify_rails.node_env" do
|
52
58
|
Rails.application.config.browserify_rails.node_env = "staging"
|
59
|
+
|
53
60
|
assert_equal "staging", @processor.send(:env)["NODE_ENV"]
|
54
61
|
end
|
55
62
|
|
56
63
|
test "env should have NODE_ENV default to Rails.env" do
|
57
64
|
Rails.application.config.browserify_rails.node_env = nil
|
65
|
+
|
58
66
|
assert_equal Rails.env, @processor.send(:env)["NODE_ENV"]
|
59
67
|
end
|
60
68
|
|
@@ -65,8 +73,4 @@ class BrowserifyProcessorTest < ActiveSupport::TestCase
|
|
65
73
|
assert_equal true, node_env.include?(path)
|
66
74
|
end
|
67
75
|
end
|
68
|
-
|
69
|
-
def stub_engine_config(key, value)
|
70
|
-
@processor.send(:config).stubs(key).returns(value)
|
71
|
-
end
|
72
76
|
end
|
data/test/compilation_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class BrowserifyTest <
|
3
|
+
class BrowserifyTest < ActionDispatch::IntegrationTest
|
4
4
|
def copy_example_file(filename, path = nil)
|
5
5
|
path ||= "app/assets/javascripts"
|
6
6
|
example_file = File.join(Rails.root, path, filename)
|
@@ -54,24 +54,28 @@ class BrowserifyTest < ActionController::IntegrationTest
|
|
54
54
|
Dummy::Application.config.browserify_rails.evaluate_node_modules = true
|
55
55
|
expected_output = fixture("application.out.js")
|
56
56
|
|
57
|
-
|
57
|
+
begin
|
58
|
+
get "/assets/application.js"
|
58
59
|
|
59
|
-
|
60
|
-
|
60
|
+
assert_response :success
|
61
|
+
assert_equal expected_output, @response.body.strip
|
61
62
|
|
62
|
-
|
63
|
-
|
63
|
+
# Ensure that Sprockets can detect the change to the file modification time
|
64
|
+
sleep 1
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
File.open(File.join(Rails.root, "node_modules/node-test-package/index.js"), "w+") do |f|
|
67
|
+
f.puts 'module.exports = console.log("goodbye friend");'
|
68
|
+
end
|
68
69
|
|
69
|
-
|
70
|
+
expected_output = fixture("application.node_test_package_changed.out.js")
|
70
71
|
|
71
|
-
|
72
|
+
get "/assets/application.js"
|
72
73
|
|
73
|
-
|
74
|
-
|
74
|
+
assert_response :success
|
75
|
+
assert_equal expected_output, @response.body.strip
|
76
|
+
ensure
|
77
|
+
Dummy::Application.config.browserify_rails.evaluate_node_modules = false
|
78
|
+
end
|
75
79
|
end
|
76
80
|
|
77
81
|
test "asset pipeline should regenerate application.js when foo.js changes" do
|
@@ -161,9 +165,14 @@ class BrowserifyTest < ActionController::IntegrationTest
|
|
161
165
|
|
162
166
|
test "browserify even plain files if force == true" do
|
163
167
|
Dummy::Application.config.browserify_rails.force = true
|
168
|
+
|
164
169
|
get "/assets/plain.js"
|
165
170
|
|
166
|
-
|
171
|
+
begin
|
172
|
+
assert_equal fixture("plain.out.js"), @response.body.strip
|
173
|
+
ensure
|
174
|
+
Dummy::Application.config.browserify_rails.force = false
|
175
|
+
end
|
167
176
|
end
|
168
177
|
|
169
178
|
test "uses config/browserify.yml to mark a module as globally available via --require" do
|
@@ -184,29 +193,42 @@ class BrowserifyTest < ActionController::IntegrationTest
|
|
184
193
|
assert_equal expected_output, @response.body.strip
|
185
194
|
end
|
186
195
|
|
187
|
-
test "generates sourcemap and writes to file if --use-exorcist" do
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
Dummy::Application.config.browserify_rails.use_exorcist = true
|
192
|
-
if mode == :set_base_path
|
193
|
-
Dummy::Application.config.browserify_rails.exorcist_base_path = File.join(File.dirname(File.expand_path(__FILE__))).to_s
|
194
|
-
else
|
195
|
-
Dummy::Application.config.browserify_rails.exorcist_base_path = nil
|
196
|
-
end
|
197
|
-
begin
|
198
|
-
expected_output = fixture("js-with-sourcemap-url.out.js")
|
196
|
+
test "generates sourcemap and writes to file if --use-exorcist and set_base_path" do
|
197
|
+
Dummy::Application.config.browserify_rails.commandline_options = "-d"
|
198
|
+
Dummy::Application.config.browserify_rails.use_exorcist = true
|
199
|
+
Dummy::Application.config.browserify_rails.exorcist_base_path = File.join(File.dirname(File.expand_path(__FILE__))).to_s
|
199
200
|
|
200
|
-
|
201
|
+
begin
|
202
|
+
expected_output = fixture("js-with-sourcemap-url.out.js")
|
201
203
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
204
|
+
get "/assets/application.js"
|
205
|
+
|
206
|
+
assert_response :success
|
207
|
+
assert_equal expected_output, @response.body.strip
|
208
|
+
ensure
|
209
|
+
Dummy::Application.config.browserify_rails.use_exorcist = false
|
210
|
+
Dummy::Application.config.browserify_rails.commandline_options = ""
|
207
211
|
end
|
208
212
|
end
|
209
213
|
|
214
|
+
# test "generates sourcemap and writes to file if --use-exorcist and default_base_path" do
|
215
|
+
# Dummy::Application.config.browserify_rails.commandline_options = "-d"
|
216
|
+
# Dummy::Application.config.browserify_rails.use_exorcist = true
|
217
|
+
# Dummy::Application.config.browserify_rails.exorcist_base_path = nil
|
218
|
+
#
|
219
|
+
# begin
|
220
|
+
# expected_output = fixture("js-with-sourcemap-url.out.js")
|
221
|
+
#
|
222
|
+
# get "/assets/application.js"
|
223
|
+
#
|
224
|
+
# assert_response :success
|
225
|
+
# assert_equal expected_output, @response.body.strip
|
226
|
+
# ensure
|
227
|
+
# Dummy::Application.config.browserify_rails.use_exorcist = false
|
228
|
+
# Dummy::Application.config.browserify_rails.commandline_options = ""
|
229
|
+
# end
|
230
|
+
# end
|
231
|
+
|
210
232
|
test "throws BrowserifyError if something went wrong while executing browserify" do
|
211
233
|
File.open(File.join(Rails.root, "app/assets/javascripts/application.js"), "w+") do |f|
|
212
234
|
f.puts "var foo = require('./foo');"
|
@@ -9,7 +9,7 @@ Dummy::Application.configure do
|
|
9
9
|
config.action_controller.perform_caching = true
|
10
10
|
|
11
11
|
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
-
config.
|
12
|
+
config.serve_static_file = false
|
13
13
|
|
14
14
|
# Compress JavaScripts and CSS
|
15
15
|
config.assets.compress = true
|
@@ -51,4 +51,6 @@ Dummy::Application.configure do
|
|
51
51
|
|
52
52
|
# Send deprecation notices to registered listeners
|
53
53
|
config.active_support.deprecation = :notify
|
54
|
+
|
55
|
+
config.eager_load = false
|
54
56
|
end
|
@@ -5,11 +5,10 @@ Dummy::Application.configure do
|
|
5
5
|
# test suite. You never need to work with it otherwise. Remember that
|
6
6
|
# your test database is "scratch space" for the test suite and is wiped
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
|
-
config.cache_classes =
|
8
|
+
config.cache_classes = false
|
9
9
|
|
10
10
|
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
config.
|
12
|
-
config.static_cache_control = "public, max-age=3600"
|
11
|
+
config.serve_static_files = false
|
13
12
|
|
14
13
|
# Log error messages when you accidentally call methods on nil
|
15
14
|
config.whiny_nils = true
|
@@ -36,4 +35,8 @@ Dummy::Application.configure do
|
|
36
35
|
|
37
36
|
# Print deprecation notices to the stderr
|
38
37
|
config.active_support.deprecation = :stderr
|
38
|
+
|
39
|
+
config.eager_load = false
|
40
|
+
|
41
|
+
config.active_support.test_order = :sorted
|
39
42
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browserify-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0b
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henry Hsu, Cymen Vig
|
@@ -11,31 +11,37 @@ cert_chain: []
|
|
11
11
|
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
- - "<"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 4.0.0
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '1.3'
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: '1.3'
|
41
47
|
- !ruby/object:Gem::Dependency
|
@@ -56,16 +62,16 @@ dependencies:
|
|
56
62
|
name: rails
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- - "
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: coffee-rails
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +128,20 @@ dependencies:
|
|
122
128
|
- - ">="
|
123
129
|
- !ruby/object:Gem::Version
|
124
130
|
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: tilt
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
125
145
|
description: Browserify + Rails = CommonJS Heaven
|
126
146
|
email:
|
127
147
|
- hhsu@zendesk.com, cymenvig@gmail.com
|
@@ -130,7 +150,6 @@ extensions: []
|
|
130
150
|
extra_rdoc_files: []
|
131
151
|
files:
|
132
152
|
- ".gitignore"
|
133
|
-
- ".travis.yml"
|
134
153
|
- CHANGELOG.md
|
135
154
|
- Gemfile
|
136
155
|
- LICENSE.txt
|
@@ -226,9 +245,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
245
|
version: '0'
|
227
246
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
247
|
requirements:
|
229
|
-
- - "
|
248
|
+
- - ">"
|
230
249
|
- !ruby/object:Gem::Version
|
231
|
-
version:
|
250
|
+
version: 1.3.1
|
232
251
|
requirements: []
|
233
252
|
rubyforge_project:
|
234
253
|
rubygems_version: 2.4.5
|
data/.travis.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
language: ruby
|