browserify-rails 0.6.0 → 0.7.1

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: 31f20bae2702655004904b80da5922dd785b5ba5
4
- data.tar.gz: d428590fea987f46fbf6116754d77da5014f8f87
3
+ metadata.gz: 1ec87a4fff319b405562ec1fa058d017b69f6d11
4
+ data.tar.gz: 237322a74b3801ccb8124b948fd89700a742c831
5
5
  SHA512:
6
- metadata.gz: f8bffd09ad1abd12acc2043fb5bc3a530c8c356602aa2d7b28c198a6121f765020737b22eaaad553dbd940113fe50eb581229e71427bccf75ff284e3eec1531f
7
- data.tar.gz: 933039714e6ad123741f6a0990c89b581f44e16b05ae66f353006716e30193dbc2d1f87ef5d65390c1bbea487b82655ca8449616ae94d6221c1b3049743ac15b
6
+ metadata.gz: 0b7cf388a9aedb93b97d24d0169f02a8c98ebb10b1aa053f224fb03d954982602edb57f379072da200f29ffafa477157bcff897d0fbcc8ad583359b9582fe85f
7
+ data.tar.gz: 7f0a8eb6d944b42b032f3b04b3d6700a1ba69562364f7a732df7e0c631ff625d5be17c71cbd8eb443bbd986285ebd488f33a0d2a05a228e0ccd5b99c60feec7b
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.5"
20
+ gem "browserify-rails", "~> 0.7"
21
21
 
22
22
  Create `package.json` in your Rails root:
23
23
 
