browserify-rails 0.3.1 → 0.4.1
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 +13 -5
- data/.gitignore +1 -0
- data/README.md +90 -4
- data/browserify-rails.gemspec +3 -3
- data/lib/browserify-rails.rb +1 -0
- data/lib/browserify-rails/browserify_logger.rb +10 -0
- data/lib/browserify-rails/browserify_processor.rb +33 -7
- data/lib/browserify-rails/railtie.rb +5 -0
- data/lib/browserify-rails/version.rb +1 -1
- data/test/compilation_test.rb +47 -5
- data/test/dummy/app/assets/javascripts/a_huge_library.js.example +14 -0
- data/test/dummy/app/assets/javascripts/app_a_huge_library.js.example +14 -0
- data/test/dummy/app/assets/javascripts/app_main.js.example +5 -0
- data/test/dummy/app/assets/javascripts/app_secondary.js.example +5 -0
- data/test/dummy/app/assets/javascripts/main.js.example +5 -0
- data/test/dummy/app/assets/javascripts/node.js.example +3 -0
- data/test/dummy/app/assets/javascripts/node_path_based_require.js.example +3 -0
- data/test/dummy/app/assets/javascripts/secondary.js.example +5 -0
- data/test/dummy/app/assets/javascripts/some_folder/answer.js.example +1 -0
- data/test/dummy/config/browserify.yml +7 -0
- data/test/fixtures/main.out.js +26 -0
- data/test/fixtures/node_path_based_require.out.js +9 -0
- data/test/fixtures/secondary.out.js +8 -0
- metadata +51 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
MzQ3ZTNjN2UxMGQ3NzE2MzBkNGMzOTExNDZhN2NmMTY0ZDM0ZTQ2OQ==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
MWI0YWIwN2I0YzQxZmZlMGI2MGU1NzE2OWQzMjk2YjkyNTExOGNmNg==
|
|
5
7
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MjE2Y2FmOGY1ZTg3ODIyZGY4YTQyYWNhNzI3YWQ1NzAyNTAyODZiZjIyZGJm
|
|
10
|
+
NGRjNGY5N2Q4YWFiZjJiYWQ2MWFiODYxOThjNjkyMDZlYzAxYmVhYjcxZTRj
|
|
11
|
+
YmExZGUxMjM1MzJkYTYwYTJjYzcyM2Y1ZTA1OWVmODM4NWE1OTc=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
M2E2OWM5NTVlZDY0YWVmZjkyODU1NTRjMWFjZDg1YjllNjhkNTc1ZTViYWJi
|
|
14
|
+
MTM3MjhkYjUyYjhlZmIxMGE1ZmNlNjQ5ODhlODg0NzBjYjQyNjA5M2E2N2Qw
|
|
15
|
+
YjYxZWIwYjg2ZTA4ZjMyNDI0MTkzNjE0MmE3ZDIzNjYwZTA5OTQ=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# browserify-rails
|
|
2
|
-
|
|
3
|
-
[](https://travis-ci.org/hsume2/browserify-rails)
|
|
2
|
+
[](https://travis-ci.org/browserify-rails/browserify-rails)
|
|
4
3
|
|
|
5
4
|
This library adds CommonJS module support to Sprockets (via Browserify).
|
|
6
5
|
|
|
@@ -11,12 +10,14 @@ It let's you mix and match `//= require` directives and `require()` calls for i
|
|
|
11
10
|
3. Require modules with `require()` (without separate `//= require` directives)
|
|
12
11
|
4. Only build required modules
|
|
13
12
|
5. Require *npm modules* in your Rails assets
|
|
13
|
+
6. Require modules relative to asset paths (ie app/assets/javascript) with non-relative syntax (see below before using)
|
|
14
|
+
7. Configure browserify options for each JavaScript file so you can mark modules with `--require`, `--external`, etc
|
|
14
15
|
|
|
15
16
|
## Getting Started
|
|
16
17
|
|
|
17
18
|
Add this line to your application's Gemfile:
|
|
18
19
|
|
|
19
|
-
gem "browserify-rails", "~> 0.
|
|
20
|
+
gem "browserify-rails", "~> 0.4"
|
|
20
21
|
|
|
21
22
|
Create `package.json` in your Rails root:
|
|
22
23
|
|
|
@@ -71,8 +72,14 @@ Add the following command line options within `application.rb`:
|
|
|
71
72
|
config.browserify_rails.commandline_options = "-t coffeeify --extension=\".js.coffee\""
|
|
72
73
|
```
|
|
73
74
|
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
* node-browserify 4.x
|
|
78
|
+
|
|
74
79
|
## Configuration
|
|
75
80
|
|
|
81
|
+
### Global configuration
|
|
82
|
+
|
|
76
83
|
You can configure different options of browserify-rails by adding one of lines
|
|
77
84
|
mentioned below into your `config/application.rb` or your environment file
|
|
78
85
|
(`config/environments/*.rb`):
|
|
@@ -102,9 +109,87 @@ class My::Application < Rails::Application
|
|
|
102
109
|
config.browserify_rails.commandline_options = "-t browserify-shim --fast"
|
|
103
110
|
```
|
|
104
111
|
|
|
112
|
+
### Multiple bundles
|
|
113
|
+
|
|
114
|
+
node-browserify supports [multiple bundles](https://github.com/substack/node-browserify#multiple-bundles)
|
|
115
|
+
and so do does rails-browserify. It does this using `config/browserify.yml`.
|
|
116
|
+
Below is an example.
|
|
117
|
+
|
|
118
|
+
Say you have three JavaScript files and one is a huge library you would like to
|
|
119
|
+
use in both. Browserify lets you mark that huge library with --require in one
|
|
120
|
+
file (to both bundle it and mark it with a special internal ID) and then
|
|
121
|
+
require it in the other file and mark it with --external (so it is not bundled
|
|
122
|
+
into the file but instead accessed via browserify internals using that special
|
|
123
|
+
ID). Note that this only works when the file that has the library bundled is
|
|
124
|
+
loaded before the file that uses the library with --external.
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
javascript:
|
|
128
|
+
main:
|
|
129
|
+
require:
|
|
130
|
+
- a_huge_library
|
|
131
|
+
secondary:
|
|
132
|
+
external:
|
|
133
|
+
- a_huge_library
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Note that any valid browserify option is allowed in the YAML file but not
|
|
137
|
+
use cases have been considered. If your use case does not work, please open
|
|
138
|
+
an issue with a runnable example of the problem including your
|
|
139
|
+
browserify.yml file.
|
|
140
|
+
|
|
141
|
+
## Support for rails asset directories as non-relative module sources
|
|
142
|
+
|
|
143
|
+
In the Rails asset pipeline, it is common to have files in
|
|
144
|
+
`app/assets/javascripts` and being able to do `//= require some_file` which
|
|
145
|
+
exists in one of the asset/javascript directories. In some cases, it is
|
|
146
|
+
useful to have similar functionality with browserify. This has been added
|
|
147
|
+
by putting the Rails asset paths into NODE_PATH environment variable when
|
|
148
|
+
running browserify.
|
|
149
|
+
|
|
150
|
+
But this comes at a large cost: right now, it appears to break source maps.
|
|
151
|
+
This might be a bug or a fixable breakage but it hasn't been solved yet. The
|
|
152
|
+
use of NODE_PATH is also contentious in the NodeJS community.
|
|
153
|
+
|
|
154
|
+
Why leave it in? Because some typical Rails components break without it.
|
|
155
|
+
For example, jasmine-rails expects to be able to move JavaScript to
|
|
156
|
+
different depths. So if you do a relative require from spec/javascript to
|
|
157
|
+
app/assets/javascripts, your tests will fail to run when RAILS_ENV=test.
|
|
158
|
+
|
|
159
|
+
So if you really need this, use it. But if you really need it for files that
|
|
160
|
+
are not tests, you should definitely figure out an alternative. Support
|
|
161
|
+
for this may go away if we cannot fix the issue(s) with source maps being
|
|
162
|
+
invalid.
|
|
163
|
+
|
|
164
|
+
## Troubleshooting
|
|
165
|
+
|
|
166
|
+
### Clear the asset pipeline cache
|
|
167
|
+
|
|
168
|
+
The Rails asset pipeline caches some files in the `tmp` directory off of
|
|
169
|
+
Rails root. It can happen that sometimes the cache does not get invalidated
|
|
170
|
+
correctly. You can manually clear the cache in at least two ways:
|
|
171
|
+
|
|
172
|
+
1. `rake tmp:cache:clear`
|
|
173
|
+
2. `rm -rf ./tmp` (when in the root directory of the Rails project)
|
|
174
|
+
|
|
175
|
+
The second method is definitely brute force but if you experience issues,
|
|
176
|
+
it is definitely worth trying before spending too much time debugging
|
|
177
|
+
why something that is browserified appears to not match the sources files.
|
|
178
|
+
|
|
105
179
|
## Contributing
|
|
106
180
|
|
|
107
|
-
Pull requests appreciated.
|
|
181
|
+
Pull requests appreciated. Pull requests will not be rejected based on
|
|
182
|
+
ideological neurosis of either the NodeJS or the Ruby on Rails communities.
|
|
183
|
+
In other words, technical needs are respected.
|
|
184
|
+
|
|
185
|
+
## Potential areas of change (contributions welcome)
|
|
186
|
+
|
|
187
|
+
### Multiple modules
|
|
188
|
+
|
|
189
|
+
Often one has one main module (say a library module) and other modules that
|
|
190
|
+
consume the main module. It would be nice to be able to establish this
|
|
191
|
+
relationship in the YAML file to avoid having to manually manage the require
|
|
192
|
+
and external entries for the involved modules.
|
|
108
193
|
|
|
109
194
|
## Contributors
|
|
110
195
|
|
|
@@ -112,3 +197,4 @@ Pull requests appreciated.
|
|
|
112
197
|
* [Cássio Souza](https://github.com/cassiozen)
|
|
113
198
|
* [Marten Lienen](https://github.com/CQQL)
|
|
114
199
|
* [Lukasz Sagol](https://github.com/zgryw)
|
|
200
|
+
* [Cymen Vig](https://github.com/cymen)
|
data/browserify-rails.gemspec
CHANGED
|
@@ -6,11 +6,11 @@ require 'browserify-rails/version'
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "browserify-rails"
|
|
8
8
|
spec.version = BrowserifyRails::VERSION
|
|
9
|
-
spec.authors = ["Henry Hsu"]
|
|
10
|
-
spec.email = ["hhsu@zendesk.com"]
|
|
9
|
+
spec.authors = ["Henry Hsu, Cymen Vig"]
|
|
10
|
+
spec.email = ["hhsu@zendesk.com, cymenvig@gmail.com"]
|
|
11
11
|
spec.description = %q{Browserify + Rails = CommonJS Heaven}
|
|
12
12
|
spec.summary = %q{Get the best of both worlds: Browserify + Rails = CommonJS Heaven}
|
|
13
|
-
spec.homepage = ""
|
|
13
|
+
spec.homepage = "https://github.com/browserify-rails/browserify-rails"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/browserify-rails.rb
CHANGED
|
@@ -5,6 +5,7 @@ module BrowserifyRails
|
|
|
5
5
|
BROWSERIFY_CMD = "./node_modules/.bin/browserify".freeze
|
|
6
6
|
|
|
7
7
|
def prepare
|
|
8
|
+
@config = Rails.application.config.browserify_rails_granular
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
def evaluate(context, locals, &block)
|
|
@@ -13,7 +14,7 @@ module BrowserifyRails
|
|
|
13
14
|
context.depend_on(path)
|
|
14
15
|
end
|
|
15
16
|
|
|
16
|
-
browserify
|
|
17
|
+
browserify context.logical_path
|
|
17
18
|
else
|
|
18
19
|
data
|
|
19
20
|
end
|
|
@@ -21,6 +22,18 @@ module BrowserifyRails
|
|
|
21
22
|
|
|
22
23
|
private
|
|
23
24
|
|
|
25
|
+
def asset_paths
|
|
26
|
+
@asset_paths ||= Rails.application.config.assets.paths.collect { |p| p.to_s }.join(":") || ""
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def has_config?(logical_path)
|
|
30
|
+
@config.has_key?("javascript") && @config["javascript"].has_key?(logical_path)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_config(logical_path)
|
|
34
|
+
@config["javascript"][logical_path] if @config.has_key?("javascript")
|
|
35
|
+
end
|
|
36
|
+
|
|
24
37
|
def should_browserify?
|
|
25
38
|
in_path? && commonjs_module?
|
|
26
39
|
end
|
|
@@ -57,8 +70,8 @@ module BrowserifyRails
|
|
|
57
70
|
end
|
|
58
71
|
end
|
|
59
72
|
|
|
60
|
-
def browserify
|
|
61
|
-
run_browserify(options)
|
|
73
|
+
def browserify(logical_path)
|
|
74
|
+
run_browserify(options, logical_path)
|
|
62
75
|
end
|
|
63
76
|
|
|
64
77
|
def browserify_cmd
|
|
@@ -83,11 +96,24 @@ module BrowserifyRails
|
|
|
83
96
|
# @raise [BrowserifyRails::BrowserifyError] if browserify does not succeed
|
|
84
97
|
# @param options [String] Options for browserify
|
|
85
98
|
# @return [String] Output on standard out
|
|
86
|
-
def run_browserify(options)
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
def run_browserify(options, logical_path=nil)
|
|
100
|
+
if has_config?(logical_path)
|
|
101
|
+
config = get_config logical_path
|
|
102
|
+
|
|
103
|
+
granular_options = config.keys.collect do |key|
|
|
104
|
+
config[key].collect { |value| "--#{key} #{value}" }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
options += " " + granular_options.join(" ")
|
|
108
|
+
end
|
|
109
|
+
|
|
89
110
|
directory = File.dirname(file)
|
|
90
|
-
|
|
111
|
+
command = "#{browserify_cmd} #{options} -"
|
|
112
|
+
Logger::log "Browserify: #{command}"
|
|
113
|
+
env = {
|
|
114
|
+
"NODE_PATH" => asset_paths
|
|
115
|
+
}
|
|
116
|
+
stdout, stderr, status = Open3.capture3(env, command, stdin_data: data, chdir: directory)
|
|
91
117
|
|
|
92
118
|
if !status.success?
|
|
93
119
|
raise BrowserifyRails::BrowserifyError.new("Error while running `#{command}`:\n\n#{stderr}")
|
|
@@ -10,6 +10,11 @@ module BrowserifyRails
|
|
|
10
10
|
config.browserify_rails.source_map_environments = ["development"]
|
|
11
11
|
|
|
12
12
|
initializer :setup_browserify do |app|
|
|
13
|
+
# Load granular configuration
|
|
14
|
+
filename = File.join(Rails.root, 'config', 'browserify.yml')
|
|
15
|
+
configuration = YAML::load(File.read(filename)) if File.exist? filename
|
|
16
|
+
config.browserify_rails_granular = configuration || {}
|
|
17
|
+
|
|
13
18
|
app.assets.register_postprocessor "application/javascript", BrowserifyRails::BrowserifyProcessor
|
|
14
19
|
end
|
|
15
20
|
|
data/test/compilation_test.rb
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
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$/, '')}")
|
|
7
|
+
|
|
8
|
+
FileUtils.cp(example_file, new_file)
|
|
9
|
+
end
|
|
10
|
+
|
|
4
11
|
setup do
|
|
5
12
|
Rails.application.assets.cache = nil
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
copy_example_file "application.js.example"
|
|
15
|
+
copy_example_file "foo.js.example"
|
|
16
|
+
copy_example_file "nested/index.js.example"
|
|
17
|
+
copy_example_file "mocha.js.coffee.example"
|
|
18
|
+
copy_example_file "coffee.js.coffee.example"
|
|
19
|
+
copy_example_file "node_path_based_require.js.example"
|
|
20
|
+
copy_example_file "main.js.example"
|
|
21
|
+
copy_example_file "secondary.js.example"
|
|
22
|
+
copy_example_file "a_huge_library.js.example"
|
|
23
|
+
copy_example_file "some_folder/answer.js.example"
|
|
12
24
|
end
|
|
13
25
|
|
|
14
26
|
test "asset pipeline should serve application.js" do
|
|
@@ -85,6 +97,36 @@ class BrowserifyTest < ActionController::IntegrationTest
|
|
|
85
97
|
assert_no_match /BrowserifyRails::BrowserifyError/, @response.body
|
|
86
98
|
end
|
|
87
99
|
|
|
100
|
+
test "uses NODE_PATH so files can be required non-relatively" do
|
|
101
|
+
expected_output = fixture("node_path_based_require.out.js")
|
|
102
|
+
|
|
103
|
+
get "/assets/node_path_based_require.js"
|
|
104
|
+
|
|
105
|
+
assert_response :success
|
|
106
|
+
assert_equal expected_output, @response.body.strip
|
|
107
|
+
assert_equal false, @response.body.include?("Error: Cannot find module 'some_folder/answer'")
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
test "uses config/browserify.yml to mark a module as globally available via --require" do
|
|
111
|
+
expected_output = fixture("main.out.js")
|
|
112
|
+
|
|
113
|
+
get "/assets/main.js"
|
|
114
|
+
|
|
115
|
+
assert_response :success
|
|
116
|
+
assert_equal expected_output, @response.body.strip
|
|
117
|
+
assert_equal true, @response.body.include?("ReMerY") # browserify internal global id for a_huge_library.js module
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
test "uses config/browserify.yml for browserification options" do
|
|
121
|
+
expected_output = fixture("secondary.out.js")
|
|
122
|
+
|
|
123
|
+
get "/assets/secondary.js"
|
|
124
|
+
|
|
125
|
+
assert_response :success
|
|
126
|
+
assert_equal expected_output, @response.body.strip
|
|
127
|
+
assert_equal true, @response.body.include?("ReMerY") # browserify internal global id for a_huge_library.js module
|
|
128
|
+
end
|
|
129
|
+
|
|
88
130
|
test "throws BrowserifyError if something went wrong while executing browserify" do
|
|
89
131
|
File.open(File.join(Rails.root, "app/assets/javascripts/application.js"), "w+") do |f|
|
|
90
132
|
f.puts "var foo = require('./foo');"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// pretend this file is 1 MB
|
|
2
|
+
//
|
|
3
|
+
// app_main.js is going to require() it and browserify.yml is going to tell it to use --require on it
|
|
4
|
+
//
|
|
5
|
+
// app_secondary.js is going to require() it too but we know app_main.js is always going to be loaded
|
|
6
|
+
// so browserify.yml will be configured to mark it as --external so it is not bundled in
|
|
7
|
+
//
|
|
8
|
+
// this results in app_main.js taking the cost of loading app_a_huge_library.js
|
|
9
|
+
//
|
|
10
|
+
// and app_secondary.js saving the cost of loading app_a_huge_library.js (because again,
|
|
11
|
+
// we know a priori that something else has loaded it)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
module.exports = "THIS IS A HUGE LIBRARY";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// pretend this file is 1 MB
|
|
2
|
+
//
|
|
3
|
+
// app_main.js is going to require() it and browserify.yml is going to tell it to use --require on it
|
|
4
|
+
//
|
|
5
|
+
// app_secondary.js is going to require() it too but we know app_main.js is always going to be loaded
|
|
6
|
+
// so browserify.yml will be configured to mark it as --external so it is not bundled in
|
|
7
|
+
//
|
|
8
|
+
// this results in app_main.js taking the cost of loading app_a_huge_library.js
|
|
9
|
+
//
|
|
10
|
+
// and app_secondary.js saving the cost of loading app_a_huge_library.js (because again,
|
|
11
|
+
// we know a priori that something else has loaded it)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
module.exports = "THIS IS A HUGE LIBRARY";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = 42;
|
|
@@ -0,0 +1,26 @@
|
|
|
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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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})({"a_huge_library":[function(require,module,exports){
|
|
2
|
+
module.exports=require('ReMerY');
|
|
3
|
+
},{}],"ReMerY":[function(require,module,exports){
|
|
4
|
+
// pretend this file is 1 MB
|
|
5
|
+
//
|
|
6
|
+
// app_main.js is going to require() it and browserify.yml is going to tell it to use --require on it
|
|
7
|
+
//
|
|
8
|
+
// app_secondary.js is going to require() it too but we know app_main.js is always going to be loaded
|
|
9
|
+
// so browserify.yml will be configured to mark it as --external so it is not bundled in
|
|
10
|
+
//
|
|
11
|
+
// this results in app_main.js taking the cost of loading app_a_huge_library.js
|
|
12
|
+
//
|
|
13
|
+
// and app_secondary.js saving the cost of loading app_a_huge_library.js (because again,
|
|
14
|
+
// we know a priori that something else has loaded it)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
module.exports = "THIS IS A HUGE LIBRARY";
|
|
18
|
+
|
|
19
|
+
},{}],3:[function(require,module,exports){
|
|
20
|
+
var library = require('./a_huge_library');
|
|
21
|
+
|
|
22
|
+
module.exports = function() {
|
|
23
|
+
console.log('library', library);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
},{"./a_huge_library":"ReMerY"}]},{},[3])
|
|
@@ -0,0 +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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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 answer = require('some_folder/answer');
|
|
3
|
+
|
|
4
|
+
console.log('answer', answer);
|
|
5
|
+
|
|
6
|
+
},{"some_folder/answer":2}],2:[function(require,module,exports){
|
|
7
|
+
module.exports = 42;
|
|
8
|
+
|
|
9
|
+
},{}]},{},[1])
|
|
@@ -0,0 +1,8 @@
|
|
|
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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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 library = require('./a_huge_library');
|
|
3
|
+
|
|
4
|
+
module.exports = function() {
|
|
5
|
+
console.log('some problem', library);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
},{"./a_huge_library":"ReMerY"}]},{},[1])
|
metadata
CHANGED
|
@@ -1,122 +1,122 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: browserify-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Henry Hsu
|
|
7
|
+
- Henry Hsu, Cymen Vig
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-07-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sprockets
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ~>
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '2.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - ~>
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '2.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ~>
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '1.3'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ~>
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '1.3'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ! '>='
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ! '>='
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rails
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ~>
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '3.2'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ~>
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '3.2'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: coffee-rails
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
73
|
+
- - ! '>='
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- -
|
|
80
|
+
- - ! '>='
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: mocha
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
|
-
- -
|
|
87
|
+
- - ! '>='
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: '0'
|
|
90
90
|
type: :development
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
|
-
- -
|
|
94
|
+
- - ! '>='
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: pry
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
|
-
- -
|
|
101
|
+
- - ! '>='
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
103
|
version: '0'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
|
-
- -
|
|
108
|
+
- - ! '>='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
description: Browserify + Rails = CommonJS Heaven
|
|
112
112
|
email:
|
|
113
|
-
- hhsu@zendesk.com
|
|
113
|
+
- hhsu@zendesk.com, cymenvig@gmail.com
|
|
114
114
|
executables: []
|
|
115
115
|
extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
|
117
117
|
files:
|
|
118
|
-
-
|
|
119
|
-
-
|
|
118
|
+
- .gitignore
|
|
119
|
+
- .travis.yml
|
|
120
120
|
- Gemfile
|
|
121
121
|
- LICENSE.txt
|
|
122
122
|
- README.md
|
|
@@ -124,6 +124,7 @@ files:
|
|
|
124
124
|
- browserify-rails.gemspec
|
|
125
125
|
- lib/browserify-rails.rb
|
|
126
126
|
- lib/browserify-rails/browserify_error.rb
|
|
127
|
+
- lib/browserify-rails/browserify_logger.rb
|
|
127
128
|
- lib/browserify-rails/browserify_processor.rb
|
|
128
129
|
- lib/browserify-rails/railtie.rb
|
|
129
130
|
- lib/browserify-rails/tasks/npm.rake
|
|
@@ -131,11 +132,20 @@ files:
|
|
|
131
132
|
- test/browserify_processor_test.rb
|
|
132
133
|
- test/compilation_test.rb
|
|
133
134
|
- test/dummy/Rakefile
|
|
135
|
+
- test/dummy/app/assets/javascripts/a_huge_library.js.example
|
|
136
|
+
- test/dummy/app/assets/javascripts/app_a_huge_library.js.example
|
|
137
|
+
- test/dummy/app/assets/javascripts/app_main.js.example
|
|
138
|
+
- test/dummy/app/assets/javascripts/app_secondary.js.example
|
|
134
139
|
- test/dummy/app/assets/javascripts/application.js.example
|
|
135
140
|
- test/dummy/app/assets/javascripts/coffee.js.coffee.example
|
|
136
141
|
- test/dummy/app/assets/javascripts/foo.js.example
|
|
142
|
+
- test/dummy/app/assets/javascripts/main.js.example
|
|
137
143
|
- test/dummy/app/assets/javascripts/mocha.js.coffee.example
|
|
138
144
|
- test/dummy/app/assets/javascripts/nested/index.js.example
|
|
145
|
+
- test/dummy/app/assets/javascripts/node.js.example
|
|
146
|
+
- test/dummy/app/assets/javascripts/node_path_based_require.js.example
|
|
147
|
+
- test/dummy/app/assets/javascripts/secondary.js.example
|
|
148
|
+
- test/dummy/app/assets/javascripts/some_folder/answer.js.example
|
|
139
149
|
- test/dummy/app/assets/stylesheets/application.css
|
|
140
150
|
- test/dummy/app/controllers/application_controller.rb
|
|
141
151
|
- test/dummy/app/controllers/home_controller.rb
|
|
@@ -148,6 +158,7 @@ files:
|
|
|
148
158
|
- test/dummy/config.ru
|
|
149
159
|
- test/dummy/config/application.rb
|
|
150
160
|
- test/dummy/config/boot.rb
|
|
161
|
+
- test/dummy/config/browserify.yml
|
|
151
162
|
- test/dummy/config/database.yml
|
|
152
163
|
- test/dummy/config/environment.rb
|
|
153
164
|
- test/dummy/config/environments/development.rb
|
|
@@ -172,9 +183,12 @@ files:
|
|
|
172
183
|
- test/fixtures/application.out.js
|
|
173
184
|
- test/fixtures/empty_module.js
|
|
174
185
|
- test/fixtures/foo.out.js
|
|
186
|
+
- test/fixtures/main.out.js
|
|
175
187
|
- test/fixtures/mocha.js
|
|
188
|
+
- test/fixtures/node_path_based_require.out.js
|
|
189
|
+
- test/fixtures/secondary.out.js
|
|
176
190
|
- test/test_helper.rb
|
|
177
|
-
homepage:
|
|
191
|
+
homepage: https://github.com/browserify-rails/browserify-rails
|
|
178
192
|
licenses:
|
|
179
193
|
- MIT
|
|
180
194
|
metadata: {}
|
|
@@ -184,12 +198,12 @@ require_paths:
|
|
|
184
198
|
- lib
|
|
185
199
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
200
|
requirements:
|
|
187
|
-
- -
|
|
201
|
+
- - ! '>='
|
|
188
202
|
- !ruby/object:Gem::Version
|
|
189
203
|
version: '0'
|
|
190
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
205
|
requirements:
|
|
192
|
-
- -
|
|
206
|
+
- - ! '>='
|
|
193
207
|
- !ruby/object:Gem::Version
|
|
194
208
|
version: '0'
|
|
195
209
|
requirements: []
|
|
@@ -197,16 +211,25 @@ rubyforge_project:
|
|
|
197
211
|
rubygems_version: 2.2.2
|
|
198
212
|
signing_key:
|
|
199
213
|
specification_version: 4
|
|
200
|
-
summary: 'Get the best of both worlds: Browserify + Rails = CommonJS Heaven'
|
|
214
|
+
summary: ! 'Get the best of both worlds: Browserify + Rails = CommonJS Heaven'
|
|
201
215
|
test_files:
|
|
202
216
|
- test/browserify_processor_test.rb
|
|
203
217
|
- test/compilation_test.rb
|
|
204
218
|
- test/dummy/Rakefile
|
|
219
|
+
- test/dummy/app/assets/javascripts/a_huge_library.js.example
|
|
220
|
+
- test/dummy/app/assets/javascripts/app_a_huge_library.js.example
|
|
221
|
+
- test/dummy/app/assets/javascripts/app_main.js.example
|
|
222
|
+
- test/dummy/app/assets/javascripts/app_secondary.js.example
|
|
205
223
|
- test/dummy/app/assets/javascripts/application.js.example
|
|
206
224
|
- test/dummy/app/assets/javascripts/coffee.js.coffee.example
|
|
207
225
|
- test/dummy/app/assets/javascripts/foo.js.example
|
|
226
|
+
- test/dummy/app/assets/javascripts/main.js.example
|
|
208
227
|
- test/dummy/app/assets/javascripts/mocha.js.coffee.example
|
|
209
228
|
- test/dummy/app/assets/javascripts/nested/index.js.example
|
|
229
|
+
- test/dummy/app/assets/javascripts/node.js.example
|
|
230
|
+
- test/dummy/app/assets/javascripts/node_path_based_require.js.example
|
|
231
|
+
- test/dummy/app/assets/javascripts/secondary.js.example
|
|
232
|
+
- test/dummy/app/assets/javascripts/some_folder/answer.js.example
|
|
210
233
|
- test/dummy/app/assets/stylesheets/application.css
|
|
211
234
|
- test/dummy/app/controllers/application_controller.rb
|
|
212
235
|
- test/dummy/app/controllers/home_controller.rb
|
|
@@ -219,6 +242,7 @@ test_files:
|
|
|
219
242
|
- test/dummy/config.ru
|
|
220
243
|
- test/dummy/config/application.rb
|
|
221
244
|
- test/dummy/config/boot.rb
|
|
245
|
+
- test/dummy/config/browserify.yml
|
|
222
246
|
- test/dummy/config/database.yml
|
|
223
247
|
- test/dummy/config/environment.rb
|
|
224
248
|
- test/dummy/config/environments/development.rb
|
|
@@ -243,5 +267,8 @@ test_files:
|
|
|
243
267
|
- test/fixtures/application.out.js
|
|
244
268
|
- test/fixtures/empty_module.js
|
|
245
269
|
- test/fixtures/foo.out.js
|
|
270
|
+
- test/fixtures/main.out.js
|
|
246
271
|
- test/fixtures/mocha.js
|
|
272
|
+
- test/fixtures/node_path_based_require.out.js
|
|
273
|
+
- test/fixtures/secondary.out.js
|
|
247
274
|
- test/test_helper.rb
|