webpacker 3.2.0 → 3.2.1

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
  SHA1:
3
- metadata.gz: b2f0cc346a219b0ec7cbf6e7a8742a5d2357e688
4
- data.tar.gz: 22cfe110c400664e867746d12872f16c0aab2ea6
3
+ metadata.gz: 5a54f5131894092cf3a3c2176cca4c3d2d99cb10
4
+ data.tar.gz: 82eb7c75ef0ce343c7e8bb8b66efffb92d9ba252
5
5
  SHA512:
6
- metadata.gz: be0bae989d22432883152e3623edd818cfbaf8845b539424cf9acc94c69e9a7aec0eda791f650cab2509e76ddf871c44db8bbe5dabda795ee44db3fd6ccf1197
7
- data.tar.gz: 86f02ab54817cae201d65463d9b17d7966c427bec9f2763041a29691b4410e2c33fa7fb2dd2cd8375f111408ccc01b57e85820955fa7e6c9c72272a632dcd86f
6
+ metadata.gz: '088e85d9e4d9534b51b55ec1c69db1cbee256ac5d965c8b49ce2d9f1a1c92ccf17ef22432e58ac52ffb78629aa2708429e5ad39e0277a4917ec9412242ed64af'
7
+ data.tar.gz: fdeab469b4ce1d04d34f7a33a810c286c0783ff69f1c8e95d4f7664fea6f9f02e0b67c4bb0b71db76e2732c42d1ba8afa8c8ea9234dd69ea76671c706fb4600e
data/.gitignore CHANGED
@@ -4,3 +4,6 @@
4
4
  node_modules
5
5
  .byebug_history
6
6
  /test/test_app/tmp
7
+ yarn-debug.log*
8
+ yarn-error.log*
9
+ .yarn-integrity
data/.travis.yml CHANGED
@@ -1,9 +1,12 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ before_install:
4
+ - gem update --system
3
5
  rvm:
4
6
  - 2.2.8
5
7
  - 2.3.5
6
8
  - 2.4.2
9
+ - 2.5.0
7
10
  - ruby-head
8
11
  gemfile:
