webpacker-legacy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +15 -0
  2. data/.eslintrc.js +14 -0
  3. data/.gitignore +4 -0
  4. data/.rubocop.yml +124 -0
  5. data/.travis.yml +22 -0
  6. data/CHANGELOG.md +148 -0
  7. data/Gemfile +11 -0
  8. data/Gemfile.lock +137 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +1118 -0
  11. data/Rakefile +12 -0
  12. data/lib/install/angular.rb +22 -0
  13. data/lib/install/bin/webpack-dev-server.tt +43 -0
  14. data/lib/install/bin/webpack.tt +27 -0
  15. data/lib/install/config/.babelrc +17 -0
  16. data/lib/install/config/.postcssrc.yml +3 -0
  17. data/lib/install/config/loaders/core/assets.js +12 -0
  18. data/lib/install/config/loaders/core/babel.js +5 -0
  19. data/lib/install/config/loaders/core/coffee.js +4 -0
  20. data/lib/install/config/loaders/core/erb.js +9 -0
  21. data/lib/install/config/loaders/core/sass.js +15 -0
  22. data/lib/install/config/loaders/installers/angular.js +4 -0
  23. data/lib/install/config/loaders/installers/elm.js +20 -0
  24. data/lib/install/config/loaders/installers/react.js +5 -0
  25. data/lib/install/config/loaders/installers/vue.js +41 -0
  26. data/lib/install/config/webpack/configuration.js +35 -0
  27. data/lib/install/config/webpack/development.js +32 -0
  28. data/lib/install/config/webpack/production.js +35 -0
  29. data/lib/install/config/webpack/shared.js +58 -0
  30. data/lib/install/config/webpack/test.js +6 -0
  31. data/lib/install/config/webpacker.yml +38 -0
  32. data/lib/install/elm.rb +33 -0
  33. data/lib/install/examples/angular/hello_angular.js +7 -0
  34. data/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  35. data/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  36. data/lib/install/examples/angular/hello_angular/index.ts +6 -0
  37. data/lib/install/examples/angular/hello_angular/polyfills.ts +19 -0
  38. data/lib/install/examples/angular/tsconfig.json +19 -0
  39. data/lib/install/examples/elm/Main.elm +54 -0
  40. data/lib/install/examples/elm/hello_elm.js +11 -0
  41. data/lib/install/examples/react/.babelrc +6 -0
  42. data/lib/install/examples/react/hello_react.jsx +26 -0
  43. data/lib/install/examples/vue/app.vue +22 -0
  44. data/lib/install/examples/vue/hello_vue.js +15 -0
  45. data/lib/install/javascript/packs/application.js +10 -0
  46. data/lib/install/react.rb +36 -0
  47. data/lib/install/template.rb +44 -0
  48. data/lib/install/vue.rb +19 -0
  49. data/lib/tasks/installers.rake +22 -0
  50. data/lib/tasks/webpacker.rake +19 -0
  51. data/lib/tasks/webpacker/check_node.rake +20 -0
  52. data/lib/tasks/webpacker/check_webpack_binstubs.rake +11 -0
  53. data/lib/tasks/webpacker/check_yarn.rake +15 -0
  54. data/lib/tasks/webpacker/clobber.rake +17 -0
  55. data/lib/tasks/webpacker/compile.rake +38 -0
  56. data/lib/tasks/webpacker/install.rake +23 -0
  57. data/lib/tasks/webpacker/verify_install.rake +18 -0
  58. data/lib/tasks/webpacker/yarn_install.rake +6 -0
  59. data/lib/webpacker-legacy.rb +2 -0
  60. data/lib/webpacker.rb +40 -0
  61. data/lib/webpacker/compiler.rb +20 -0
  62. data/lib/webpacker/configuration.rb +60 -0
  63. data/lib/webpacker/env.rb +23 -0
  64. data/lib/webpacker/file_loader.rb +24 -0
  65. data/lib/webpacker/helper.rb +62 -0
  66. data/lib/webpacker/manifest.rb +51 -0
  67. data/lib/webpacker/railtie.rb +18 -0
  68. data/lib/webpacker/version.rb +3 -0
  69. data/package.json +31 -0
  70. data/test/configuration_test.rb +32 -0
  71. data/test/env_test.rb +14 -0
  72. data/test/helper_test.rb +23 -0
  73. data/test/manifest_test.rb +30 -0
  74. data/test/test_app/config/secrets.yml +5 -0
  75. data/test/test_app/public/packs/manifest.json +4 -0
  76. data/test/webpacker_test.rb +15 -0
  77. data/webpacker.gemspec +23 -0
  78. data/yarn.lock +1014 -0
  79. metadata +200 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGZlYmIzYTQxYTFiMjJmYjkxNWQ2NzhlY2IwZDEyOTk1NjVjM2Y3NQ==
