browserify-rails 4.2.0 → 4.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 07cd114f351548db3e2885f6c99e879aa66ea0c1
4
- data.tar.gz: 9a2718ea91ac7dc5e031570bc6da6ae190875cc1
2
+ SHA256:
3
+ metadata.gz: cad940efd5616a2cd49abc09b559bee472df4ded7c308a21975a2a265b01b74a
4
+ data.tar.gz: 7bbdcb45126644fdf62358154f1b5bd04712e5ed01caefbc6555500991b1bef6
5
5
  SHA512:
6
- metadata.gz: e2604d3a6029a830190bd0806c7b3cd926766508d4729553d9a6a054b1c98b66332a4ff3d03b9527281d5c6f13f09ee2c11d699c6245b0e6d742682e3051b402
7
- data.tar.gz: 8659b908bfb1a4b72c57c89680c43587e94fe043be1ca36edc9d8725140e43fd71ff8ceba600ddfd346cc542391d5be8db91d11147b7b9ca6be414f56b08fdd0
6
+ metadata.gz: 6b1be15ad5163e9657e6708134ca7420fbc8b7cad8b4697965424a0d92ced3d639f4cbcb0803fa75e06a32a3c3d542c7a4ecf97f421c308a5440fe4c120ff711
7
+ data.tar.gz: 40ace03ac65f0a529925fda364c029046b53347baaf3ada01dd69a2795cc945d1da8e5b59390087a07c406f19a9b27f539e42b173afcea9333c853389764173c
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file going forward.
3
3
 
4
+ ## [4.4.0] - 2020-05-16
5
+ - sprockets 4 support thanks to dkamenka
6
+ - fix tests
7
+
8
+ ## [4.3.0] - 2018-04-17
9
+ - release 4.3.0.pre as 4.3.0 unchanged
10
+
11
+ ## [4.3.0.pre] - 2018-04-12
12
+ - relax railties requirement to not have an upper limit
13
+
4
14
  ## [4.2.0] - 2017-04-28
5
15
  - relax railties requirement to < 5.2
6
16
 
data/README.md CHANGED
@@ -16,6 +16,34 @@ It lets you mix and match `//= require` directives and `require()` calls for in
16
16
  6. Require modules relative to asset paths (ie app/assets/javascript) with non-relative syntax (see below before using)
17
17
  7. Configure browserify options for each JavaScript file so you can mark modules with `--require`, `--external`, etc
18
18
 
