browserify-rails 4.2.0 → 4.3.0.pre
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 +5 -5
- data/README.md +50 -6
- data/browserify-rails.gemspec +1 -1
- data/lib/browserify-rails/version.rb +1 -1
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6d886271d9cfbb4d0293353f90df8efc7949115392ec093b2b96bd4b0ba68a6
|
4
|
+
data.tar.gz: 05c2bc76779bf591569d6d4bde8859bb0e5e991fbf08e24a3d58cb2781446638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 883bd9fb5edc85e1ee24a76c1f51071a3037d4d91f16f249b014289c3ecabec31260a76d419f1768f1692c9b7951f108b6c78e7c780fbe260f018246f9679aff
|
7
|
+
data.tar.gz: 5aa6d88fe1b52843f75f5c059cd2820616fb7820fdc00676ef809b2f7c97561f7231f09c74f5a3c49ded540d85273fc56d6c822155d48af0ae42b307dfd34e81
|
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
|
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
|
241
|
-
2.
|
242
|
-
|
243
|
-
|
244
|
-
|
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
|
data/browserify-rails.gemspec
CHANGED
@@ -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"
|
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
|
|
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: 4.
|
4
|
+
version: 4.3.0.pre
|
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:
|
11
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.0.0
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5.2'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 4.0.0
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5.2'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: sprockets
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -264,12 +258,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
264
258
|
version: '0'
|
265
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
260
|
requirements:
|
267
|
-
- - "
|
261
|
+
- - ">"
|
268
262
|
- !ruby/object:Gem::Version
|
269
|
-
version:
|
263
|
+
version: 1.3.1
|
270
264
|
requirements: []
|
271
265
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.6
|
266
|
+
rubygems_version: 2.7.6
|
273
267
|
signing_key:
|
274
268
|
specification_version: 4
|
275
269
|
summary: 'Get the best of both worlds: Browserify + Rails = CommonJS Heaven'
|