webpacker 3.2.1 → 3.2.2

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: 5a54f5131894092cf3a3c2176cca4c3d2d99cb10
4
- data.tar.gz: 82eb7c75ef0ce343c7e8bb8b66efffb92d9ba252
2
+ SHA256:
3
+ metadata.gz: c15a75f6c29cc05aae6839309adee7e0db2b51ef63976992e03b1d684e703b70
4
+ data.tar.gz: c02f95838b9f7ca24c178053eeae3eed75523c72a17276e18a1b0b93b4be90c1
5
5
  SHA512:
6
- metadata.gz: '088e85d9e4d9534b51b55ec1c69db1cbee256ac5d965c8b49ce2d9f1a1c92ccf17ef22432e58ac52ffb78629aa2708429e5ad39e0277a4917ec9412242ed64af'
7
- data.tar.gz: fdeab469b4ce1d04d34f7a33a810c286c0783ff69f1c8e95d4f7664fea6f9f02e0b67c4bb0b71db76e2732c42d1ba8afa8c8ea9234dd69ea76671c706fb4600e
6
+ metadata.gz: 79e537a4b5ef7e67da86b59cf3a74c7182b79cd3787285fe06032b2a2d2c0a5fba8b35961caba36e125ffc65d17641eb331fe2d63baee59724efc9e4c0d849da
7
+ data.tar.gz: 2905386f28390de59651c450c08cad42bcaadc35e2e59ff92ee7e310c9d85aeadf2a208f4634d29896fb749e4e4a1ac3e4fd28a80905315acd6da0d43067c2d5
@@ -1,11 +1,11 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  before_install:
4
- - gem update --system
4
+ - gem update --system
5
5
  rvm:
6
- - 2.2.8
7
- - 2.3.5
8
- - 2.4.2
6
+ - 2.2.9
7
+ - 2.3.6
8
+ - 2.4.3
9
9
  - 2.5.0
10
10
  - ruby-head
11
11
  gemfile:
@@ -1,5 +1,19 @@
1
1
  **Please note that Webpacker 3.1.0 and 3.1.1 has some serious bugs so please consider using either 3.0.2 or 3.2.0**
2
2
 