@@ -25,7 +25,8 @@ Create `package.json` in your Rails root:
25
25
  {
26
26
  "name": "something",
27
27
  "devDependencies" : {
28
- "browserify": "~> 6.3"
28
+ "browserify": "~> 6.3",
29
+ "browserify-incremental": "^1.4.0"
29
30
  },
30
31
  "license": "MIT",
31
32
  "engines": {
@@ -143,6 +144,14 @@ use cases have been considered. If your use case does not work, please open
143
144
  an issue with a runnable example of the problem including your
144
145
  browserify.yml file.
145
146
 
147
+ ### Inside Isolated Engines
148
+
149
+ To make browserify-rails work inside an isolated engine, add the engine app directory to the browserify-rails paths (inside engine.rb):
150
+
151
+ ```ruby
152
+ config.browserify_rails.paths << lambda { |p| p.start_with?(Engine.root.join("app").to_s) }
153
+ ```
154
+
146
155
  ## Support for rails asset directories as non-relative module sources
147
156
 
148
157
  In the Rails asset pipeline, it is common to have files in
@@ -1,37 +1,55 @@
1
1
  require "open3"
2
+ require "fileutils"
3
+ require "tempfile"
2
4
 
3
5
  module BrowserifyRails
4
6
  class BrowserifyProcessor < Tilt::Template
5
- BROWSERIFY_CMD = "./node_modules/.bin/browserify".freeze
7
+ NODE_BIN = "node_modules/.bin/"
8
+
9
+ BROWSERIFY_CMD = File.join(NODE_BIN, "browserify").freeze
10
+ BROWSERIFYINC_CMD = File.join(NODE_BIN, "browserifyinc").freeze
11
+
12
+ TMP_PATH = File.join("tmp/browserify-rails").freeze
6
13
 
7
14
  def prepare
8
- @config = Rails.application.config.browserify_rails_granular
15
+ ensure_tmp_dir_exists!
16
+ ensure_commands_exist!
9
17
  end
10
18
 
11
19
  def evaluate(context, locals, &block)
12
- if should_browserify?
13
- evaluate_dependencies(context.environment.paths).each do |path|
14
- context.depend_on(path)
15
- end
20
+ # If there's nothing to do, we just return the data we received
21
+ return data unless should_browserify?
16
22
 
17
- browserify context.logical_path
18
- else
19
- data
23
+ # Signal dependencies to sprockets to ensure we track changes
24
+ evaluate_dependencies(context.environment.paths).each do |path|
25
+ context.depend_on(path)
20
26
  end
27
+
28
+ run_browserify(context.logical_path)
21
29
  end
22
30
 
23
- private
31
+ private
24
32
 
25
- def asset_paths
26
- @asset_paths ||= Rails.application.config.assets.paths.collect { |p| p.to_s }.join(":") || ""
33
+ def config
34
+ Rails.application.config.browserify_rails
27
35
  end
28
36
 
29
- def has_config?(logical_path)
30
- @config.has_key?("javascript") && @config["javascript"].has_key?(logical_path)
37
+ def ensure_tmp_dir_exists!
38
+ FileUtils.mkdir_p(rails_path(TMP_PATH))
31
39
  end
32
40
 
33
- def get_config(logical_path)
34
- @config["javascript"][logical_path] if @config.has_key?("javascript")
41
+ def ensure_commands_exist!
42
+ error = ->(cmd) { "Unable to run #{cmd}. Ensure you have installed it with npm." }
43
+
44
+ # Browserify has to be installed in any case
45
+ if !File.exists?(rails_path(BROWSERIFY_CMD))
46
+ raise BrowserifyRails::BrowserifyError.new(error.call(BROWSERIFY_CMD))
47
+ end
48
+
49
+ # If the user wants to use browserifyinc, we need to ensure it's there too
50
+ if config.use_browserifyinc && !File.exists?(rails_path(BROWSERIFYINC_CMD))
51
+ raise BrowserifyRails::BrowserifyError.new(error.call(BROWSERIFYINC_CMD))
52
+ end
35
53
  end
36
54
 
37
55
  def should_browserify?
@@ -58,6 +76,10 @@ module BrowserifyRails
58
76
  data.to_s.include?("module.exports") || data.present? && data.to_s.include?("require") && dependencies.length > 0
59
77
  end
60
78
 
79
+ def asset_paths
80
+ @asset_paths ||= Rails.application.config.assets.paths.collect { |p| p.to_s }.join(":") || ""
81
+ end
82
+
61
83
  # This primarily filters out required files from node modules
62
84
  #
63
85
  # @return [<String>] Paths of dependencies to evaluate
@@ -71,27 +93,20 @@ module BrowserifyRails
71
93
 
72
94
  # @return [<String>] Paths of files, that this file depends on
73
95
  def dependencies
74
- @dependencies ||= run_browserify("#{options} --list").lines.map(&:strip).select do |path|
75
- # Filter the temp file, where browserify caches the input stream
76
- File.exists?(path)
77
- end
78
- end
79
-
80
- def browserify(logical_path)
81
- run_browserify(options, logical_path)
82
- end
83
-
84
- def browserify_cmd
85
- cmd = File.join(Rails.root, BROWSERIFY_CMD)
86
-
87
- if !File.exist?(cmd)
88
- raise BrowserifyRails::BrowserifyError.new("browserify could not be found at #{cmd}. Please run npm install.")
96
+ @dependencies ||= begin
97
+ # We forcefully run browserify (avoiding browserifyinc) with the --list
98
+ # option to get a list of files.
99
+ list = run_browserify(nil, "--list")
100
+
101
+ list.lines.map(&:strip).select do |path|
102
+ # Filter the temp file, where browserify caches the input stream
103
+ File.exists?(path)
104
+ end
89
105
  end
90
-
91
- cmd
92
106
  end
93
107
 
94
- # Run browserify with `data` on standard input.
108
+ # Run the requested version of browserify (browserify or browserifyinc)
109
+ # based on configuration or the use_browserifyinc parameter if present.
95
110
  #
96
111
  # We are passing the data via stdin, so that earlier preprocessing steps are
97
112
  # respected. If you had, say, an "application.js.coffee.erb", passing the
@@ -101,32 +116,61 @@ module BrowserifyRails
101
116
  # javascript at the time this processor is called.
102
117
  #
103
118
  # @raise [BrowserifyRails::BrowserifyError] if browserify does not succeed
104
- # @param options [String] Options for browserify
105
- # @return [String] Output on standard out
106
- def run_browserify(options, logical_path=nil)
107
- if has_config?(logical_path)
108
- config = get_config logical_path
109
-
110
- granular_options = config.keys.collect do |key|
111
- config[key].collect { |value| "--#{key} #{value}" }
112
- end
113
-
114
- options += " " + granular_options.join(" ")
119
+ # @param logical_path [String] Sprockets's logical path for the file
120
+ # @param extra_options [String] Options to be included in the command
121
+ # @param force_browserifyinc [Boolean] Causes browserifyinc to be used if true
122
+ # @return [String] Output of the command
123
+ def run_browserify(logical_path=nil, extra_options=nil, force_browserifyinc=nil)
124
+ command_options = "#{options} #{extra_options} #{granular_options(logical_path)}".strip
125
+
126
+ # Browserifyinc uses a special cache file. We set up the path for it if
127
+ # we're going to use browserifyinc.
128
+ if uses_browserifyinc(force_browserifyinc)
129
+ cache_file_path = rails_path(TMP_PATH, "browserifyinc-cache.json")
130
+ command_options << " --cachefile=#{cache_file_path.inspect}"
115
131
  end
116
132
 
117
- directory = File.dirname(file)
118
- command = "#{browserify_cmd} #{options} -"
133
+ # Create a temporary file for the output. Such file is necessary when
134
+ # using browserifyinc, but we use it in all instances for consistency
135
+ output_file = Tempfile.new("output", rails_path(TMP_PATH))
136
+ command_options << " -o #{output_file.path.inspect}"
137
+
138
+ # Compose the full command (using browserify or browserifyinc as necessary)
139
+ command = "#{browserify_command(force_browserifyinc)} #{command_options} -"
140
+ env = { "NODE_PATH" => asset_paths }
141
+
142
+ # The directory the command will be executed from
143
+ base_directory = File.dirname(file)
144
+
119
145
  Logger::log "Browserify: #{command}"
120
- env = {
121
- "NODE_PATH" => asset_paths
122
- }
123
- stdout, stderr, status = Open3.capture3(env, command, stdin_data: data, chdir: directory)
146
+ stdout, stderr, status = Open3.capture3(env, command, stdin_data: data, chdir: base_directory)
124
147
 
125
148
  if !status.success?
126
149
  raise BrowserifyRails::BrowserifyError.new("Error while running `#{command}`:\n\n#{stderr}")
127
150
  end
128
151
 
129
- stdout
152
+ # Read the output that was stored in the temp file
153
+ output = output_file.read
154
+
155
+ # Destroy the temp file (good practice)
156
+ output_file.close
157
+ output_file.unlink
158
+
159
+ # Some command flags (such as --list) make the output go to stdout,
160
+ # ignoring -o. If this happens, we give out stdout instead.
161
+ if stdout.present?
162
+ stdout
163
+ else
164
+ output
165
+ end
166
+ end
167
+
168
+ def uses_browserifyinc(force=nil)
169
+ !force.nil? ? force : config.use_browserifyinc
170
+ end
171
+
172
+ def browserify_command(force=nil)
173
+ rails_path(uses_browserifyinc(force) ? BROWSERIFYINC_CMD : BROWSERIFY_CMD)
130
174
  end
131
175
 
132
176
  def options
@@ -139,8 +183,27 @@ module BrowserifyRails
139
183
  options.uniq.join(" ")
140
184
  end
141
185
 
142
- def config
143
- BrowserifyRails::Railtie.config.browserify_rails
186
+ def get_granular_config(logical_path)
187
+ granular_config = config.granular["javascript"]
188
+
189
+ granular_config && granular_config[logical_path]
190
+ end
191
+
192
+ def granular_options(logical_path)
193
+ granular_config = get_granular_config(logical_path)
194
+
195
+ return nil if granular_config.blank?
196
+
197
+ # We set separate options for each of the items in granular_config
198
+ options = granular_config.keys.collect do |key|
199
+ granular_config[key].collect { |value| "--#{key} #{value}" }
200
+ end
201
+
202
+ options.flatten.join(" ") if options
203
+ end
204
+
205
+ def rails_path(*paths)
206
+ Rails.root.join(*paths).to_s
144
207
  end
145
208
  end
146
209
  end
@@ -12,11 +12,14 @@ module BrowserifyRails
12
12
  # Environments to generate source maps in
13
13
  config.browserify_rails.source_map_environments = ["development"]
14
14
 
15
+ # Use browserifyinc instead of browserify
16
+ config.browserify_rails.use_browserifyinc = true
17
+
15
18
  initializer :setup_browserify do |app|
16
19
  # Load granular configuration
17
20
  filename = File.join(Rails.root, 'config', 'browserify.yml')
18
21
  configuration = YAML::load(File.read(filename)) if File.exist? filename
19
- config.browserify_rails_granular = configuration || {}
22
+ config.browserify_rails.granular = configuration || {}
20
23
 
21
24
  app.assets.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
22
25
  end
@@ -1,3 +1,3 @@
1
1
  module BrowserifyRails
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -12,6 +12,9 @@ class BrowserifyTest < ActionController::IntegrationTest
12
12
  setup do
13
13
  Rails.application.assets.cache = nil
14
14
 
15
+ cache_file = File.join(Rails.root, "tmp/browserify-rails/browserifyinc-cache.json")
16
+ File.delete(cache_file) if File.exists?(cache_file)
17
+
15
18
  copy_example_file "application.js.example"
16
19
  copy_example_file "foo.js.example"
17
20
  copy_example_file "nested/index.js.example"
@@ -30,36 +33,16 @@ class BrowserifyTest < ActionController::IntegrationTest
30
33
  expected_output = fixture("application.out.js")
31
34
 
32
35
  get "/assets/application.js"
33
- assert_response :success
34
- assert_equal expected_output, @response.body.strip
35
- end
36
36
 
37
- test "asset pipeline should serve foo.js" do
38
- expected_output = fixture("application.out.js")
39
-
40
- get "/assets/application.js"
41
37
  assert_response :success
42
38
  assert_equal expected_output, @response.body.strip
43
39
  end
44
40
 
45
- test "asset pipeline should not regenerate application.js when node_modules changes" do
46
- Dummy::Application.config.browserify_rails.evaluate_node_modules = false
41
+ test "asset pipeline should serve foo.js" do
47
42
  expected_output = fixture("application.out.js")
48
43
 
49
44
  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")
61
45
 
62
- get "/assets/application.js"
63
46
  assert_response :success
64
47
  assert_equal expected_output, @response.body.strip
65
48
  end
@@ -69,6 +52,7 @@ class BrowserifyTest < ActionController::IntegrationTest
69
52
  expected_output = fixture("application.out.js")
70
53
 
71
54
  get "/assets/application.js"
55
+
72
56
  assert_response :success
73
57
  assert_equal expected_output, @response.body.strip
74
58
 
@@ -82,6 +66,7 @@ class BrowserifyTest < ActionController::IntegrationTest
82
66
  expected_output = fixture("application.node_test_package_changed.out.js")
83
67
 
84
68
  get "/assets/application.js"
69
+
85
70
  assert_response :success
86
71
  assert_equal expected_output, @response.body.strip
87
72
  end
@@ -90,6 +75,7 @@ class BrowserifyTest < ActionController::IntegrationTest
90
75
  expected_output = fixture("application.out.js")
91
76
 
92
77
  get "/assets/application.js"
78
+
93
79
  assert_response :success
94
80
  assert_equal expected_output, @response.body.strip
95
81
 
@@ -104,6 +90,7 @@ class BrowserifyTest < ActionController::IntegrationTest
104
90
  expected_output = fixture("application.foo_changed.out.js")
105
91
 
106
92
  get "/assets/application.js"
93
+
107
94
  assert_response :success
108
95
  assert_equal expected_output, @response.body.strip
109
96
  end
@@ -112,6 +99,7 @@ class BrowserifyTest < ActionController::IntegrationTest
112
99
  expected_output = fixture("application.out.js")
113
100
 
114
101
  get "/assets/application.js"
102
+
115
103
  assert_response :success
116
104
  assert_equal expected_output, @response.body.strip
117
105
 
@@ -126,6 +114,7 @@ class BrowserifyTest < ActionController::IntegrationTest
126
114
  expected_output = fixture("application.changed.out.js")
127
115
 
128
116
  get "/assets/application.js"
117
+
129
118
  assert_response :success
130
119
  assert_equal expected_output, @response.body.strip
131
120
  end
@@ -141,6 +130,7 @@ class BrowserifyTest < ActionController::IntegrationTest
141
130
 
142
131
  test "browserifies files with coffee requires" do
143
132
  get "/assets/coffee.js"
133
+
144
134
  assert_no_match /BrowserifyRails::BrowserifyError/, @response.body
145
135
  end
146
136
 
@@ -156,6 +146,7 @@ class BrowserifyTest < ActionController::IntegrationTest
156
146
 
157
147
  test "skips files that are already browserified" do
158
148
  get "/assets/browserified.js"
149
+
159
150
  assert_equal fixture("browserified.out.js"), @response.body.strip
160
151
  end
161
152
 
@@ -184,6 +175,7 @@ class BrowserifyTest < ActionController::IntegrationTest
184
175
  end
185
176
 
186
177
  get "/assets/application.js"
178
+
187
179
  assert_match /BrowserifyRails::BrowserifyError/, @response.body
188
180
  end
189
181
  end
@@ -4,6 +4,7 @@
4
4
  "description": "a dummy Rails application",
5
5
  "devDependencies" : {
6
6
  "browserify": "~> 6.2",
7
+ "browserify-incremental": "^1.4.0",
7
8
  "coffeeify": "~> 0.6",
8
9
  "node-test-package": "~> 0.0.2"
9
10
  },
@@ -1,12 +1,12 @@
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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var foo = require('./foo');
3
3
  console.log(foo(11));
4
4
 
5
- },{"./foo":2}],2:[function(require,module,exports){
5
+ },{"./foo":"__RAILS_ROOT__/app/assets/javascripts/foo.js"}],"__RAILS_ROOT__/app/assets/javascripts/foo.js":[function(require,module,exports){
6
6
  require('./nested');
7
7
  module.exports = function (n) { return n * 11 }
8
8
 
9
- },{"./nested":3}],3:[function(require,module,exports){
9
+ },{"./nested":"__RAILS_ROOT__/app/assets/javascripts/nested/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/nested/index.js":[function(require,module,exports){
10
10
  module.exports.NESTED = true;
11
11
 
12
- },{}]},{},[1]);
12
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -1,15 +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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var foo = require('./foo');
3
3
  var nodeTestPackage = require('node-test-package');