9
12
  - gemfiles/Gemfile-rails.4.2.x
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
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.1] - 2018-01-21
4
+
5
+ - Disable dev server running? check if no dev server config is present in that environment [#1179](https://github.com/rails/webpacker/pull/1179)
6
+
7
+ - Fix checking 'webpack' binstub on Windows [#1123](https://github.com/rails/webpacker/pull/1123)
8
+
9
+ - silence yarn output if checking is successfull [#1131](https://github.com/rails/webpacker/pull/1131)
10
+
11
+ - Update uglifyJs plugin to support ES6 [#1194](https://github.com/rails/webpacker/pull/1194)
12
+
13
+ - Add typescript installer [#1145](https://github.com/rails/webpacker/pull/1145)
14
+
15
+ - Update default extensions and move to installer [#1181](https://github.com/rails/webpacker/pull/1181)
16
+
17
+ - Revert file loader [#1196](https://github.com/rails/webpacker/pull/1196)
18
+
19
+
3
20
  ## [3.2.0] - 2017-12-16
4
21
 
5
22
  ### To upgrade:
@@ -20,7 +37,7 @@ bundle exec rails webpacker:install:vue
20
37
  bundle exec rails webpacker:install:angular
21
38
  bundle exec rails webpacker:install:elm
22
39
  bundle exec rails webpacker:install:erb
23
- bundle exec rails webpacker:install::coffee
40
+ bundle exec rails webpacker:install:coffee
24
41
  ```
25
42
 
26
43
  Or simply copy required loaders used in your app from
@@ -42,6 +59,14 @@ environment.loaders.append('elm', elm)
42
59
  environment.loaders.append('erb', erb)
43
60
  ```
44
61
 
62
+ In `.postcssrc.yml` you need to change the plugin name from `postcss-smart-import` to `postcss-import`:
63
+
64
+ ```yml
65
+ plugins:
66
+ postcss-import: {}
67
+ postcss-cssnext: {}
68
+ ```
69
+
45
70
  ### Added (npm module)
46
71
 
47
72
  - Upgrade gems and webpack dependencies
@@ -69,7 +94,7 @@ environment.loaders.append('erb', erb)
69
94
 
70
95
  ```bash
71
96
  bundle exec rails webpacker:install:erb
72
- bundle exec rails webpacker:install::coffee
97
+ bundle exec rails webpacker:install:coffee
73
98
  ```
74
99
 
75
100
  - Resolved paths from webpacker.yml to compiler watched list
@@ -143,7 +168,7 @@ files.
143
168
  const sassLoader = environment.loaders.get('sass')
144
169
  const cssLoader = sassLoader.use.find(loader => loader.loader === 'css-loader')
145
170
 
146
- cssLoader.options = Object.assign(cssLoader.options, {
171
+ cssLoader.options = Object.assign({}, cssLoader.options, {
147
172
  modules: true,
148
173
  localIdentName: '[path][name]__[local]--[hash:base64:5]'
149
174
  })
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker (3.2.0)
4
+ webpacker (3.2.1)
5
5
  activesupport (>= 4.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 4.2)
@@ -65,11 +65,11 @@ 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.10.3)
69
- nio4r (2.1.0)
68
+ minitest (5.11.1)
69
+ nio4r (2.2.0)
70
70
  nokogiri (1.8.1)
71
71
  mini_portile2 (~> 2.3.0)
72
- parallel (1.12.0)
72
+ parallel (1.12.1)
73
73
  parser (2.4.0.2)
74
74
  ast (~> 2.3)
75
75
  powerpack (0.1.1)
@@ -101,14 +101,13 @@ GEM
101
101
  method_source
102
102
  rake (>= 0.8.7)
103
103
  thor (>= 0.18.1, < 2.0)
104
- rainbow (2.2.2)
105
- rake
104
+ rainbow (3.0.0)
106
105
  rake (12.3.0)
107
- rubocop (0.51.0)
106
+ rubocop (0.52.1)
108
107
  parallel (~> 1.10)
109
- parser (>= 2.3.3.1, < 3.0)
108
+ parser (>= 2.4.0.2, < 3.0)
110
109
  powerpack (~> 0.1)
111
- rainbow (>= 2.2.2, < 3.0)
110
+ rainbow (>= 2.2.2, < 4.0)
112
111
  ruby-progressbar (~> 1.7)
113
112
  unicode-display_width (~> 1.0, >= 1.0.1)
114
113
  ruby-progressbar (1.9.0)
data/docs/deployment.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Deployment
2
2
 
3
3
 
4
- Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`. If you are not using Sprockets you
5
- can manually trigger `bundle exec rails webpacker:compile` during your app deploy.
4
+ Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`.
5
+ If you are not using Sprockets `webpacker:compile` is automatically aliased to `assets:precompile`. Remember to set NODE_ENV environment variable to production during deployment or when running the rake task.
6
6
 
7
7
  The `javascript_pack_tag` and `stylesheet_pack_tag` helper method will automatically insert the correct HTML tag for compiled pack. Just like the asset pipeline does it.
8
8
 
data/docs/typescript.md CHANGED
@@ -3,43 +3,15 @@
3
3
 
4
4
  ## Typescript with React
5
5
 
6
- 1. Setup react using Webpacker [react installer](#react). Then add required depedencies
7
- for using typescript with React:
6
+ 1. Setup react using Webpacker [react installer](#react). Then run the typescript installer
8
7
 
9
8
  ```bash
10
- yarn add ts-loader typescript @types/react @types/react-dom
9
+ bundle exec rails webpacker:install:typescript
10
+ yarn add @types/react @types/react-dom
11
11
  ```
12
12
 
13
- 2. Add a `tsconfig.json` to project root:
14
-
15
- ``` json
16
- {
17
- "compilerOptions": {
18
- "declaration": false,
19
- "emitDecoratorMetadata": true,
20
- "experimentalDecorators": true,
21
- "lib": ["es6", "dom"],
22
- "module": "es6",
23
- "moduleResolution": "node",
24
- "sourceMap": true,
25
- "jsx": "react",
26
- "target": "es5"
27
- },
28
- "exclude": [
29
- "**/*.spec.ts",
30
- "node_modules",
31
- "vendor",
32
- "public"
33
- ],
34
- "compileOnSave": false
35
- }
36
- ```
37
-
38
- 3. Finally add `.tsx` to the list of extensions in `config/webpacker.yml`
39
- and rename your generated `hello_react.js` using react installer
40
- to `hello_react.tsx` and make it valid typescript and now you can use
41
- typescript, JSX with React.
42
-
13
+ 2. Rename the generated `hello_react.js` to `hello_react.tsx`. Make the file valid typescript and
14
+ now you can use typescript, JSX with React.
43
15
 
44
16
 
45
17
  ## HTML templates with Typescript and Angular
data/docs/webpack.md CHANGED
@@ -142,7 +142,10 @@ environment.loaders.insert('svg', {
142
142
  }
143
143
  }
144
144
  ])
145
- }, { before: 'file' })
145
+ }, { after: 'file' })
146
+
147
+ const fileLoader = environment.loaders.get('file')
148
+ fileLoader.exclude = /\.(svg)$/i
146
149
  ```
147
150
 
148
151
 
@@ -151,16 +154,13 @@ environment.loaders.insert('svg', {
151
154
  ```js
152
155
  // config/webpack/loaders/url.js
153
156
 
154
- const { assetHost } = require('@rails/webpacker')
155
-
156
157
  module.exports = {
157
158
  test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
158
159
  use: [{
159
160
  loader: 'url-loader',
160
161
  options: {
161
162
  limit: 10000,
162
- name: '[name]-[hash].[ext]',
163
- publicPath: assetHost.publicPathWithHost
163
+ name: '[name]-[hash].[ext]'
164
164
  }
165
165
  }]
166
166
  }
@@ -1,27 +1,12 @@
1
1
  require "webpacker/configuration"
2
2
 
3
- say "Copying angular loader to config/webpack/loaders"
4
- copy_file "#{__dir__}/loaders/typescript.js", Rails.root.join("config/webpack/loaders/typescript.js").to_s
5
-
6
- say "Adding typescript loader to config/webpack/environment.js"
7
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
8
- "const typescript = require('./loaders/typescript')\n",
9
- after: "require('@rails/webpacker')\n"
10
-
11
- insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
- "environment.loaders.append('typescript', typescript)\n",
13
- before: "module.exports"
14
-
15
3
  say "Copying angular example entry file to #{Webpacker.config.source_entry_path}"
16
4
  copy_file "#{__dir__}/examples/angular/hello_angular.js", "#{Webpacker.config.source_entry_path}/hello_angular.js"
17
5
 
18
6
  say "Copying hello_angular app to #{Webpacker.config.source_path}"
19
7
  directory "#{__dir__}/examples/angular/hello_angular", "#{Webpacker.config.source_path}/hello_angular"
20
8
 
21
- say "Copying tsconfig.json to the Rails root directory for typescript"
22
- copy_file "#{__dir__}/examples/angular/tsconfig.json", "tsconfig.json"
23
-
24
9
  say "Installing all angular dependencies"
25
- run "yarn add typescript ts-loader core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic"
10
+ run "yarn add core-js zone.js rxjs @angular/core @angular/common @angular/compiler @angular/platform-browser @angular/platform-browser-dynamic"
26
11
 
27
- say "Webpacker now supports angular and typescript 🎉", :green
12
+ say "Webpacker now supports angular 🎉", :green
@@ -12,6 +12,9 @@ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
12
  "environment.loaders.append('coffee', coffee)\n",
13
13
  before: "module.exports"
14
14
 
15
+ say "Updating webpack paths to include .coffee file extension"
16
+ insert_into_file Webpacker.config.config_path, " - .coffee\n", after: /extensions:\n/
17
+
15
18
  say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
16
19
  copy_file "#{__dir__}/examples/coffee/hello_coffee.coffee",
17
20
  "#{Webpacker.config.source_entry_path}/hello_coffee.coffee"
@@ -14,12 +14,7 @@ default: &default
14
14
  cache_manifest: false
15
15
 
16
16
  extensions:
17
- - .coffee
18
- - .erb
19
17
  - .js
20
- - .jsx
21
- - .ts
22
- - .vue
23
18
  - .sass
24
19
  - .scss
25
20
  - .css
data/lib/install/elm.rb CHANGED
@@ -25,7 +25,7 @@ run "yarn add elm elm-webpack-loader"
25
25
  run "yarn add --dev elm-hot-loader"
26
26
  run "yarn run elm package install -- --yes"
27
27
 
28
- say "Updating webpack paths to include Elm file extension"
28
+ say "Updating webpack paths to include .elm file extension"
29
29
  insert_into_file Webpacker.config.config_path, " - .elm\n", after: /extensions:\n/
30
30
 
31
31
  say "Updating Elm source location"
data/lib/install/erb.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "webpacker/configuration"
2
2
 
3
- say "Copying vue loader to config/webpack/loaders"
3
+ say "Copying erb loader to config/webpack/loaders"
4
4
  copy_file "#{__dir__}/loaders/erb.js", Rails.root.join("config/webpack/loaders/erb.js").to_s
5
5
 
6
6
  say "Adding erb loader to config/webpack/environment.js"
@@ -12,6 +12,9 @@ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
12
12
  "environment.loaders.append('erb', erb)\n",
13
13
  before: "module.exports"
14
14
 
15
+ say "Updating webpack paths to include .erb file extension"
16
+ insert_into_file Webpacker.config.config_path, " - .erb\n", after: /extensions:\n/
17
+
15
18
  say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
16
19
  copy_file "#{__dir__}/examples/erb/hello_erb.js.erb",
17
20
  "#{Webpacker.config.source_entry_path}/hello_erb.js.erb"
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": false,
4
+ "emitDecoratorMetadata": true,
5
+ "experimentalDecorators": true,
6
+ "lib": ["es6", "dom"],
7
+ "module": "es6",
8
+ "moduleResolution": "node",
9
+ "sourceMap": true,
10
+ "target": "es5",
11
+ "jsx": "react"
12
+ },
13
+ "exclude": [
14
+ "**/*.spec.ts",
15
+ "node_modules",
16
+ "vendor",
17
+ "public"
18
+ ],
19
+ "compileOnSave": false
20
+ }
@@ -0,0 +1,4 @@
1
+ // Run this example by adding <%%= javascript_pack_tag 'hello_typescript' %> to the head of your layout file,
2
+ // like app/views/layouts/application.html.erb.
3
+
4
+ console.log('Hello world from typescript');
@@ -9,10 +9,11 @@ import Vue from 'vue'
9
9
  import App from '../app.vue'
10
10
 
11
11
  document.addEventListener('DOMContentLoaded', () => {
12
- document.body.appendChild(document.createElement('hello'))
12
+ const el = document.body.appendChild(document.createElement('hello'))
13
13
  const app = new Vue({
14
+ el,
14
15
  render: h => h(App)
15
- }).$mount('hello')
16
+ })
16
17
 
17
18
  console.log(app)
18
19
  })
