webpacker 3.5.3 → 3.5.5

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
  SHA256:
3
- metadata.gz: e4013ed561828080b4628169180eb208a438237ccc35ce5b6d5eef755dea2d45
4
- data.tar.gz: 601997343da416bc4232effff181f144e167b21d1fd57d272421348572c06b19
3
+ metadata.gz: b71d06e4c3b26132fe071d34ab0e6cf16ee5972928e8455f020016d9f8e9c4fc
4
+ data.tar.gz: d3ab16ffe934cb08285dfc1399f0afd0f7a2643e2d4b73bef568bfec81faafd7
5
5
  SHA512:
6
- metadata.gz: 16b2b45d4ee641048a629354d8e5473e5fb1c7527aa83a74e496233fb6325cacb78561e5def4764df1ba0e9b21ac7201984f46d878822b335ea84dd84434f933
7
- data.tar.gz: 6a41ffa090a7856be21fb0709d35dcf73b16d96f32dfe23d5be7dab4b1a33c5c62f7fdb8e90199777cd2dafc28b003c1b23bcd368bf57a544430707e593bfff4
6
+ metadata.gz: ff65fabb9b0802dc4eb2fedc7026d1f2655520e421e77aed9a15c690856bd8d30c99026e6ce07847f8a08c076872a5b5558fcf6adb0033469d0a149f3e0060f5
7
+ data.tar.gz: 9847cb5cc56b6da3cb02000a6f37d16c20cdda5139818443be85d775204566299c60bcdc8d9595dfe593625e63dd1bdb8ff29c6660897b551e6e5efe2b84445f
@@ -32,3 +32,6 @@ script:
32
32
  matrix:
33
33
  allow_failures:
34
34
  - gemfile: gemfiles/Gemfile-rails-edge
35
+ exclude:
36
+ - rvm: 2.3.7
37
+ gemfile: gemfiles/Gemfile-rails-edge
@@ -1,5 +1,12 @@
1
1
  **Please note that Webpacker 3.1.0 and 3.1.1 have some serious bugs so please consider using either 3.0.2 or 3.2.0**
2
2
 