4
4
 
5
- },{"./foo":2,"node-test-package":4}],2:[function(require,module,exports){
5
+ },{"./foo":"__RAILS_ROOT__/app/assets/javascripts/foo.js","node-test-package":"__RAILS_ROOT__/node_modules/node-test-package/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/foo.js":[function(require,module,exports){
6
6
  require('./nested');
7
7
  module.exports = function (n) { return n * 12 }
8
8
 
9
- },{"./nested":3}],3:[function(require,module,exports){
9
+ },{"./nested":"__RAILS_ROOT__/app/assets/javascripts/nested/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/nested/index.js":[function(require,module,exports){
10
10
  module.exports.NESTED = true;
11
11
 
12
- },{}],4:[function(require,module,exports){
12
+ },{}],"__RAILS_ROOT__/node_modules/node-test-package/index.js":[function(require,module,exports){
13
13
  module.exports = console.log("hello friend");
14
14
 
15
- },{}]},{},[1]);
15
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -1,15 +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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var foo = require('./foo');
3
3
  var nodeTestPackage = require('node-test-package');
4
4
 
5
- },{"./foo":2,"node-test-package":4}],2:[function(require,module,exports){
5
+ },{"./foo":"__RAILS_ROOT__/app/assets/javascripts/foo.js","node-test-package":"__RAILS_ROOT__/node_modules/node-test-package/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/foo.js":[function(require,module,exports){
6
6
  require('./nested');
7
7
  module.exports = function (n) { return n * 11 }
8
8
 
9
- },{"./nested":3}],3:[function(require,module,exports){
9
+ },{"./nested":"__RAILS_ROOT__/app/assets/javascripts/nested/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/nested/index.js":[function(require,module,exports){
10
10
  module.exports.NESTED = true;
11
11
 
12
- },{}],4:[function(require,module,exports){
12
+ },{}],"__RAILS_ROOT__/node_modules/node-test-package/index.js":[function(require,module,exports){
13
13
  module.exports = console.log("goodbye friend");
14
14
 
15
- },{}]},{},[1]);
15
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -1,15 +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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var foo = require('./foo');
3
3
  var nodeTestPackage = require('node-test-package');
4
4
 
5
- },{"./foo":2,"node-test-package":4}],2:[function(require,module,exports){
5
+ },{"./foo":"__RAILS_ROOT__/app/assets/javascripts/foo.js","node-test-package":"__RAILS_ROOT__/node_modules/node-test-package/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/foo.js":[function(require,module,exports){
6
6
  require('./nested');
7
7
  module.exports = function (n) { return n * 11 }
8
8
 
9
- },{"./nested":3}],3:[function(require,module,exports){
9
+ },{"./nested":"__RAILS_ROOT__/app/assets/javascripts/nested/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/nested/index.js":[function(require,module,exports){
10
10
  module.exports.NESTED = true;
11
11
 
12
- },{}],4:[function(require,module,exports){
12
+ },{}],"__RAILS_ROOT__/node_modules/node-test-package/index.js":[function(require,module,exports){
13
13
  module.exports = console.log("hello friend");
14
14
 
15
- },{}]},{},[1]);
15
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -6,4 +6,4 @@ module.exports = function (n) { return n * 11 }
6
6
  },{"./nested":2}],2:[function(require,module,exports){
7
7
  module.exports.NESTED = true;
8
8
 
9
- },{}]},{},[1]);
9
+ },{}]},{},[1]);
@@ -1,11 +1,11 @@
1
- require=(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){
1
+ require=(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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var library = require('./a_huge_library');
3
3
 
4
4
  module.exports = function() {
5
5
  console.log('library', library);
6
6
  };
7
7
 
8
- },{"./a_huge_library":2}],2:[function(require,module,exports){
8
+ },{"./a_huge_library":"__RAILS_ROOT__/app/assets/javascripts/a_huge_library.js"}],"__RAILS_ROOT__/app/assets/javascripts/a_huge_library.js":[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
@@ -21,4 +21,4 @@ module.exports = function() {
21
21
 
22
22
  module.exports = "THIS IS A HUGE LIBRARY";
23
23
 
24
- },{}]},{},[1]);
24
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -1,4 +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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  (function() {
3
3
  var f, hello;
4
4
 
@@ -10,11 +10,11 @@
10
10
 
11
11
  }).call(this);
