browserify-rails 0.5.1 → 0.6.0

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: aeecc403d82b8bdd29c23d5ec203a95eb9af2ba0
4
- data.tar.gz: 6c0192837995cb3608bc80200444f864b92bb09a
3
+ metadata.gz: 31f20bae2702655004904b80da5922dd785b5ba5
4
+ data.tar.gz: d428590fea987f46fbf6116754d77da5014f8f87
5
5
  SHA512:
6
- metadata.gz: f37a94233e4b1c76c908b3fcfd4ce1ebe6c698f663beeddfebd05c5b2d2a42be0e08c005aa6ef8204e61df7a83b96dd847baca04e109e2aae9dbd41b63b0e4dd
7
- data.tar.gz: 0d4220551f56097e05ef7687fae4ed5ffa0f856a186db0003f85a49c6aee8df6a4ee857bb399e8f79b73978206577d8e66e3943fe6e72d82d426a1768d874f0f
6
+ metadata.gz: f8bffd09ad1abd12acc2043fb5bc3a530c8c356602aa2d7b28c198a6121f765020737b22eaaad553dbd940113fe50eb581229e71427bccf75ff284e3eec1531f
7
+ data.tar.gz: 933039714e6ad123741f6a0990c89b581f44e16b05ae66f353006716e30193dbc2d1f87ef5d65390c1bbea487b82655ca8449616ae94d6221c1b3049743ac15b
data/README.md CHANGED
@@ -17,7 +17,7 @@ It lets you mix and match `//= require` directives and `require()` calls for in
17
17
 
18
18
  Add this line to your application's Gemfile:
19
19
 
20
- gem "browserify-rails", "~> 0.4"
20
+ gem "browserify-rails", "~> 0.5"
21
21
 
22
22
  Create `package.json` in your Rails root:
23
23
 