@@ -5,7 +5,7 @@ const elmSource = resolve(process.cwd())
5
5
  const elmMake = `${elmSource}/node_modules/.bin/elm-make`
6
6
 
7
7
  const elmDefaultOptions = { cwd: elmSource, pathToMake: elmMake }
8
- const developmentOptions = Object.assign(elmDefaultOptions, {
8
+ const developmentOptions = Object.assign({}, elmDefaultOptions, {
9
9
  verbose: true,
10
10
  warn: true,
11
11
  debug: true
data/lib/install/react.rb CHANGED
@@ -22,6 +22,9 @@ end
22
22
  say "Copying react example entry file to #{Webpacker.config.source_entry_path}"
23
23
  copy_file "#{__dir__}/examples/react/hello_react.jsx", "#{Webpacker.config.source_entry_path}/hello_react.jsx"
24
24
 
25
+ say "Updating webpack paths to include .jsx file extension"
26
+ insert_into_file Webpacker.config.config_path, " - .jsx\n", after: /extensions:\n/
27
+
25
28
  say "Installing all react dependencies"
26
29
  run "yarn add react react-dom babel-preset-react prop-types"
27
30
 
@@ -17,25 +17,24 @@ say "Installing binstubs"
17
17
  run "bundle binstubs webpacker"
18
18
 
19
19
  say "Adding configurations"
20
- environment <<CONFIG, env: :development
21
- # Verifies that versions and hashed value of the package contents in the project's package.json
22
- config.webpacker.check_yarn_integrity = true
23
- CONFIG
24
- environment <<CONFIG, env: :production
25
- # Verifies that versions and hashed value of the package contents in the project's package.json
26
- config.webpacker.check_yarn_integrity = false
27
- CONFIG
20
+
21
+ # 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
28
24
 
29
25
  if File.exists?(".gitignore")
30
26
  append_to_file ".gitignore", <<-EOS
31
27
  /public/packs
32
28
  /public/packs-test
33
29
  /node_modules
30
+ yarn-debug.log*
31
+ yarn-error.log*
32
+ .yarn-integrity
34
33
  EOS
35
34
  end
36
35
 
37
36
  say "Installing all JavaScript dependencies"
38
- run "yarn add @rails/webpacker coffeescript@1.12.7"
37
+ run "yarn add @rails/webpacker"
39
38
 
40
39
  say "Installing dev server for live reloading"
41
40
  run "yarn add --dev webpack-dev-server"
@@ -0,0 +1,46 @@
1
+ require "webpacker/configuration"
2
+
3
+ additional_packages = ""
4
+ example_source = "typescript"
5
+
6
+ # Additional configuration is required for React projects
7
+ package_json = Rails.root.join("package.json")
8
+ if File.exist?(package_json)
9
+ package = JSON.parse(File.read(package_json))
10
+ package["dependencies"] ||= {}
11
+
12
+ if package["dependencies"].keys.include?("react")
13
+ additional_packages = "@types/react @types/react-dom"
14
+ example_source = "react"
15
+ end
16
+ end
17
+
18
+ say "Copying typescript loader to config/webpack/loaders"
19
+ copy_file "#{__dir__}/loaders/typescript.js", Rails.root.join("config/webpack/loaders/typescript.js").to_s
20
+
21
+ say "Adding typescript loader to config/webpack/environment.js"
22
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
23
+ "const typescript = require('./loaders/typescript')\n",
24
+ after: "require('@rails/webpacker')\n"
25
+
26
+ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
27
+ "environment.loaders.append('typescript', typescript)\n",
28
+ before: "module.exports"
29
+
30
+ say "Copying tsconfig.json to the Rails root directory for typescript"
31
+ copy_file "#{__dir__}/examples/#{example_source}/tsconfig.json", "tsconfig.json"
32
+
33
+ say "Updating webpack paths to include .ts file extension"
34
+ insert_into_file Webpacker.config.config_path, " - .ts\n", after: /extensions:\n/
35
+
36
+ say "Updating webpack paths to include .tsx file extension"
37
+ insert_into_file Webpacker.config.config_path, " - .tsx\n", after: /extensions:\n/
38
+
39
+ say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
40
+ copy_file "#{__dir__}/examples/typescript/hello_typescript.ts",
41
+ "#{Webpacker.config.source_entry_path}/hello_typescript.ts"
42
+
43
+ say "Installing all typescript dependencies"
44
+ run "yarn add typescript ts-loader #{additional_packages}"
45
+
46
+ say "Webpacker now supports typescript 🎉", :green