5
+ data.tar.gz: !binary |-
6
+ ZjUyMWMwMDE3NDY2OGM2MWZkNTRjMTFlZTY0ODU0YzEyOTI0MDRiMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODBmNDA2MzhmOTE1ZGJiZTA3NDgxN2IwN2Y3Yzg4NjE2ZTE2MGUyMjRlODk3
10
+ ZjJiZmVkMTg3ZGZkMTlmYzkwYjZlZGRkMTdkYTBiYjAxNTc5NmQ2ZGM0NjMw
11
+ ZDYwOWM2YjViNWFkNzdlZTViZTBkNjQwYTE4YjdlYWI4MzNlNzQ=
12
+ data.tar.gz: !binary |-
13
+ YjE1OGUzMzY3Njc4MGJiZDJlZGM1ZGM4ZmMyZDQyZGUxNTcyNmNjNTY0OWIy
14
+ Yzc2MzZiMmM2NDlkZDI5YjgzZTQyM2E1MTg4OWNkMzNmNTg2MzgzNmQ5YmJl
15
+ ZDZkZWZlZWZkZTkzMTliZmI4OTUyOTUzMGY3NDc5NmZmMjhlM2E=
data/.eslintrc.js ADDED
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ 'extends': 'airbnb',
3
+ 'rules': {
4
+ 'comma-dangle': ['error', 'never'],
5
+ 'import/no-unresolved': 'off',
6
+ 'import/no-extraneous-dependencies': 'off',
7
+ 'import/extensions': 'off',
8
+ semi: ['error', 'never'],
9
+ },
10
+ 'env': {
11
+ 'browser': true,
12
+ 'node': true,
13
+ },
14
+ };
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ /.bundle
2
+ /pkg
3
+ /test/test_app/log
4
+ node_modules
data/.rubocop.yml ADDED
@@ -0,0 +1,124 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
4
+ # to ignore them, so only the ones explicitly set in this file are enabled.
5
+ DisabledByDefault: true
6
+ Exclude:
7
+ - 'lib/install/templates/**'
8
+ - 'vendor/**/*'
9
+ - 'node_modules/**/*'
10
+
11
+ # Prefer &&/|| over and/or.
12
+ Style/AndOr:
13
+ Enabled: true
14
+
15
+ # Do not use braces for hash literals when they are the last argument of a
16
+ # method call.
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: true
19
+
20
+ # Align `when` with `case`.
21
+ Style/CaseIndentation:
22
+ Enabled: true
23
+
24
+ # Align comments with method definitions.
25
+ Style/CommentIndentation:
26
+ Enabled: true
27
+
28
+ # No extra empty lines.
29
+ Style/EmptyLines:
30
+ Enabled: true
31
+
32
+ # In a regular class definition, no empty lines around the body.
33
+ Style/EmptyLinesAroundClassBody:
34
+ Enabled: true
35
+
36
+ # In a regular method definition, no empty lines around the body.
37
+ Style/EmptyLinesAroundMethodBody:
38
+ Enabled: true
39
+
40
+ # In a regular module definition, no empty lines around the body.
41
+ Style/EmptyLinesAroundModuleBody:
42
+ Enabled: true
43
+
44
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
45
+ Style/HashSyntax:
46
+ Enabled: true
47
+
48
+ # Method definitions after `private` or `protected` isolated calls need one
49
+ # extra level of indentation.
50
+ Style/IndentationConsistency:
51
+ Enabled: true
52
+ EnforcedStyle: rails
53
+
54
+ # Two spaces, no tabs (for indentation).
55
+ Style/IndentationWidth:
56
+ Enabled: true
57
+
58
+ Style/SpaceAfterColon:
59
+ Enabled: true
60
+
61
+ Style/SpaceAfterComma:
62
+ Enabled: true
63
+
64
+ Style/SpaceAroundEqualsInParameterDefault:
65
+ Enabled: true
66
+
67
+ Style/SpaceAroundKeyword:
68
+ Enabled: true
69
+
70
+ Style/SpaceAroundOperators:
71
+ Enabled: true
72
+
73
+ Style/SpaceBeforeFirstArg:
74
+ Enabled: true
75
+
76
+ # Defining a method with parameters needs parentheses.
77
+ Style/MethodDefParentheses:
78
+ Enabled: true
79
+
80
+ # Use `foo {}` not `foo{}`.
81
+ Style/SpaceBeforeBlockBraces:
82
+ Enabled: true
83
+
84
+ # Use `foo { bar }` not `foo {bar}`.
85
+ Style/SpaceInsideBlockBraces:
86
+ Enabled: true
87
+
88
+ # Use `{ a: 1 }` not `{a:1}`.
89
+ Style/SpaceInsideHashLiteralBraces:
90
+ Enabled: true
91
+
92
+ Style/SpaceInsideParens:
93
+ Enabled: true
94
+
95
+ # Check quotes usage according to lint rule below.
96
+ Style/StringLiterals:
97
+ Enabled: true
98
+ EnforcedStyle: double_quotes
99
+
100
+ # Detect hard tabs, no hard tabs.
101
+ Style/Tab:
102
+ Enabled: true
103
+
104
+ # Blank lines should not have any spaces.
105
+ Style/TrailingBlankLines:
106
+ Enabled: true
107
+
108
+ # No trailing whitespace.
109
+ Style/TrailingWhitespace:
110
+ Enabled: true
111
+
112
+ # Use quotes for string literals when they are enough.
113
+ Style/UnneededPercentQ:
114
+ Enabled: true
115
+
116
+ # Align `end` with the matching keyword or starting expression except for
117
+ # assignments, where it should be aligned with the LHS.
118
+ Lint/EndAlignment:
119
+ Enabled: true
120
+ EnforcedStyleAlignWith: variable
121
+
122
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
123
+ Lint/RequireParentheses:
124
+ Enabled: true
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.6
5
+ - 2.3.3
6
+ - 2.4.1
7
+ cache:
8
+ bundler: true
9
+ directories:
10
+ - node_modules
11
+ yarn: true
12
+
13
+ install:
14
+ - bundle install
15
+ - nvm install node
16
+ - node -v
17
+ - npm i -g yarn
18
+ - yarn
19
+ script:
20
+ - yarn lint
21
+ - bundle exec rubocop
22
+ - bundle exec rake test
data/CHANGELOG.md ADDED
@@ -0,0 +1,148 @@
1
+ ## [2.0] - 2017-05-24
2
+
3
+
4
+ ### Fixed
5
+ - Update `.babelrc` to fix compilation issues - [#306](https://github.com/rails/webpacker/issues/306)
6
+
7
+ - Duplicated asset hosts - [#320](https://github.com/rails/webpacker/issues/320), [#397](https://github.com/rails/webpacker/pull/397)
8
+
9
+ - Missing asset host when defined as a `Proc` or on `ActionController::Base.asset_host` directly - [#397](https://github.com/rails/webpacker/pull/397)
10
+
11
+ - Incorrect asset host when running `webpacker:compile` or `bin/webpack` in development mode - [#397](https://github.com/rails/webpacker/pull/397)
12
+
13
+ - Update `webpacker:compile` task to use `stdout` and `stderr` for better logging - [#395](https://github.com/rails/webpacker/issues/395)
14
+
15
+ - ARGV support for `webpack-dev-server` - [#286](https://github.com/rails/webpacker/issues/286)
16
+
17
+
18
+ ### Added
19
+ - [Elm](http://elm-lang.org) support. You can now add Elm support via the following methods:
20
+ - New app: `rails new <app> --webpack=elm`
21
+ - Within an existing app: `rails webpacker:install:elm`
22
+
23
+ - Support for custom `public_output_path` paths independent of `source_entry_path` in `config/webpacker.yml`. `output` is also now relative to `public/`. - [#397](https://github.com/rails/webpacker/pull/397)
24
+
25
+ Before (compile to `public/packs`):
26
+ ```yaml
27
+ source_entry_path: packs
28
+ public_output_path: packs
29
+ ```
30
+ After (compile to `public/sweet/js`):
31
+ ```yaml
32
+ source_entry_path: packs
33
+ public_output_path: sweet/js
34
+ ```
35
+
36
+ - `https` option to use `https` mode, particularly on platforms like - https://community.c9.io/t/running-a-rails-app/1615 or locally - [#176](https://github.com/rails/webpacker/issues/176)
37
+
38
+ - [Babel] Dynamic import() and Class Fields and Static Properties babel plugin to `.babelrc`
39
+
40
+ ```json
41
+ {
42
+ "presets": [
43
+ ["env", {
44
+ "modules": false,
45
+ "targets": {
46
+ "browsers": "> 1%",
47
+ "uglify": true
48
+ },
49
+ "useBuiltIns": true
50
+ }]
51
+ ],
52
+
53
+ "plugins": [
54
+ "syntax-dynamic-import",
55
+ "transform-class-properties", { "spec": true }
56
+ ]
57
+ }
58
+ ```
59
+
60
+ - Source-map support for production bundle
61
+
62
+
63
+ #### Breaking Change
64
+
65
+ - Consolidate and flatten `paths.yml` and `development.server.yml` config into one file - `config/webpacker.yml` - [#403](https://github.com/rails/webpacker/pull/403). This is a breaking change and requires you to re-install webpacker and cleanup old configuration files.
66
+
67
+ ```bash
68
+ bundle update webpacker
69
+ bundle exec rails webpacker:install
70
+
71
+ # Remove old/unused configuration files
72
+ rm config/webpack/paths.yml
73
+ rm config/webpack/development.server.yml
74
+ rm config/webpack/development.server.js
75
+ ```
76
+
77
+
78
+ ## [1.2] - 2017-04-27
79
+ Some of the changes made requires you to run below commands to install new changes.
80
+
81
+ ```
82
+ bundle update webpacker
83
+ bundle exec rails webpacker:install
84
+ ```
85
+
86
+
87
+ ### Fixed
88
+ - Support Spring - [#205](https://github.com/rails/webpacker/issues/205)
89
+
90
+ ```ruby
91
+ Spring.after_fork { Webpacker.bootstrap } if defined?(Spring)
92
+ ```
93
+ - Check node version and yarn before installing webpacker - [#217](https://github.com/rails/webpacker/issues/217)
94
+
95
+ - Include webpacker helper to views - [#172](https://github.com/rails/webpacker/issues/172)
96
+
97
+ - Webpacker installer on windows - [#245](https://github.com/rails/webpacker/issues/245)
98
+
99
+ - Yarn duplication - [#278](https://github.com/rails/webpacker/issues/278)
100
+
101
+ - Add back Spring for `rails-erb-loader` - [#216](https://github.com/rails/webpacker/issues/216)
102
+
103
+ - Move babel presets and plugins to .babelrc - [#202](https://github.com/rails/webpacker/issues/202)
104
+
105
+
106
+ ### Added
107
+ - A changelog - [#211](https://github.com/rails/webpacker/issues/211)
108
+ - Minimize CSS assets - [#218](https://github.com/rails/webpacker/issues/218)
109
+ - Pack namespacing support - [#201](https://github.com/rails/webpacker/pull/201)
110
+
111
+ For example:
112
+ ```
113
+ app/javascript/packs/admin/hello_vue.js
114
+ app/javascript/packs/admin/hello.vue
115
+ app/javascript/packs/hello_vue.js
116
+ app/javascript/packs/hello.vue
117
+ ```
118
+ - Add tree-shaking support - [#250](https://github.com/rails/webpacker/pull/250)
119
+ - Add initial test case by @kimquy [#259](https://github.com/rails/webpacker/pull/259)
120
+ - Compile assets before test:controllers and test:system
121
+
122
+
123
+ ### Removed
124
+ - Webpack watcher - [#295](https://github.com/rails/webpacker/pull/295)
125
+
126
+
127
+ ## [1.1] - 2017-03-24
128
+
129
+ This release requires you to run below commands to install new features.
130
+
131
+ ```
132
+ bundle update webpacker
133
+ bundle exec rails webpacker:install
134
+
135
+ # if installed react, vue or angular
136
+ bundle exec rails webpacker:install:[react, angular, vue]
137
+ ```
138
+
139
+ ### Added (breaking changes)
140
+ - Static assets support - [#153](https://github.com/rails/webpacker/pull/153)
141
+ - Advanced webpack configuration - [#153](https://github.com/rails/webpacker/pull/153)
142
+
143
+
144
+ ### Removed
145
+
146
+ ```rb
147
+ config.x.webpacker[:digesting] = true
148
+ ```
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rails"
6
+ gem "rake", ">= 11.1"
7
+ gem "rubocop", ">= 0.47", require: false
8
+
9
+ group :test do
10
+ gem "minitest", "~> 5.0"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,137 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webpacker (1.2)
5
+ activesupport (>= 4.2)
6
+ multi_json (~> 1.2)
7
+ railties (>= 4.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (5.0.1)
13
+ actionpack (= 5.0.1)
14
+ nio4r (~> 1.2)
15
+ websocket-driver (~> 0.6.1)
16
+ actionmailer (5.0.1)
17
+ actionpack (= 5.0.1)
18
+ actionview (= 5.0.1)
19
+ activejob (= 5.0.1)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.0.1)
23
+ actionview (= 5.0.1)
24
+ activesupport (= 5.0.1)
25
+ rack (~> 2.0)
26
+ rack-test (~> 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.0.1)
30
+ activesupport (= 5.0.1)
31
+ builder (~> 3.1)
32
+ erubis (~> 2.7.0)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
35
+ activejob (5.0.1)
36
+ activesupport (= 5.0.1)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.0.1)
39
+ activesupport (= 5.0.1)
40
+ activerecord (5.0.1)
41
+ activemodel (= 5.0.1)
42
+ activesupport (= 5.0.1)
43
+ arel (~> 7.0)
44
+ activesupport (5.0.1)
45
+ concurrent-ruby (~> 1.0, >= 1.0.2)
46
+ i18n (~> 0.7)
47
+ minitest (~> 5.1)
48
+ tzinfo (~> 1.1)
49
+ arel (7.1.4)
50
+ ast (2.3.0)
51
+ builder (3.2.3)
52
+ concurrent-ruby (1.0.5)
53
+ erubis (2.7.0)
54
+ globalid (0.3.7)
55
+ activesupport (>= 4.1.0)
56
+ i18n (0.8.1)
57
+ loofah (2.0.3)
58
+ nokogiri (>= 1.5.9)
59
+ mail (2.6.4)
60
+ mime-types (>= 1.16, < 4)
61
+ method_source (0.8.2)
62
+ mime-types (3.1)
63
+ mime-types-data (~> 3.2015)
64
+ mime-types-data (3.2016.0521)
65
+ mini_portile2 (2.1.0)
66
+ minitest (5.10.1)
67
+ multi_json (1.12.1)
68
+ nio4r (1.2.1)
69
+ nokogiri (1.7.0.1)
70
+ mini_portile2 (~> 2.1.0)
71
+ parser (2.4.0.0)
72
+ ast (~> 2.2)
73
+ powerpack (0.1.1)
74
+ rack (2.0.1)
75
+ rack-test (0.6.3)
76
+ rack (>= 1.0)
77
+ rails (5.0.1)
78
+ actioncable (= 5.0.1)
79
+ actionmailer (= 5.0.1)
80
+ actionpack (= 5.0.1)
81
+ actionview (= 5.0.1)
82
+ activejob (= 5.0.1)
83
+ activemodel (= 5.0.1)
84
+ activerecord (= 5.0.1)
85
+ activesupport (= 5.0.1)
86
+ bundler (>= 1.3.0, < 2.0)
87
+ railties (= 5.0.1)
88
+ sprockets-rails (>= 2.0.0)
89
+ rails-dom-testing (2.0.2)
90
+ activesupport (>= 4.2.0, < 6.0)
91
+ nokogiri (~> 1.6)
92
+ rails-html-sanitizer (1.0.3)
93
+ loofah (~> 2.0)
94
+ railties (5.0.1)
95
+ actionpack (= 5.0.1)
96
+ activesupport (= 5.0.1)
97
+ method_source
98
+ rake (>= 0.8.7)
99
+ thor (>= 0.18.1, < 2.0)
100
+ rainbow (2.2.1)
101
+ rake (12.0.0)
102
+ rubocop (0.47.1)
103
+ parser (>= 2.3.3.1, < 3.0)
104
+ powerpack (~> 0.1)
105
+ rainbow (>= 1.99.1, < 3.0)
106
+ ruby-progressbar (~> 1.7)
107
+ unicode-display_width (~> 1.0, >= 1.0.1)
108
+ ruby-progressbar (1.8.1)
109
+ sprockets (3.7.1)
110
+ concurrent-ruby (~> 1.0)
111
+ rack (> 1, < 3)
112
+ sprockets-rails (3.2.0)
113
+ actionpack (>= 4.0)
114
+ activesupport (>= 4.0)
115
+ sprockets (>= 3.0.0)
116
+ thor (0.19.4)
117
+ thread_safe (0.3.6)
118
+ tzinfo (1.2.2)
119
+ thread_safe (~> 0.1)
120
+ unicode-display_width (1.1.3)
121
+ websocket-driver (0.6.5)
122
+ websocket-extensions (>= 0.1.0)
123
+ websocket-extensions (0.1.2)
124
+
125
+ PLATFORMS
126
+ ruby
127
+
128
+ DEPENDENCIES
129
+ bundler (~> 1.12)
130
+ minitest (~> 5.0)
131
+ rails
132
+ rake (>= 11.1)
133
+ rubocop (>= 0.47)
134
+ webpacker!
135
+
136
+ BUNDLED WITH
137
+ 1.14.6