3
+ ## [3.2.2] - 2018-02-11
4
+
5
+ ### Added
6
+
7
+ - Stimulus example [https://stimulusjs.org/](https://stimulusjs.org/)
8
+
9
+ ```bash
10
+ bundle exec rails webpacker:install:stimulus
11
+ ```
12
+
13
+ - Upgrade gems and npm packages [#1254](https://github.com/rails/webpacker/pull/1254)
14
+
15
+ And, bunch of bug fixes [See changes](https://github.com/rails/webpacker/compare/v3.2.1...3.2.2)
16
+
3
17
  ## [3.2.1] - 2018-01-21
4
18
 
5
19
  - Disable dev server running? check if no dev server config is present in that environment [#1179](https://github.com/rails/webpacker/pull/1179)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker (3.2.1)
4
+ webpacker (3.2.2)
5
5
  activesupport (>= 4.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 4.2)
@@ -47,15 +47,15 @@ GEM
47
47
  minitest (~> 5.1)
48
48
  tzinfo (~> 1.1)
49
49
  arel (8.0.0)
50
- ast (2.3.0)
50
+ ast (2.4.0)
51
51
  builder (3.2.3)
52
- byebug (9.1.0)
52
+ byebug (10.0.0)
53
53
  concurrent-ruby (1.0.5)
54
54
  crass (1.0.3)
55
55
  erubi (1.7.0)
56
56
  globalid (0.4.1)
57
57
  activesupport (>= 4.2.0)
58
- i18n (0.9.1)
58
+ i18n (0.9.3)
59
59
  concurrent-ruby (~> 1.0)
60
60
  loofah (2.1.1)
61
61
  crass (~> 1.0.2)
@@ -65,15 +65,15 @@ GEM
65
65
  method_source (0.9.0)
66
66
  mini_mime (1.0.0)
67
67
  mini_portile2 (2.3.0)
68
- minitest (5.11.1)
68
+ minitest (5.11.3)
69
69
  nio4r (2.2.0)
70
- nokogiri (1.8.1)
70
+ nokogiri (1.8.2)
71
71
  mini_portile2 (~> 2.3.0)
72
72
  parallel (1.12.1)
73
73
  parser (2.4.0.2)
74
74
  ast (~> 2.3)
75
75
  powerpack (0.1.1)
76
- rack (2.0.3)
76
+ rack (2.0.4)
77
77
  rack-proxy (0.6.3)
78
78
  rack
79
79
  rack-test (0.8.2)
@@ -120,7 +120,7 @@ GEM
120
120
  sprockets (>= 3.0.0)
121
121
  thor (0.20.0)
122
122
  thread_safe (0.3.6)
123
- tzinfo (1.2.4)
123
+ tzinfo (1.2.5)
124
124
  thread_safe (~> 0.1)
125
125
  unicode-display_width (1.3.0)
126
126
  websocket-driver (0.6.5)
@@ -141,4 +141,4 @@ DEPENDENCIES
141
141
  webpacker!
142
142
 
143
143
  BUNDLED WITH
144
- 1.15.4
144
+ 1.16.1
data/README.md CHANGED
@@ -30,6 +30,7 @@ in which case you may not even need the asset pipeline. This is mostly relevant
30
30
  - [Angular with TypeScript](#angular-with-typescript)
31
31
  - [Vue](#vue)
32
32
  - [Elm](#elm)
33
+ - [Stimulus](#stimulus)
33
34
  - [Coffeescript](#coffeescript)
34
35
  - [Erb](#erb)
35
36
  - [Paths](#paths)
@@ -79,7 +80,7 @@ Or add it to your `Gemfile`:
79
80
 
80
81
  ```ruby
81
82
  # Gemfile
82
- gem 'webpacker', '~> 3.0'
83
+ gem 'webpacker', '~> 3.2'
83
84
 
84
85
  # OR if you prefer to use master
85
86
  gem 'webpacker', git: 'https://github.com/rails/webpacker.git'
@@ -306,7 +307,7 @@ configuration:
306
307
  p.script_src :self, :https
307
308
  end
308
309
  ```
309
- You can read more this in [Vue docs](https://vuejs.org/v2/guide/installation.html#CSP-environments).
310
+ You can read more about this in the [Vue docs](https://vuejs.org/v2/guide/installation.html#CSP-environments).
310
311
 
311
312
 
312
313
  ### Elm
@@ -325,6 +326,20 @@ The Elm library and core packages will be added via Yarn and Elm itself.
325
326
  An example `Main.elm` app will also be added to your project in `app/javascript`
326
327
  so that you can experiment with Elm right away.
327
328
 
329
+ ### Stimulus
330
+
331
+ To use Webpacker with [Stimulus](http://stimulusjs.org), create a
332
+ new Rails 5.1+ app using `--webpack=stimulus` option:
333
+
334
+ ```
335
+ # Rails 5.1+
336
+ rails new myapp --webpack=stimulus
337
+ ```
338
+
339
+ (or run `bundle exec rails webpacker:install:stimulus` on a Rails app already setup with Webpacker).
340
+
341
+ Please read [The Stimulus Handbook](https://stimulusjs.org/handbook/introduction) or learn more about its source code at https://github.com/stimulusjs/stimulus
342
+
328
343
  ### Coffeescript
329
344
 
330
345
  To add [Coffeescript](http://coffeescript.org/) support,
@@ -39,7 +39,7 @@ and create an env file to load environment variables from:
39
39
  ```env
40
40
  NODE_ENV=development
41
41
  RAILS_ENV=development
42
- WEBPACKER_DEV_SERVER_HOST: 0.0.0.0
42
+ WEBPACKER_DEV_SERVER_HOST=0.0.0.0
43
43
  ```
44
44
 
45
45
  Lastly, rebuild your container:
@@ -9,4 +9,15 @@ directory "#{__dir__}/examples/angular/hello_angular", "#{Webpacker.config.sourc
9
9
  say "Installing all angular dependencies"
10
10
  run "yarn add core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic"
11
11
 
12
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
13
+ say "You need to enable unsafe-eval rule.", :yellow
14
+ say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
15
+ say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
16
+ say "if Rails.env.development?", :yellow
17
+ say " p.script_src :self, :https, :unsafe_eval", :yellow
18
+ say "else", :yellow
19
+ say " p.script_src :self, :https", :yellow
20
+ say "end", :yellow
21
+ end
22
+
12
23
  say "Webpacker now supports angular 🎉", :green
@@ -1,4 +1,4 @@
1
- # Run this example by adding <%%= javascript_pack_tag 'hello_coffee' %> to the head of your layout file,
1
+ # Run this example by adding <%= javascript_pack_tag 'hello_coffee' %> to the head of your layout file,
2
2
  # like app/views/layouts/application.html.erb.
3
3
 
4
4
  console.log 'Hello world from coffeescript'
@@ -1,4 +1,4 @@
1
- // Run this example by adding <%%= javascript_pack_tag 'hello_erb' %> to the head of your layout file,
1
+ // Run this example by adding <%= javascript_pack_tag 'hello_erb' %> to the head of your layout file,
2
2
  // like app/views/layouts/application.html.erb.
3
3
 
4
4
  <% name = 'Erb' %>
@@ -0,0 +1,6 @@
1
+ import { Application } from "stimulus"
2
+ import { definitionsFromContext } from "stimulus/webpack-helpers"
3
+
4
+ const application = Application.start()
5
+ const context = require.context("controllers", true, /.js$/)
6
+ application.load(definitionsFromContext(context))
@@ -0,0 +1,18 @@
1
+ // Visit The Stimulus Handbook for more details
2
+ // https://stimulusjs.org/handbook/introduction
3
+ //
4
+ // This example controller works with specially annotated HTML like:
5
+ //
6
+ // <div data-controller="hello">
7
+ // <h1 data-target="hello.output"></h1>
8
+ // </div>
9
+
10
+ import { Controller } from "stimulus"
11
+
12
+ export default class extends Controller {
13
+ static targets = [ "output" ]
14
+
15
+ connect() {
16
+ this.outputTarget.textContent = 'Hello, Stimulus!'
17
+ }
18
+ }
@@ -1,4 +1,4 @@
1
- // Run this example by adding <%%= javascript_pack_tag 'hello_typescript' %> to the head of your layout file,
1
+ // Run this example by adding <%= javascript_pack_tag 'hello_typescript' %> to the head of your layout file,
2
2
  // like app/views/layouts/application.html.erb.
3
3
 
4
4
  console.log('Hello world from typescript');
@@ -0,0 +1,12 @@
1
+ say "Appending Stimulus setup code to #{Webpacker.config.source_entry_path}/application.js"
2
+ append_to_file "#{Webpacker.config.source_entry_path}/application.js" do
3
+ "\n" + open("#{__dir__}/examples/stimulus/application.js").read
4
+ end
5
+
6
+ say "Creating controllers directory"
7
+ directory "#{__dir__}/examples/stimulus/controllers", "#{Webpacker.config.source_path}/controllers"
8
+
9
+ say "Installing all Stimulus dependencies"
10
+ run "yarn add stimulus"
11
+
12
+ say "Webpacker now supports Stimulus.js 🎉", :green
@@ -18,9 +18,18 @@ run "bundle binstubs webpacker"
18
18
 
19
19
  say "Adding configurations"
20
20
 
21
+ check_yarn_integrity_config = ->(value) { <<CONFIG }
21
22
  # Verifies that versions and hashed value of the package contents in the project's package.json
22
- inject_into_file "config/environments/development.rb", " config.webpacker.check_yarn_integrity = true", after: "Rails.application.configure do\n", verbose: false
23
- inject_into_file "config/environments/production.rb", " config.webpacker.check_yarn_integrity = false", after: "Rails.application.configure do\n", verbose: false
23
+ config.webpacker.check_yarn_integrity = #{value}
24
+ CONFIG
25
+
26
+ if Rails::VERSION::MAJOR >= 5
27
+ environment check_yarn_integrity_config.call("true"), env: :development
28
+ environment check_yarn_integrity_config.call("false"), env: :production
29
+ else
30
+ inject_into_file "config/environments/development.rb", "\n #{check_yarn_integrity_config.call("true")}", after: "Rails.application.configure do", verbose: false
31
+ inject_into_file "config/environments/production.rb", "\n #{check_yarn_integrity_config.call("false")}", after: "Rails.application.configure do", verbose: false
32
+ end
24
33
 
25
34
  if File.exists?(".gitignore")
26
35
  append_to_file ".gitignore", <<-EOS
@@ -28,7 +37,6 @@ if File.exists?(".gitignore")
28
37
  /public/packs-test
29
38
  /node_modules
30
39
  yarn-debug.log*
31
- yarn-error.log*
32
40
  .yarn-integrity
33
41
  EOS
34
42
  end
@@ -39,4 +47,11 @@ run "yarn add @rails/webpacker"
39
47
  say "Installing dev server for live reloading"
40
48
  run "yarn add --dev webpack-dev-server"
41
49
 
50
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
51
+ say "You need to allow webpack-dev-server host as allowed origin for connect-src.", :yellow
52
+ say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
53
+ say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
54
+ say "p.connect_src :self, :https, \"http://localhost:3035\", \"ws://localhost:3035\" if Rails.env.development?", :yellow
55
+ end
56
+
42
57
  say "Webpacker successfully installed 🎉 🍰", :green
@@ -26,4 +26,15 @@ copy_file "#{__dir__}/examples/vue/app.vue",
26
26
  say "Installing all Vue dependencies"
27
27
  run "yarn add vue vue-loader vue-template-compiler"
28
28
 
29
+ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
30
+ say "You need to enable unsafe-eval rule.", :yellow
31
+ say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
32
+ say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
33
+ say "if Rails.env.development?", :yellow
34
+ say " p.script_src :self, :https, :unsafe_eval", :yellow
35
+ say "else", :yellow
36
+ say " p.script_src :self, :https", :yellow
37
+ say "end", :yellow
38
+ end
39
+
29
40
  say "Webpacker now supports Vue.js 🎉", :green
@@ -5,7 +5,8 @@ installers = {
5
5
  "Vue": :vue,
6
6
  "Erb": :erb,
7
7
  "Coffee": :coffee,
8
- "Typescript": :typescript
8
+ "Typescript": :typescript,
9
+ "Stimulus": :stimulus
9
10
  }.freeze
10
11
 
11
12
  dependencies = {
@@ -11,6 +11,7 @@ tasks = {
11
11
  "webpacker:install:vue" => "Installs and setup example Vue component",
12
12
  "webpacker:install:angular" => "Installs and setup example Angular component",
13
13
  "webpacker:install:elm" => "Installs and setup example Elm component",
14
+ "webpacker:install:stimulus" => "Installs and setup example Stimulus component",
14
15
  "webpacker:install:erb" => "Installs Erb loader with an example",
15
16
  "webpacker:install:coffee" => "Installs CoffeeScript loader with an example",
16
17
  "webpacker:install:typescript" => "Installs Typescript loader with an example"
@@ -11,7 +11,7 @@ module Webpacker::Helper
11
11
  # # In production mode:
12
12
  # <%= asset_pack_path 'calendar.css' %> # => "/packs/calendar-1016838bab065ae1e122.css"
13
13
  def asset_pack_path(name, **options)
14
- unless Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?
14
+ unless stylesheet?(name) && Webpacker.dev_server.running? && Webpacker.dev_server.hot_module_replacing?
15
15
  asset_path(Webpacker.manifest.lookup!(name), **options)
16
16
  end
17
17
  end
@@ -68,6 +68,10 @@ module Webpacker::Helper
68
68
  end
69
69
 
70
70
  private
71
+ def stylesheet?(name)
72
+ File.extname(name) == ".css"
73
+ end
74
+
71
75
  def sources_from_pack_manifest(names, type:)
72
76
  names.map { |name| Webpacker.manifest.lookup!(pack_name_with_extension(name, type: type)) }
73
77
  end
@@ -28,17 +28,17 @@ class Webpacker::Engine < ::Rails::Engine
28
28
  output = `yarn check --integrity 2>&1`
29
29
 
30
30
  unless $?.success?
31
- warn "\n\n"
32
- warn "========================================"
33
- warn " Your Yarn packages are out of date!"
34
- warn " Please run `yarn install` to update."
35
- warn "========================================"
36
- warn "\n\n"
37
- warn "To disable this check, please add `config.webpacker.check_yarn_integrity = false`"
38
- warn "to your Rails development config file (config/environments/development.rb)."
39
- warn "\n\n"
40
- warn output
41
- warn "\n\n"
31
+ $stderr.puts "\n\n"
32
+ $stderr.puts "========================================"
33
+ $stderr.puts " Your Yarn packages are out of date!"
34
+ $stderr.puts " Please run `yarn install` to update."
35
+ $stderr.puts "========================================"
36
+ $stderr.puts "\n\n"
37
+ $stderr.puts "To disable this check, please add `config.webpacker.check_yarn_integrity = false`"
38
+ $stderr.puts "to your Rails development config file (config/environments/development.rb)."
39
+ $stderr.puts "\n\n"
40
+ $stderr.puts output
41
+ $stderr.puts "\n\n"
42
42
 
43
43
  exit(1)
44
44
  end
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "3.2.1".freeze
3
+ VERSION = "3.2.2".freeze
4
4
  end
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -20,30 +20,30 @@
20
20
  "babel-polyfill": "^6.26.0",
21
21
  "babel-preset-env": "^1.6.1",
22
22
  "case-sensitive-paths-webpack-plugin": "^2.1.1",
23
- "compression-webpack-plugin": "^1.1.3",
24
- "css-loader": "^0.28.8",
23
+ "compression-webpack-plugin": "^1.1.6",
24
+ "css-loader": "^0.28.9",
25
25
  "extract-text-webpack-plugin": "^3.0.2",
26
26
  "file-loader": "^1.1.6",
27
27
  "glob": "^7.1.2",
28
28
  "js-yaml": "^3.10.0",
29
29
  "node-sass": "^4.7.2",
30
30
  "path-complete-extname": "^0.1.0",
31
- "postcss-cssnext": "^3.0.2",
31
+ "postcss-cssnext": "^3.1.0",
32
32
  "postcss-import": "^11.0.0",
33
- "postcss-loader": "^2.0.10",
33
+ "postcss-loader": "^2.1.0",
34
34
  "sass-loader": "^6.0.6",
35
- "style-loader": "^0.19.1",
36
- "uglifyjs-webpack-plugin": "^1.1.6",
35
+ "style-loader": "^0.20.1",
36
+ "uglifyjs-webpack-plugin": "^1.1.8",
37
37
  "webpack": "^3.10.0",
38
38
  "webpack-manifest-plugin": "^1.3.2"
39
39
  },
40
40
  "devDependencies": {
41
- "eslint": "^4.15.0",
41
+ "eslint": "^4.17.0",
42
42
  "eslint-config-airbnb": "^16.1.0",
43
43
  "eslint-plugin-import": "^2.8.0",
44
44
  "eslint-plugin-jsx-a11y": "^6.0.3",
45
- "eslint-plugin-react": "^7.5.1",
46
- "jest": "^22.0.6"
45
+ "eslint-plugin-react": "^7.6.1",
46
+ "jest": "^22.2.1"
47
47
  },
48
48
  "jest": {
49
49
  "testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
@@ -0,0 +1,25 @@
1
+ /* global test expect, describe */
2
+
3
+ const chdirApp = () => process.chdir('test/test_app')
4
+ const chdirCwd = () => process.chdir(process.cwd())
5
+ chdirApp()
6
+
7
+ const config = require('../config')
8
+
9
+ describe('Webpacker.yml config', () => {
10
+ afterAll(chdirCwd)
11
+
12
+ test('should return extensions as listed in app config', () => {
13
+ expect(config.extensions).toEqual([
14
+ '.js',
15
+ '.sass',
16
+ '.scss',
17
+ '.css',
18
+ '.png',
19
+ '.svg',
20
+ '.gif',
21
+ '.jpeg',
22
+ '.jpg'
23
+ ])
24
+ })
25
+ })