@@ -25,7 +25,7 @@ Create `package.json` in your Rails root:
25
25
  {
26
26
  "name": "something",
27
27
  "devDependencies" : {
28
- "browserify": "~> 4.1"
28
+ "browserify": "~> 6.3"
29
29
  },
30
30
  "license": "MIT",
31
31
  "engines": {
@@ -54,7 +54,7 @@ console.log(foo(12));
54
54
  For CoffeeScript support, make sure to follow the standard rails
55
55
  `.js.coffee` naming convention. You'll also need to do the following:
56
56
 
57
- Add `coffeify` as a dependency within `package.json`:
57
+ Add `coffeeify` as a dependency within `package.json`:
58
58
 
59
59
  ```js
60
60
  {
@@ -100,6 +100,11 @@ class My::Application < Rails::Application
100
100
  # The default is `["development"]`.
101
101
  config.browserify_rails.source_map_environments << "production"
102
102
 
103
+ # Should the node_modules directory be evaluated for changes on page load
104
+ #
105
+ # The default is `false`
106
+ config.browserify_rails.evaluate_node_modules = true
107
+
103
108
  # Command line options used when running browserify
104
109
  #
105
110
  # can be provided as an array:
@@ -10,7 +10,7 @@ module BrowserifyRails
10
10
 
11
11
  def evaluate(context, locals, &block)
12
12
  if should_browserify?
13
- asset_dependencies(context.environment.paths).each do |path|
13
+ evaluate_dependencies(context.environment.paths).each do |path|
14
14
  context.depend_on(path)
15
15
  end
16
16
 
@@ -60,8 +60,10 @@ module BrowserifyRails
60
60
 
61
61
  # This primarily filters out required files from node modules
62
62
  #
63
- # @return [<String>] Paths of dependencies, that are in asset directories
64
- def asset_dependencies(asset_paths)
63
+ # @return [<String>] Paths of dependencies to evaluate
64
+ def evaluate_dependencies(asset_paths)
65
+ return dependencies if config.evaluate_node_modules
66
+
65
67
  dependencies.select do |path|
66
68
  path.start_with?(*asset_paths)
67
69
  end
@@ -6,6 +6,9 @@ module BrowserifyRails
6
6
  config.browserify_rails.paths = [lambda { |p| p.start_with?(Rails.root.join("app").to_s) },
7
7
  lambda { |p| p.start_with?(Rails.root.join("node_modules").to_s) }]
8
8
 
9
+ # Should node_modules be evaluated assets before run_browserify
10
+ config.browserify_rails.evaluate_node_modules = false
11
+
9
12
  # Environments to generate source maps in
10
13
  config.browserify_rails.source_map_environments = ["development"]
11
14
 
@@ -1,3 +1,3 @@
1
1
  module BrowserifyRails
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -1,9 +1,10 @@
1
1
  require "test_helper"
2
2
 
3
3
  class BrowserifyTest < ActionController::IntegrationTest
4
- def copy_example_file(filename)
5
- example_file = File.join(Rails.root, "app/assets/javascripts/#{filename}")
6
- new_file = File.join(Rails.root, "app/assets/javascripts/#{filename.gsub(/\.example$/, '')}")
4
+ def copy_example_file(filename, path = nil)
5
+ path ||= "app/assets/javascripts"
6
+ example_file = File.join(Rails.root, path, filename)
7
+ new_file = File.join(Rails.root, path, filename.gsub(/\.example$/, ''))
7
8
 
8
9
  FileUtils.cp(example_file, new_file)
9
10
  end
@@ -22,6 +23,7 @@ class BrowserifyTest < ActionController::IntegrationTest
22
23
  copy_example_file "a_huge_library.js.example"
23
24
  copy_example_file "some_folder/answer.js.example"
24
25
  copy_example_file "browserified.js.example"
26
+ copy_example_file "index.js.example", "node_modules/node-test-package"
25
27
  end
26
28
 
27
29
  test "asset pipeline should serve application.js" do
@@ -33,9 +35,53 @@ class BrowserifyTest < ActionController::IntegrationTest
33
35
  end
34
36
 
35
37
  test "asset pipeline should serve foo.js" do
36
- expected_output = fixture("foo.out.js")
38
+ expected_output = fixture("application.out.js")
39
+
40
+ get "/assets/application.js"
41
+ assert_response :success
42
+ assert_equal expected_output, @response.body.strip
43
+ end
44
+
45
+ test "asset pipeline should not regenerate application.js when node_modules changes" do
46
+ Dummy::Application.config.browserify_rails.evaluate_node_modules = false
47
+ expected_output = fixture("application.out.js")
48
+
49
+ get "/assets/application.js"
50
+ assert_response :success
51
+ assert_equal expected_output, @response.body.strip
52
+
53
+ # Ensure that Sprockets can detect the change to the file modification time
54
+ sleep 1
55
+
56
+ File.open(File.join(Rails.root, "node_modules/node-test-package/index.js"), "w+") do |f|
57
+ f.puts 'module.exports = console.log("goodbye friend");'
58
+ end
59
+
60
+ expected_output = fixture("application.out.js")
37
61
 
38
- get "/assets/foo.js"
62
+ get "/assets/application.js"
63
+ assert_response :success
64
+ assert_equal expected_output, @response.body.strip
65
+ end
66
+
67
+ test "asset pipeline should regenerate application.js when node_modules changes" do
68
+ Dummy::Application.config.browserify_rails.evaluate_node_modules = true
69
+ expected_output = fixture("application.out.js")
70
+
71
+ get "/assets/application.js"
72
+ assert_response :success
73
+ assert_equal expected_output, @response.body.strip
74
+
75
+ # Ensure that Sprockets can detect the change to the file modification time
76
+ sleep 1
77
+
78
+ File.open(File.join(Rails.root, "node_modules/node-test-package/index.js"), "w+") do |f|
79
+ f.puts 'module.exports = console.log("goodbye friend");'
80
+ end
81
+
82
+ expected_output = fixture("application.node_test_package_changed.out.js")
83
+
84
+ get "/assets/application.js"
39
85
  assert_response :success
40
86
  assert_equal expected_output, @response.body.strip
41
87
  end
@@ -1 +1,2 @@
1
1
  var foo = require('./foo');
2
+ var nodeTestPackage = require('node-test-package');
@@ -4,7 +4,8 @@
4
4
  "description": "a dummy Rails application",
5
5
  "devDependencies" : {
6
6
  "browserify": "~> 6.2",
7
- "coffeeify": "~> 0.6"
7
+ "coffeeify": "~> 0.6",
8
+ "node-test-package": "~> 0.0.2"
8
9
  },
9
10
  "license": "MIT",
10
11
  "engines": {
@@ -1,11 +1,15 @@
1
1
  (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
2
  var foo = require('./foo');
3
+ var nodeTestPackage = require('node-test-package');
3
4
 
4
- },{"./foo":2}],2:[function(require,module,exports){
5
+ },{"./foo":2,"node-test-package":4}],2:[function(require,module,exports){
5
6
  require('./nested');
6
7
  module.exports = function (n) { return n * 12 }
7
8
 
8
9
  },{"./nested":3}],3:[function(require,module,exports){
9
10
  module.exports.NESTED = true;
10
11
 
11
- },{}]},{},[1]);
12
+ },{}],4:[function(require,module,exports){
13
+ module.exports = console.log("hello friend");
14
+
15
+ },{}]},{},[1]);
@@ -0,0 +1,15 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ var foo = require('./foo');
3
+ var nodeTestPackage = require('node-test-package');
4
+
5
+ },{"./foo":2,"node-test-package":4}],2:[function(require,module,exports){
6
+ require('./nested');
7
+ module.exports = function (n) { return n * 11 }
8
+
9
+ },{"./nested":3}],3:[function(require,module,exports){
10
+ module.exports.NESTED = true;
11
+
12
+ },{}],4:[function(require,module,exports){
13
+ module.exports = console.log("goodbye friend");
14
+
15
+ },{}]},{},[1]);
@@ -1,11 +1,15 @@
1
1
  (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
2
  var foo = require('./foo');
3
+ var nodeTestPackage = require('node-test-package');
3
4
 
4
- },{"./foo":2}],2:[function(require,module,exports){
5
+ },{"./foo":2,"node-test-package":4}],2:[function(require,module,exports){
5
6
  require('./nested');
6
7
  module.exports = function (n) { return n * 11 }
7
8
 
8
9
  },{"./nested":3}],3:[function(require,module,exports){
9
10
  module.exports.NESTED = true;
10
11
 
11
- },{}]},{},[1]);
12
+ },{}],4:[function(require,module,exports){
13
+ module.exports = console.log("hello friend");
14
+
15
+ },{}]},{},[1]);
@@ -0,0 +1,4 @@
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ module.exports = console.log("hello friend");
3
+
4
+ },{}]},{},[1]);
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: 0.5.1
4
+ version: 0.6.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: 2014-11-13 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -181,6 +181,7 @@ files:
181
181
  - test/dummy/script/rails
182
182
  - test/fixtures/application.changed.out.js
183
183
  - test/fixtures/application.foo_changed.out.js
184
+ - test/fixtures/application.node_test_package_changed.out.js
184
185
  - test/fixtures/application.out.js
185
186
  - test/fixtures/browserified.out.js
186
187
  - test/fixtures/empty_module.js
@@ -188,6 +189,7 @@ files:
188
189
  - test/fixtures/main.out.js
189
190
  - test/fixtures/mocha.js
190
191
  - test/fixtures/node_path_based_require.out.js
192
+ - test/fixtures/node_test_package.out.js
191
193
  - test/fixtures/secondary.out.js
192
194
  - test/test_helper.rb
193
195
  homepage: https://github.com/browserify-rails/browserify-rails
@@ -267,6 +269,7 @@ test_files:
267
269
  - test/dummy/script/rails
268
270
  - test/fixtures/application.changed.out.js
269
271
  - test/fixtures/application.foo_changed.out.js
272
+ - test/fixtures/application.node_test_package_changed.out.js
270
273
  - test/fixtures/application.out.js
271
274
  - test/fixtures/browserified.out.js
272
275
  - test/fixtures/empty_module.js
@@ -274,5 +277,6 @@ test_files:
274
277
  - test/fixtures/main.out.js
275
278
  - test/fixtures/mocha.js
276
279
  - test/fixtures/node_path_based_require.out.js
280
+ - test/fixtures/node_test_package.out.js
277
281
  - test/fixtures/secondary.out.js
278
282
  - test/test_helper.rb