browserify-rails 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -3
- data/lib/browserify-rails/browserify_processor.rb +18 -2
- data/lib/browserify-rails/railtie.rb +18 -8
- data/lib/browserify-rails/version.rb +1 -1
- data/test/fixtures/main.out.js +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4dcf3eb3bc52f7b2cd40c8c6acddc9a0553d6dc
|
4
|
+
data.tar.gz: 2f58e322cc3574fc3f2b3940353d7345016d4dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ee233810dbc83ed84e4d4c1045f7ff80aaba4cc0e618477639bcd3fdeb79c0773f286317b1af1eee79b43c84f8a8fee6a442b74669384192c1d318a1fcef10
|
7
|
+
data.tar.gz: ef402cd88e6f4d4ab40f212a1fe28a924badca4d2a518e64f93b2626e6920f53642c942bf55bddf7cf7808dc1842dc2030ae66613ff5102c81f6ce1d20782637
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file going forward.
|
3
3
|
|
4
|
+
## [1.5.0] - 2015-10-07
|
5
|
+
- add jruby support for file name resolution (thanks to jmagoon)
|
6
|
+
- make config.force more flexible by allowing it to be a proc (thanks to rosendi)
|
7
|
+
- fix browserify-rails to work with new sprockets 3 interface (thanks to hajpoj)
|
8
|
+
- fix broken test with current `npm install` in dummy test app
|
9
|
+
|
4
10
|
## [1.4.0] - 2015-08-12
|
5
11
|
- modify tilt allowed version to be ">= 1.1", "< 3" to be compatible with sass-rails
|
6
12
|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
This library adds CommonJS module support to Sprockets (via Browserify).
|
7
7
|
|
8
|
-
It lets you mix and match `//= require` directives and `require()` calls for including plain javascript files as well as modules.
|
8
|
+
It lets you mix and match `//= require` directives and `require()` calls for including plain javascript files as well as modules. However, it is important to remember that once you are into code that is being browserified you can no longer use sprockets-style require (so no `//= require`). In many cases, it makes sense to put all your sprockets-required code in a separate file or at the very least at the top of your main JavaScript file. Then use `require()` to pull in the CommonJS code.
|
9
9
|
|
10
10
|
1. Manage JS modules with `npm`
|
11
11
|
2. Serve assets with Sprockets
|
@@ -109,10 +109,11 @@ class My::Application < Rails::Application
|
|
109
109
|
# The default is `false`
|
110
110
|
config.browserify_rails.evaluate_node_modules = true
|
111
111
|
|
112
|
-
# Force browserify on every found JavaScript asset
|
112
|
+
# Force browserify on every found JavaScript asset if true.
|
113
|
+
# Can be a proc.
|
113
114
|
#
|
114
115
|
# The default is `false`
|
115
|
-
config.browserify_rails.force =
|
116
|
+
config.browserify_rails.force = ->(file) { File.extname(file) == ".ts" }
|
116
117
|
|
117
118
|
# Command line options used when running browserify
|
118
119
|
#
|
@@ -221,6 +222,15 @@ The second method is definitely brute force but if you experience issues,
|
|
221
222
|
it is definitely worth trying before spending too much time debugging
|
222
223
|
why something that is browserified appears to not match the sources files.
|
223
224
|
|
225
|
+
## Acceptance Test Failures
|
226
|
+
|
227
|
+
If you have Sprockets precompile multiple JS files, each of which include
|
228
|
+
certain browserified files, your acceptance tests may timeout before some
|
229
|
+
of the assets have finished compiling.
|
230
|
+
|
231
|
+
To avoid this problem, run `rake assets:precompile` before running your
|
232
|
+
acceptance tests.
|
233
|
+
|
224
234
|
## Contributing
|
225
235
|
|
226
236
|
Pull requests appreciated. Pull requests will not be rejected based on
|
@@ -67,7 +67,15 @@ module BrowserifyRails
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def should_browserify?
|
70
|
-
|
70
|
+
force_browserify? || (in_path? && !browserified? && commonjs_module?)
|
71
|
+
end
|
72
|
+
|
73
|
+
def force_browserify?
|
74
|
+
if config.force.is_a? Proc
|
75
|
+
config.force.call file
|
76
|
+
else
|
77
|
+
config.force
|
78
|
+
end
|
71
79
|
end
|
72
80
|
|
73
81
|
# Is this file in any of the configured paths?
|
@@ -171,7 +179,15 @@ module BrowserifyRails
|
|
171
179
|
base_directory = File.dirname(file)
|
172
180
|
|
173
181
|
Logger::log "Browserify: #{command}"
|
174
|
-
|
182
|
+
|
183
|
+
# If we are on JRuby 1.x, capture3 does not support chdir option
|
184
|
+
stdout, stderr, status = if RUBY_PLATFORM == "java" && JRUBY_VERSION =~ /^1/
|
185
|
+
Dir.chdir(base_directory) {
|
186
|
+
Open3.capture3(env, command, stdin_data: data)
|
187
|
+
}
|
188
|
+
else
|
189
|
+
Open3.capture3(env, command, stdin_data: data, chdir: base_directory)
|
190
|
+
end
|
175
191
|
|
176
192
|
if !status.success?
|
177
193
|
raise BrowserifyRails::BrowserifyError.new("Error while running `#{command}`:\n\n#{stderr}")
|
@@ -4,7 +4,7 @@ module BrowserifyRails
|
|
4
4
|
class Railtie < Rails::Engine
|
5
5
|
config.browserify_rails = ActiveSupport::OrderedOptions.new
|
6
6
|
|
7
|
-
#
|
7
|
+
# Browserify every file if true. Can be a proc.
|
8
8
|
config.browserify_rails.force = false
|
9
9
|
|
10
10
|
# Which paths should be browserified?
|
@@ -24,17 +24,27 @@ module BrowserifyRails
|
|
24
24
|
# until then, disable in staging and production
|
25
25
|
config.browserify_rails.use_browserifyinc = !["staging", "production"].include?(Rails.env)
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
if config.respond_to?(:assets)
|
28
|
+
config.assets.configure do |env|
|
29
|
+
load_granular_configuration
|
30
|
+
env.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
|
31
|
+
end
|
32
|
+
else
|
33
|
+
initializer :setup_browserify do |app|
|
34
|
+
load_granular_configuration
|
35
|
+
app.assets.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
39
|
+
|
36
40
|
rake_tasks do
|
37
41
|
Dir[File.join(File.dirname(__FILE__), "tasks/*.rake")].each { |f| load f }
|
38
42
|
end
|
43
|
+
|
44
|
+
def load_granular_configuration
|
45
|
+
filename = File.join(Rails.root, 'config', 'browserify.yml')
|
46
|
+
configuration = YAML::load(File.read(filename)) if File.exist? filename
|
47
|
+
config.browserify_rails.granular = configuration || {}
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
data/test/fixtures/main.out.js
CHANGED
@@ -5,7 +5,7 @@ module.exports = function() {
|
|
5
5
|
console.log('library', library);
|
6
6
|
};
|
7
7
|
|
8
|
-
},{"./a_huge_library":"__RAILS_ROOT__/app/assets/javascripts/a_huge_library.js"}],"
|
8
|
+
},{"./a_huge_library":"__RAILS_ROOT__/app/assets/javascripts/a_huge_library.js"}],"a_huge_library":[function(require,module,exports){
|
9
9
|
// pretend this file is 1 MB
|
10
10
|
//
|
11
11
|
// app_main.js is going to require() it and browserify.yml is going to tell it to use --require on it
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browserify-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henry Hsu, Cymen Vig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08
|
11
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|