3
+ ## [3.5.5] - 2018-07-09
4
+ See changes: https://github.com/rails/webpacker/compare/e8b197e36c77181ca2e4765c620faea59dcd0351...3-x-stable
5
+
6
+ ### Added
7
+ - On CI, sort files & check modified w/ digest intead of mtime[#1522](https://github.com/rails/webpacker/pull/1522)
8
+
9
+
3
10
  ## [3.5.3] - 2018-05-03
4
11
 
5
12
  ### Fixed
@@ -20,14 +27,13 @@
20
27
 
21
28
  ### Fixed
22
29
  - Remove compilation digest file if webpack command fails [#1399](https://github.com/rails/webpacker/pull/1399)
23
- - Handle http dev_server setting properly in the proxy [#1420]
30
+ - Handle http dev_server setting properly in the proxy [#1420](https://github.com/rails/webpacker/pull/1420)
24
31
  - Use correct protocol [#1425](https://github.com/rails/webpacker/pull/1425)
25
32
 
26
33
  ### Added
27
34
  - `image_pack_tag` helper [#1400](https://github.com/rails/webpacker/pull/1400)
28
35
  - devserver proxy for custom environments [#1415](https://github.com/rails/webpacker/pull/1415)
29
- - Rails webpacker:info task [#1416](https://github.com/rails/webpacker/pull/1416)
30
- (https://github.com/rails/webpacker/pull/1420)
36
+ - Rails webpacker:info task [#1416](https://github.com/rails/webpacker/pull/1416)
31
37
  - Include `RAILS_RELATIVE_URL_ROOT` environment variable in publicPath [#1428](https://github.com/rails/webpacker/pull/1428)
32
38
 
33
39
  Complete list of changes: [#1464](https://github.com/rails/webpacker/pull/1464)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker (3.5.3)
4
+ webpacker (3.5.5)
5
5
  activesupport (>= 4.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 4.2)
@@ -61,6 +61,7 @@ GEM
61
61
  activesupport (>= 4.2.0)
62
62
  i18n (1.0.1)
63
63
  concurrent-ruby (~> 1.0)
64
+ jaro_winkler (1.5.1)
64
65
  loofah (2.2.2)
65
66
  crass (~> 1.0.2)
66
67
  nokogiri (>= 1.5.9)
@@ -73,13 +74,13 @@ GEM
73
74
  mini_mime (1.0.0)
74
75
  mini_portile2 (2.3.0)
75
76
  minitest (5.11.3)
76
- nio4r (2.3.0)
77
- nokogiri (1.8.2)
77
+ nio4r (2.3.1)
78
+ nokogiri (1.8.4)
78
79
  mini_portile2 (~> 2.3.0)
79
80
  parallel (1.12.1)
80
81
  parser (2.5.1.0)
81
82
  ast (~> 2.4.0)
82
- powerpack (0.1.1)
83
+ powerpack (0.1.2)
83
84
  rack (2.0.5)
84
85
  rack-proxy (0.6.4)
85
86
  rack
@@ -111,7 +112,8 @@ GEM
111
112
  thor (>= 0.18.1, < 2.0)
112
113
  rainbow (3.0.0)
113
114
  rake (12.3.1)
114
- rubocop (0.55.0)
115
+ rubocop (0.58.0)
116
+ jaro_winkler (~> 1.5.1)
115
117
  parallel (~> 1.10)
116
118
  parser (>= 2.5)
117
119
  powerpack (~> 0.1)
@@ -119,7 +121,7 @@ GEM
119
121
  ruby-progressbar (~> 1.7)
120
122
  unicode-display_width (~> 1.0, >= 1.0.1)
121
123
  ruby-progressbar (1.9.0)
122
- sprockets (3.7.1)
124
+ sprockets (3.7.2)
123
125
  concurrent-ruby (~> 1.0)
124
126
  rack (> 1, < 3)
125
127
  sprockets-rails (3.2.1)
@@ -130,7 +132,7 @@ GEM
130
132
  thread_safe (0.3.6)
131
133
  tzinfo (1.2.5)
132
134
  thread_safe (~> 0.1)
133
- unicode-display_width (1.3.2)
135
+ unicode-display_width (1.4.0)
134
136
  websocket-driver (0.7.0)
135
137
  websocket-extensions (>= 0.1.0)
136
138
  websocket-extensions (0.1.3)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Webpacker
2
2
 
3
- ![travis-ci status](https://api.travis-ci.org/rails/webpacker.svg?branch=master)
3
+ ![travis-ci status](https://api.travis-ci.org/rails/webpacker.svg?branch=3-x-stable)
4
4
  [![node.js](https://img.shields.io/badge/node-%3E%3D%206.0.0-brightgreen.svg)](https://nodejs.org/en/)
5
5
  [![Gem](https://img.shields.io/gem/v/webpacker.svg)](https://github.com/rails/webpacker)
6
6
 
data/Rakefile CHANGED
@@ -2,9 +2,8 @@
2
2
  require "bundler/gem_tasks"
3
3
  require "rake/testtask"
4
4
 
5
- Rake::TestTask.new(:test) do |t|
5
+ Rake::TestTask.new do |t|
6
6
  t.libs << "test"
7
- t.libs << "lib"
8
7
  t.test_files = FileList["test/**/*_test.rb"]
9
8
  t.verbose = true
10
9
  end
@@ -100,9 +100,9 @@ Rails.application.config.assets.js_compressor = :uglifier
100
100
 
101
101
  ```
102
102
 
103
- ### Angular: WARNING in ./node_modules/@angular/core/esm5/core.js, Critical dependency: the request of a dependency is an expression
103
+ ## Angular: WARNING in ./node_modules/@angular/core/esm5/core.js, Critical dependency: the request of a dependency is an expression
104
104
 
105
- To silent these warnings, please update `config/webpack/environment.js`
105
+ To silence these warnings, please update `config/webpack/environment.js`
106
106
 
107
107
  ```js
108
108
  // environment.js
@@ -117,3 +117,6 @@ environment.plugins.append('ContextReplacement',
117
117
  )
118
118
  )
119
119
  ```
120
+
121
+ ## Compilation triggered even when files haven't changed
122
+ Webpacker compares the modified times (mtimes) of files to see if they have changed & determine whether to recompile on-demand. For CI environments that clone the repository before running tests, the modified times will be set to when the repository was cloned, not when the file was last modified. To prevent unnecessary recompilation on CI, Webpacker watches for the `CI` environment variable, and instead compares the SHA hashes of all files to determine if they've actually changed. You can enable this behavior outside of CI environemnts, or in those that don't set the `CI` env var, by running `CI=true bin/webpack` (or `webpack-dev-server`).
@@ -54,7 +54,7 @@ document.addEventListener('DOMContentLoaded', () => {
54
54
  //
55
55
  // Then uncomment the code block below:
56
56
  //
57
- // import TurbolinksAdapter from 'vue-turbolinks';
57
+ // import TurbolinksAdapter from 'vue-turbolinks'
58
58
  // import Vue from 'vue/dist/vue.esm'
59
59
  // import App from '../app.vue'
60
60
  //
@@ -44,7 +44,12 @@ class Webpacker::Compiler
44
44
 
45
45
  def watched_files_digest
46
46
  files = Dir[*default_watched_paths, *watched_paths].reject { |f| File.directory?(f) }
47
- Digest::SHA1.hexdigest(files.map { |f| "#{File.basename(f)}/#{File.mtime(f).utc.to_i}" }.join("/"))
47
+ file_ids = if ENV["CI"]
48
+ files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
49
+ else
50
+ files.map { |f| "#{File.basename(f)}/#{File.mtime(f).utc.to_i}" }
51
+ end
52
+ Digest::SHA1.hexdigest(file_ids.join("/"))
48
53
  end
49
54
 
50
55
  def record_compilation_digest
@@ -1,8 +1,14 @@
1
+ require "yaml"
2
+ require "active_support/core_ext/hash/keys"
3
+ require "active_support/core_ext/hash/indifferent_access"
4
+
1
5
  class Webpacker::Configuration
2
- delegate :root_path, :config_path, :env, to: :@webpacker
6
+ attr_reader :root_path, :config_path, :env
3
7
 
4
- def initialize(webpacker)
5
- @webpacker = webpacker
8
+ def initialize(root_path:, config_path:, env:)
9
+ @root_path = root_path
10
+ @config_path = config_path
11
+ @env = env
6
12
  end
7
13
 
8
14
  def refresh
@@ -3,10 +3,10 @@ class Webpacker::DevServer
3
3
  # Webpacker.dev_server.connect_timeout = 1
4
4
  cattr_accessor(:connect_timeout) { 0.01 }
5
5
 
6
- delegate :config, to: :@webpacker
6
+ attr_reader :config
7
7
 
8
- def initialize(webpacker)
9
- @webpacker = webpacker
8
+ def initialize(config)
9
+ @config = config
10
10
  end
11
11
 
12
12
  def running?
@@ -54,6 +54,10 @@ class Webpacker::DevServer
54
54
  "#{host}:#{port}"
55
55
  end
56
56
 
57
+ def pretty?
58
+ fetch(:pretty)
59
+ end
60
+
57
61
  private
58
62
  def fetch(key)
59
63
  ENV["WEBPACKER_DEV_SERVER_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key])
@@ -1,6 +1,7 @@
1
1
  require "shellwords"
2
- require "yaml"
3
2
  require "socket"
3
+ require "webpacker/configuration"
4
+ require "webpacker/dev_server"
4
5
  require "webpacker/runner"
5
6
 
6
7
  module Webpacker
@@ -13,15 +14,22 @@ module Webpacker
13
14
 
14
15
  private
15
16
  def load_config
16
- @config_file = File.join(@app_path, "config/webpacker.yml")
17
- dev_server = YAML.load_file(@config_file)[ENV["RAILS_ENV"]]["dev_server"]
17
+ app_root = Pathname.new(@app_path)
18
18
 
19
- @hostname = dev_server["host"]
20
- @port = dev_server["port"]
21
- @pretty = dev_server.fetch("pretty", true)
19
+ config = Configuration.new(
20
+ root_path: app_root,
21
+ config_path: app_root.join("config/webpacker.yml"),
22
+ env: ENV["RAILS_ENV"]
23
+ )
24
+
25
+ dev_server = DevServer.new(config)
26
+
27
+ @hostname = dev_server.host
28
+ @port = dev_server.port
29
+ @pretty = dev_server.pretty?
22
30
 
23
31
  rescue Errno::ENOENT, NoMethodError
24
- $stdout.puts "webpack dev_server configuration not found in #{@config_file}[#{ENV["RAILS_ENV"]}]."
32
+ $stdout.puts "webpack dev_server configuration not found in #{config.config_path}[#{ENV["RAILS_ENV"]}]."
25
33
  $stdout.puts "Please run bundle exec rails webpacker:install to install Webpacker"
26
34
  exit!
27
35
  end
@@ -13,7 +13,7 @@ class Webpacker::Env
13
13
 
14
14
  def inquire
15
15
  fallback_env_warning unless current
16
- (current || DEFAULT).inquiry
16
+ current || DEFAULT.inquiry
17
17
  end
18
18
 
19
19
  private
@@ -12,7 +12,11 @@ class Webpacker::Instance
12
12
  end
13
13
 
14
14
  def config
15
- @config ||= Webpacker::Configuration.new self
15
+ @config ||= Webpacker::Configuration.new(
16
+ root_path: root_path,
17
+ config_path: config_path,
18
+ env: env
19
+ )
16
20
  end
17
21
 
18
22
  def compiler
@@ -20,7 +24,7 @@ class Webpacker::Instance
20
24
  end
21
25
 
22
26
  def dev_server
23
- @dev_server ||= Webpacker::DevServer.new self
27
+ @dev_server ||= Webpacker::DevServer.new config
24
28
  end
25
29
 
26
30
  def manifest
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "3.5.3".freeze
3
+ VERSION = "3.5.5".freeze
4
4
  end
@@ -1,37 +1,41 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "3.5.3",
3
+ "version": "3.5.5",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
- "files": ["package", "lib/install/config/webpacker.yml"],
6
+ "files": [
7
+ "package",
8
+ "lib/install/config/webpacker.yml"
9
+ ],
7
10
  "engines": {
8
11
  "node": ">=6.0.0",
9
12
  "yarn": ">=0.25.2"
10
13
  },
11
14
  "dependencies": {
12
15
  "babel-core": "^6.26.3",
13
- "babel-loader": "^7.1.4",
16
+ "babel-loader": "^7.1.5",
14
17
  "babel-plugin-syntax-dynamic-import": "^6.18.0",
15
18
  "babel-plugin-transform-class-properties": "^6.24.1",
16
19
  "babel-plugin-transform-object-rest-spread": "^6.26.0",
17
20
  "babel-polyfill": "^6.26.0",
18
- "babel-preset-env": "^1.6.1",
21
+ "babel-preset-env": "^1.7.0",
19
22
  "case-sensitive-paths-webpack-plugin": "^2.1.2",
20
23
  "compression-webpack-plugin": "^1.1.11",
21
24
  "css-loader": "^0.28.11",
22
25
  "extract-text-webpack-plugin": "^3.0.2",
23
26
  "file-loader": "^1.1.11",
24
27
  "glob": "^7.1.2",
25
- "js-yaml": "^3.11.0",
26
- "node-sass": "^4.9.0",
28
+ "js-yaml": "^3.12.0",
29
+ "node-sass": "^4.9.2",
30
+ "optimize-css-assets-webpack-plugin": "^3.2.0",
27
31
  "path-complete-extname": "^1.0.0",
28
32
  "postcss-cssnext": "^3.1.0",
29
33
  "postcss-import": "^11.1.0",
30
- "postcss-loader": "^2.1.4",
34
+ "postcss-loader": "^2.1.5",
31
35
  "sass-loader": "^6.0.7",
32
- "style-loader": "^0.20.3",
33
- "uglifyjs-webpack-plugin": "^1.2.5",
34
- "webpack": "^3.11.0",
36
+ "style-loader": "^0.21.0",
37
+ "uglifyjs-webpack-plugin": "^1.2.7",
38
+ "webpack": "^3.12.0",
35
39
  "webpack-manifest-plugin": "^1.3.2"
36
40
  },
37
41
  "devDependencies": {
@@ -40,11 +44,13 @@
40
44
  "eslint-plugin-import": "^2.11.0",
41
45
  "eslint-plugin-jsx-a11y": "^6.0.3",
42
46
  "eslint-plugin-react": "^7.7.0",
43
- "jest": "^22.4.3"
47
+ "jest": "^23.3.0"
44
48
  },
45
49
  "jest": {
46
50
  "testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
47
- "roots": ["<rootDir>/package"]
51
+ "roots": [
52
+ "<rootDir>/package"
53
+ ]
48
54
  },
49
55
  "scripts": {
50
56
  "test": "jest",
@@ -13,9 +13,11 @@ describe('Production environment', () => {
13
13
 
14
14
  test('should use production config and environment', () => {
15
15
  process.env.RAILS_ENV = 'production'
16
- const { environment } = require('../index')
16
+ process.env.NODE_ENV = 'production'
17
17
 
18
+ const { environment } = require('../index')
18
19
  const config = environment.toWebpackConfig()
20
+
19
21
  expect(config.output.path).toEqual(resolve('public', 'packs'))
20
22
  expect(config.output.publicPath).toEqual('/packs/')
21
23
  expect(config).toMatchObject({
@@ -13,9 +13,11 @@ describe('Custom environment', () => {
13
13
 
14
14
  test('should use staging config and production environment', () => {
15
15
  process.env.RAILS_ENV = 'staging'
16
- const { environment } = require('../index')
16
+ delete process.env.NODE_ENV
17
17
 
18
+ const { environment } = require('../index')
18
19
  const config = environment.toWebpackConfig()
20
+
19
21
  expect(config.output.path).toEqual(resolve('public', 'packs-staging'))
20
22
  expect(config.output.publicPath).toEqual('/packs-staging/')
21
23
  expect(config).toMatchObject({
@@ -13,9 +13,11 @@ describe('Test environment', () => {
13
13
 
14
14
  test('should use test config and production environment', () => {
15
15
  process.env.RAILS_ENV = 'test'
16
- const { environment } = require('../index')
16
+ process.env.NODE_ENV = 'test'
17
17
 
18
+ const { environment } = require('../index')
18
19
  const config = environment.toWebpackConfig()
20
+
19
21
  expect(config.output.path).toEqual(resolve('public', 'packs-test'))
20
22
  expect(config.output.publicPath).toEqual('/packs-test/')
21
23
  })
@@ -11,7 +11,7 @@ const devServerConfig = config.dev_server
11
11
  if (devServerConfig) {
12
12
  Object.keys(devServerConfig).forEach((key) => {
13
13
  const envValue = fetch(`WEBPACKER_DEV_SERVER_${key.toUpperCase().replace(/_/g, '')}`)
14
- if (envValue) devServerConfig[key] = envValue
14
+ if (envValue !== undefined) devServerConfig[key] = envValue
15
15
  })
16
16
  }
17
17
 
@@ -2,7 +2,7 @@ const { resolve } = require('path')
2
2
  const { safeLoad } = require('js-yaml')
3
3
  const { readFileSync } = require('fs')
4
4
 
5
- const NODE_ENVIRONMENTS = ['development', 'production']
5
+ const NODE_ENVIRONMENTS = ['development', 'production', 'test']
6
6
  const DEFAULT = 'production'
7
7
  const configPath = resolve('config', 'webpacker.yml')
8
8
 
@@ -11,7 +11,7 @@ const nodeEnv = process.env.NODE_ENV
11
11
 
12
12
  const config = safeLoad(readFileSync(configPath), 'utf8')
13
13
  const availableEnvironments = Object.keys(config).join('|')
14
- const regex = new RegExp(availableEnvironments, 'g')
14
+ const regex = new RegExp(`^(${availableEnvironments})$`, 'g')
15
15
 
16
16
  module.exports = {
17
17
  railsEnv: railsEnv && railsEnv.match(regex) ? railsEnv : DEFAULT,
@@ -1,6 +1,7 @@
1
1
  const webpack = require('webpack')
2
2
  const CompressionPlugin = require('compression-webpack-plugin')
3
3
  const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
4
+ const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
4
5
  const Base = require('./base')
5
6
 
6
7
  module.exports = class extends Base {
@@ -8,6 +9,7 @@ module.exports = class extends Base {
8
9
  super()
9
10
 
10
11
  this.plugins.append('ModuleConcatenation', new webpack.optimize.ModuleConcatenationPlugin())
12
+ this.plugins.append('OptimizeCSSAssets', new OptimizeCSSAssetsPlugin())
11
13
 
12
14
  this.plugins.append(
13
15
  'UglifyJs',
@@ -16,17 +18,22 @@ module.exports = class extends Base {
16
18
  cache: true,
17
19
  sourceMap: true,
18
20
  uglifyOptions: {
19
- ie8: false,
20
- ecma: 8,
21
- warnings: false,
22
- mangle: {
23
- safari10: true
21
+ parse: {
22
+ // Let uglify-js parse ecma 8 code but always output
23
+ // ES5 compliant code for older browsers
24
+ ecma: 8
24
25
  },
25
26
  compress: {
27
+ ecma: 5,
26
28
  warnings: false,
27
29
  comparisons: false
28
30
  },
31
+ mangle: {
32
+ safari10: true
33
+ },
29
34
  output: {
35
+ ecma: 5,
36
+ comments: false,
30
37
  ascii_only: true
31
38
  }
32
39
  }