19
+ ## Should you use this gem?
20
+
21
+ As the primary developer, I'm going to offer some opiniated advice. The sweet spot for this
22
+ gem is for Rails projects with legacy JavaScript (not using CommonJS/modules). This gem is
23
+ a great way to make it possible to rewrite that legacy JavaScript to CommonJS on a timeline
24
+ that you dictate. Then consider stepping off the Rails asset pipeline or using another gem.
25
+
26
+ If you're starting a new Rails project today, I highly recommend looking at alternatives to
27
+ this gem. The primary reason is that this gem, while it works well, is not as efficient as
28
+ most would like for local development. Also a lot has changed over the last couple of years.
29
+
30
+ An example of that change is this project from Rails:
31
+
32
+ [rails/webpacker](https://github.com/rails/webpacker)
33
+
34
+ This is a huge step in the right direction for the Rails community. In the past, it has been
35
+ extremely frustrating working with JavaScript on the asset pipeline. The good news is you have a lot
36
+ of great choices. If I were starting a new Rails project today, I think the safest choice is
37
+ one in which you have a [Procfile](https://mattstauffer.co/blog/using-a-procfile-to-streamline-your-local-development) that kicks off a separate Webpack build and you use zero
38
+ Rails magic. A slightly less safe but maybe more convenient choice would be trying rails/webpacker
39
+ or another gem. The choice is yours.
40
+
41
+
42
+ For more discussion on this topic, see issues
43
+ [203](https://github.com/browserify-rails/browserify-rails/issues/203),
44
+ [161](https://github.com/browserify-rails/browserify-rails/issues/161),
45
+ [43](https://github.com/browserify-rails/browserify-rails/issues/43), etc.
46
+
19
47
  ## Getting Started
20
48
 
21
49
  Add this line to your application's Gemfile:
@@ -235,13 +263,29 @@ buildpacks that run `bundle` and `npm install` on the target machine.
235
263
 
236
264
  ## Using Browserify Transforms
237
265
 
238
- You can easily use a browserify transform by adding it to your `package.json`, then adding the transform flag to your `application.rb`, using `config.browserify_rails.commandline_options`. For example, here is how you can add ES6 support in your app:
266
+ You can easily use a browserify transform by making some additions to your `package.json` and creating a .babelrc. For example, here is how you can add ES6 support in your app:
239
267
 
240
- 1. Add `babelify` and `babel-preset-es2015` to your `package.json` in your app's root directory, then run `npm install`
241
- 2. Add this line to your config/application.rb:
242
- `config.browserify_rails.commandline_options = "-t [ babelify --presets [ es2015 ] --extensions .es6 ]"`
243
- 3. Create some `.es6` files and require them with `var m = require('./m.es6')` or `import m from './m.es6'`
244
- 4. Restart your server, and you now have ES6 support!
268
+ 1. Add `babelify` and `babel-preset-es2015` to your `package.json` in your app's root directory either by editing the file directly and running `npm install` or using `npm install babelify --save` and `npm install babel-preset-es2015 --save`
269
+ 2. Update your `package.json` to contain the babelify transform by adding the following lines
270
+ ```
271
+ "browserify": {
272
+ "transform": [
273
+ [
274
+ "babelify"
275
+ ]
276
+ ]
277
+ }
278
+ ```
279
+ 3. Create a `.babelrc` file in the project root with the following contents
280
+ ```
281
+ {
282
+ "plugins": [],
283
+ "presets": ["es2015"]
284
+ }
285
+ ```
286
+
287
+ 4. Create some `.es6` files and require them with `var m = require('./m.es6')` or `import m from './m.es6'`
288
+ 5. Restart your server, and you now have ES6 support!
245
289
 
246
290
 
247
291
  ## Troubleshooting
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
 
22
- spec.add_runtime_dependency "railties", ">= 4.0.0", "< 5.2"
22
+ spec.add_runtime_dependency "railties", ">= 4.0.0"
23
23
  spec.add_runtime_dependency "sprockets", ">= 3.6.0"
24
24
  spec.add_runtime_dependency "addressable", ">= 2.4.0"
25
25
 
@@ -41,12 +41,12 @@ module BrowserifyRails
41
41
  resolved = input[:environment].resolve(path)
42
42
 
43
43
  if resolved && resolved.is_a?(Array)
44
- resolved = resolved[0]
45
- elsif config.evaluate_node_modules && !resolved
46
- resolved = path
44
+ dependencies += resolved[1]
45
+ elsif resolved
46
+ dependencies << "file-digest://#{Addressable::URI.escape resolved}"
47
+ elsif config.evaluate_node_modules
48
+ dependencies << "file-digest://#{Addressable::URI.escape path}"
47
49
  end
48
-
49
- dependencies << "file-digest://#{Addressable::URI.escape resolved}" if resolved
50
50
  end
51
51
 
52
52
  new_data = run_browserify(input[:name])
@@ -1,3 +1,3 @@
1
1
  module BrowserifyRails
2
- VERSION = "4.2.0"
2
+ VERSION = "4.4.0"
3
3
  end
@@ -182,6 +182,7 @@ class BrowserifyTest < ActionDispatch::IntegrationTest
182
182
  get "/assets/node_path_based_require.js"
183
183
 
184
184
  assert_response :success
185
+
185
186
  assert_equal expected_output, @response.body.strip
186
187
  assert_equal false, @response.body.include?("Error: Cannot find module 'some_folder/answer'")
187
188
  end
@@ -0,0 +1 @@
1
+ {}