12
12
 
13
- },{"./foo":2}],2:[function(require,module,exports){
13
+ },{"./foo":"__RAILS_ROOT__/app/assets/javascripts/foo.js"}],"__RAILS_ROOT__/app/assets/javascripts/foo.js":[function(require,module,exports){
14
14
  require('./nested');
15
15
  module.exports = function (n) { return n * 11 }
16
16
 
17
- },{"./nested":3}],3:[function(require,module,exports){
17
+ },{"./nested":"__RAILS_ROOT__/app/assets/javascripts/nested/index.js"}],"__RAILS_ROOT__/app/assets/javascripts/nested/index.js":[function(require,module,exports){
18
18
  module.exports.NESTED = true;
19
19
 
20
- },{}]},{},[1]);
20
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -1,9 +1,9 @@
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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var answer = require('some_folder/answer');
3
3
 
4
4
  console.log('answer', answer);
5
5
 
6
- },{"some_folder/answer":2}],2:[function(require,module,exports){
6
+ },{"some_folder/answer":"__RAILS_ROOT__/app/assets/javascripts/some_folder/answer.js"}],"__RAILS_ROOT__/app/assets/javascripts/some_folder/answer.js":[function(require,module,exports){
7
7
  module.exports = 42;
8
8
 
9
- },{}]},{},[1]);
9
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -1,11 +1,11 @@
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){
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})({"__RAILS_ROOT__/app/assets/javascripts/_stream_0.js":[function(require,module,exports){
2
2
  var library = require('./a_huge_library');
3
3
 
4
4
  module.exports = function() {
5
5
  console.log('some problem', library);
6
6
  };
7
7
 
8
- },{"./a_huge_library":"/a_huge_library"}],2:[function(require,module,exports){
8
+ },{"./a_huge_library":"/a_huge_library"}],"__RAILS_ROOT__/app/assets/javascripts/a_huge_library.js":[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
@@ -21,4 +21,4 @@ module.exports = function() {
21
21
 
22
22
  module.exports = "THIS IS A HUGE LIBRARY";
23
23
 
24
- },{}]},{},[1]);
24
+ },{}]},{},["__RAILS_ROOT__/app/assets/javascripts/_stream_0.js"]);
@@ -16,7 +16,8 @@ FileUtils.rm_rf "#{File.dirname(__FILE__)}/dummy/tmp"
16
16
  ActiveSupport::TestCase.class_eval do
17
17
  def fixture(filename)
18
18
  File.open(File.join(File.dirname(__FILE__), "fixtures", filename)) do |f|
19
- f.read.strip
19
+ contents = f.read.strip
20
+ contents.gsub(/__RAILS_ROOT__/, Rails.root.to_s) if contents
20
21
  end
21
22
  end
22
23
  end
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.6.0
4
+ version: 0.7.1
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-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets