webpacker-jets 3.2.100

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.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintignore +4 -0
  3. data/.eslintrc.js +14 -0
  4. data/.gitignore +6 -0
  5. data/.rubocop.yml +124 -0
  6. data/.travis.yml +32 -0
  7. data/CHANGELOG.md +523 -0
  8. data/Gemfile +13 -0
  9. data/Gemfile.lock +154 -0
  10. data/MIT-LICENSE +20 -0
  11. data/README.md +445 -0
  12. data/Rakefile +12 -0
  13. data/docs/assets.md +106 -0
  14. data/docs/cloud9.md +310 -0
  15. data/docs/css.md +116 -0
  16. data/docs/deployment.md +74 -0
  17. data/docs/docker.md +49 -0
  18. data/docs/env.md +65 -0
  19. data/docs/es6.md +53 -0
  20. data/docs/folder-structure.md +66 -0
  21. data/docs/misc.md +23 -0
  22. data/docs/props.md +223 -0
  23. data/docs/testing.md +128 -0
  24. data/docs/troubleshooting.md +119 -0
  25. data/docs/typescript.md +116 -0
  26. data/docs/webpack-dev-server.md +92 -0
  27. data/docs/webpack.md +297 -0
  28. data/docs/yarn.md +12 -0
  29. data/exe/webpack +8 -0
  30. data/exe/webpack-dev-server +8 -0
  31. data/gemfiles/Gemfile-rails-edge +13 -0
  32. data/gemfiles/Gemfile-rails.4.2.x +10 -0
  33. data/gemfiles/Gemfile-rails.5.0.x +10 -0
  34. data/gemfiles/Gemfile-rails.5.1.x +10 -0
  35. data/lib/install/angular.rb +27 -0
  36. data/lib/install/coffee.rb +22 -0
  37. data/lib/install/config/.babelrc +18 -0
  38. data/lib/install/config/.postcssrc.yml +3 -0
  39. data/lib/install/config/webpack/development.js +3 -0
  40. data/lib/install/config/webpack/environment.js +3 -0
  41. data/lib/install/config/webpack/production.js +3 -0
  42. data/lib/install/config/webpack/staging.js +3 -0
  43. data/lib/install/config/webpack/test.js +3 -0
  44. data/lib/install/config/webpacker.yml +79 -0
  45. data/lib/install/elm.rb +38 -0
  46. data/lib/install/erb.rb +22 -0
  47. data/lib/install/examples/angular/hello_angular.js +7 -0
  48. data/lib/install/examples/angular/hello_angular/app/app.component.ts +9 -0
  49. data/lib/install/examples/angular/hello_angular/app/app.module.ts +16 -0
  50. data/lib/install/examples/angular/hello_angular/index.ts +8 -0
  51. data/lib/install/examples/angular/hello_angular/polyfills.ts +73 -0
  52. data/lib/install/examples/angular/tsconfig.json +19 -0
  53. data/lib/install/examples/coffee/hello_coffee.coffee +4 -0
  54. data/lib/install/examples/elm/Main.elm +54 -0
  55. data/lib/install/examples/elm/hello_elm.js +12 -0
  56. data/lib/install/examples/erb/hello_erb.js.erb +6 -0
  57. data/lib/install/examples/react/.babelrc +6 -0
  58. data/lib/install/examples/react/hello_react.jsx +26 -0
  59. data/lib/install/examples/vue/app.vue +22 -0
  60. data/lib/install/examples/vue/hello_vue.js +70 -0
  61. data/lib/install/javascript/packs/application.js +10 -0
  62. data/lib/install/loaders/coffee.js +6 -0
  63. data/lib/install/loaders/elm.js +23 -0
  64. data/lib/install/loaders/erb.js +11 -0
  65. data/lib/install/loaders/typescript.js +6 -0
  66. data/lib/install/loaders/vue.js +13 -0
  67. data/lib/install/react.rb +28 -0
  68. data/lib/install/template.rb +37 -0
  69. data/lib/install/vue.rb +26 -0
  70. data/lib/tasks/installers.rake +24 -0
  71. data/lib/tasks/webpacker.rake +22 -0
  72. data/lib/tasks/webpacker/check_binstubs.rake +12 -0
  73. data/lib/tasks/webpacker/check_node.rake +24 -0
  74. data/lib/tasks/webpacker/check_yarn.rake +24 -0
  75. data/lib/tasks/webpacker/clobber.rake +16 -0
  76. data/lib/tasks/webpacker/compile.rake +41 -0
  77. data/lib/tasks/webpacker/install.rake +13 -0
  78. data/lib/tasks/webpacker/verify_install.rake +16 -0
  79. data/lib/tasks/webpacker/yarn_install.rake +6 -0
  80. data/lib/webpacker.rb +32 -0
  81. data/lib/webpacker/commands.rb +23 -0
  82. data/lib/webpacker/compiler.rb +88 -0
  83. data/lib/webpacker/configuration.rb +87 -0
  84. data/lib/webpacker/dev_server.rb +61 -0
  85. data/lib/webpacker/dev_server_proxy.rb +26 -0
  86. data/lib/webpacker/dev_server_runner.rb +51 -0
  87. data/lib/webpacker/helper.rb +66 -0
  88. data/lib/webpacker/instance.rb +44 -0
  89. data/lib/webpacker/manifest.rb +75 -0
  90. data/lib/webpacker/railtie.rb +82 -0
  91. data/lib/webpacker/rake_tasks.rb +6 -0
  92. data/lib/webpacker/runner.rb +22 -0
  93. data/lib/webpacker/version.rb +9 -0
  94. data/lib/webpacker/webpack_runner.rb +15 -0
  95. data/package.json +67 -0
  96. data/package/__tests__/environment.js +74 -0
  97. data/package/config.js +34 -0
  98. data/package/config_types/__tests__/config_list.js +123 -0
  99. data/package/config_types/__tests__/config_object.js +43 -0
  100. data/package/config_types/config_list.js +85 -0
  101. data/package/config_types/config_object.js +55 -0
  102. data/package/config_types/index.js +7 -0
  103. data/package/environment.js +116 -0
  104. data/package/environments/development.js +46 -0
  105. data/package/environments/production.js +37 -0
  106. data/package/environments/test.js +3 -0
  107. data/package/index.js +20 -0
  108. data/package/rules/babel.js +13 -0
  109. data/package/rules/css.js +39 -0
  110. data/package/rules/file.js +13 -0
  111. data/package/rules/index.js +11 -0
  112. data/package/rules/sass.js +15 -0
  113. data/package/utils/__tests__/deep_assign.js +11 -0
  114. data/package/utils/__tests__/deep_merge.js +10 -0
  115. data/package/utils/__tests__/objectify.js +9 -0
  116. data/package/utils/deep_assign.js +22 -0
  117. data/package/utils/deep_merge.js +23 -0
  118. data/package/utils/helpers.js +32 -0
  119. data/package/utils/objectify.js +4 -0
  120. data/test/command_test.rb +27 -0
  121. data/test/compiler_test.rb +35 -0
  122. data/test/configuration_test.rb +69 -0
  123. data/test/dev_server_test.rb +24 -0
  124. data/test/helper_test.rb +52 -0
  125. data/test/manifest_test.rb +28 -0
  126. data/test/rake_tasks_test.rb +29 -0
  127. data/test/test_app/Rakefile +3 -0
  128. data/test/test_app/app/javascript/packs/application.js +10 -0
  129. data/test/test_app/config/application.rb +11 -0
  130. data/test/test_app/config/environment.rb +4 -0
  131. data/test/test_app/config/webpacker.yml +65 -0
  132. data/test/test_app/public/packs/manifest.json +6 -0
  133. data/test/test_helper.rb +29 -0
  134. data/webpacker-jets.gemspec +29 -0
  135. data/yarn.lock +5768 -0
  136. metadata +250 -0
@@ -0,0 +1,3 @@
1
+ plugins:
2
+ postcss-import: {}
3
+ postcss-cssnext: {}
@@ -0,0 +1,3 @@
1
+ const environment = require('./environment')
2
+
3
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const { environment } = require('@rails/webpacker')
2
+
3
+ module.exports = environment
@@ -0,0 +1,3 @@
1
+ const environment = require('./environment')
2
+
3
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const environment = require('./environment')
2
+
3
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,3 @@
1
+ const environment = require('./environment')
2
+
3
+ module.exports = environment.toWebpackConfig()
@@ -0,0 +1,79 @@
1
+ # Note: You must restart bin/webpack-dev-server for changes to take effect
2
+
3
+ default: &default
4
+ source_path: app/javascript
5
+ source_entry_path: packs
6
+ public_output_path: packs
7
+ cache_path: tmp/cache/webpacker
8
+
9
+ # Additional paths webpack should lookup modules
10
+ # ['app/assets', 'engine/foo/app/assets']
11
+ resolved_paths: []
12
+
13
+ # Reload manifest.json on all requests so we reload latest compiled packs
14
+ cache_manifest: false
15
+
16
+ extensions:
17
+ - .coffee
18
+ - .erb
19
+ - .js
20
+ - .jsx
21
+ - .ts
22
+ - .vue
23
+ - .sass
24
+ - .scss
25
+ - .css
26
+ - .png
27
+ - .svg
28
+ - .gif
29
+ - .jpeg
30
+ - .jpg
31
+
32
+ development:
33
+ <<: *default
34
+ compile: true
35
+
36
+ # Reference: https://webpack.js.org/configuration/dev-server/
37
+ dev_server:
38
+ https: false
39
+ host: localhost
40
+ port: 3035
41
+ public: localhost:3035
42
+ hmr: false
43
+ # Inline should be set to true if using HMR
44
+ inline: true
45
+ overlay: true
46
+ compress: true
47
+ disable_host_check: true
48
+ use_local_ip: false
49
+ quiet: false
50
+ headers:
51
+ 'Access-Control-Allow-Origin': '*'
52
+ watch_options:
53
+ ignored: /node_modules/
54
+
55
+
56
+ test:
57
+ <<: *default
58
+ compile: true
59
+
60
+ # Compile test packs to a separate directory
61
+ public_output_path: packs-test
62
+
63
+ staging:
64
+ <<: *default
65
+
66
+ # Production depends on precompilation of packs prior to booting for performance.
67
+ compile: false
68
+
69
+ # Cache manifest.json for performance
70
+ cache_manifest: true
71
+
72
+ production:
73
+ <<: *default
74
+
75
+ # Production depends on precompilation of packs prior to booting for performance.
76
+ compile: false
77
+
78
+ # Cache manifest.json for performance
79
+ cache_manifest: true
@@ -0,0 +1,38 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying elm loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/elm.js", Jets.root.join("config/webpack/loaders/elm.js").to_s
5
+
6
+ say "Adding elm loader to config/webpack/environment.js"
7
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
8
+ "const elm = require('./loaders/elm')\n",
9
+ after: "require('@rails/webpacker')\n"
10
+
11
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
12
+ "environment.loaders.append('elm', elm)\n",
13
+ before: "module.exports"
14
+
15
+ say "Copying Elm example entry file to #{Webpacker.config.source_entry_path}"
16
+ copy_file "#{__dir__}/examples/elm/hello_elm.js",
17
+ "#{Webpacker.config.source_entry_path}/hello_elm.js"
18
+
19
+ say "Copying Elm app file to #{Webpacker.config.source_path}"
20
+ copy_file "#{__dir__}/examples/elm/Main.elm",
21
+ "#{Webpacker.config.source_path}/Main.elm"
22
+
23
+ say "Installing all Elm dependencies"
24
+ run "yarn add elm elm-webpack-loader"
25
+ run "yarn add --dev elm-hot-loader"
26
+ run "yarn run elm package install -- --yes"
27
+
28
+ say "Updating webpack paths to include Elm file extension"
29
+ insert_into_file Webpacker.config.config_path, " - .elm\n", after: /extensions:\n/
30
+
31
+ say "Updating Elm source location"
32
+ gsub_file "elm-package.json", /\"\.\"\n/,
33
+ %("#{Webpacker.config.source_path.relative_path_from(Jets.root)}"\n)
34
+
35
+ say "Updating .gitignore to include elm-stuff folder"
36
+ insert_into_file ".gitignore", "/elm-stuff\n", before: "/node_modules\n"
37
+
38
+ say "Webpacker now supports Elm 🎉", :green
@@ -0,0 +1,22 @@
1
+ require "webpacker/configuration"
2
+
3
+ say "Copying erb loader to config/webpack/loaders"
4
+ copy_file "#{__dir__}/loaders/erb.js", Jets.root.join("config/webpack/loaders/erb.js").to_s
5
+
6
+ say "Adding erb loader to config/webpack/environment.js"
7
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
8
+ "const erb = require('./loaders/erb')\n",
9
+ after: "require('@rails/webpacker')\n"
10
+
11
+ insert_into_file Jets.root.join("config/webpack/environment.js").to_s,
12
+ "environment.loaders.append('erb', erb)\n",
13
+ before: "module.exports"
14
+
15
+ say "Copying the example entry file to #{Webpacker.config.source_entry_path}"
16
+ copy_file "#{__dir__}/examples/erb/hello_erb.js.erb",
17
+ "#{Webpacker.config.source_entry_path}/hello_erb.js.erb"
18
+
19
+ say "Installing all Erb dependencies"
20
+ run "yarn add rails-erb-loader"
21
+
22
+ say "Webpacker now supports Erb in JS 🎉", :green
@@ -0,0 +1,7 @@
1
+ // Run this Angular example by adding the following HTML markup to your view:
2
+ //
3
+ // <hello-angular>Loading...</hello-angular>
4
+ //
5
+ // <%= javascript_pack_tag 'hello_angular' %>
6
+
7
+ require('../hello_angular')
@@ -0,0 +1,9 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'hello-angular',
5
+ template: `<h1>Hello {{name}}</h1>`
6
+ })
7
+ export class AppComponent {
8
+ name = 'Angular!';
9
+ }
@@ -0,0 +1,16 @@
1
+ import { BrowserModule } from '@angular/platform-browser';
2
+ import { NgModule } from '@angular/core';
3
+
4
+ import { AppComponent } from './app.component';
5
+
6
+ @NgModule({
7
+ declarations: [
8
+ AppComponent
9
+ ],
10
+ imports: [
11
+ BrowserModule
12
+ ],
13
+ providers: [],
14
+ bootstrap: [AppComponent]
15
+ })
16
+ export class AppModule { }
@@ -0,0 +1,8 @@
1
+ import './polyfills.ts';
2
+
3
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
4
+ import { AppModule } from './app/app.module';
5
+
6
+ document.addEventListener('DOMContentLoaded', () => {
7
+ platformBrowserDynamic().bootstrapModule(AppModule);
8
+ });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * This file includes polyfills needed by Angular and is loaded before the app.
3
+ * You can add your own extra polyfills to this file.
4
+ *
5
+ * This file is divided into 2 sections:
6
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8
+ * file.
9
+ *
10
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13
+ *
14
+ * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15
+ */
16
+
17
+ /***************************************************************************************************
18
+ * BROWSER POLYFILLS
19
+ */
20
+
21
+ /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22
+ // import 'core-js/es6/symbol';
23
+ // import 'core-js/es6/object';
24
+ // import 'core-js/es6/function';
25
+ // import 'core-js/es6/parse-int';
26
+ // import 'core-js/es6/parse-float';
27
+ // import 'core-js/es6/number';
28
+ // import 'core-js/es6/math';
29
+ // import 'core-js/es6/string';
30
+ // import 'core-js/es6/date';
31
+ // import 'core-js/es6/array';
32
+ // import 'core-js/es6/regexp';
33
+ // import 'core-js/es6/map';
34
+ // import 'core-js/es6/weak-map';
35
+ // import 'core-js/es6/set';
36
+
37
+ /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38
+ // import 'classlist.js'; // Run `npm install --save classlist.js`.
39
+
40
+ /** Evergreen browsers require these. **/
41
+ import 'core-js/es6/reflect';
42
+ import 'core-js/es7/reflect';
43
+
44
+
45
+ /**
46
+ * Required to support Web Animations `@angular/animation`.
47
+ * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
48
+ **/
49
+ // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
50
+
51
+
52
+
53
+ /***************************************************************************************************
54
+ * Zone JS is required by Angular itself.
55
+ */
56
+ import 'zone.js/dist/zone';
57
+ // import 'zone.js/dist/long-stack-trace-zone' // async stack traces with zone.js
58
+
59
+
60
+
61
+ /***************************************************************************************************
62
+ * APPLICATION IMPORTS
63
+ */
64
+
65
+ /**
66
+ * Date, currency, decimal and percent pipes.
67
+ * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
68
+ */
69
+ // import 'intl'; // Run `npm install --save intl`.
70
+ /**
71
+ * Need to import at least one locale-data with intl.
72
+ */
73
+ // import 'intl/locale-data/jsonp/en';
@@ -0,0 +1,19 @@
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
+ },
12
+ "exclude": [
13
+ "**/*.spec.ts",
14
+ "node_modules",
15
+ "vendor",
16
+ "public"
17
+ ],
18
+ "compileOnSave": false
19
+ }
@@ -0,0 +1,4 @@
1
+ # Run this example by adding <%%= javascript_pack_tag 'hello_coffee' %> to the head of your layout file,
2
+ # like app/views/layouts/application.html.erb.
3
+
4
+ console.log 'Hello world from coffeescript'
@@ -0,0 +1,54 @@
1
+ module Main exposing (..)
2
+
3
+ import Html exposing (Html, h1, text)
4
+ import Html.Attributes exposing (style)
5
+
6
+ -- MODEL
7
+
8
+ type alias Model =
9
+ {
10
+ }
11
+
12
+ -- INIT
13
+
14
+ init : (Model, Cmd Message)
15
+ init =
16
+ (Model, Cmd.none)
17
+
18
+ -- VIEW
19
+
20
+ view : Model -> Html Message
21
+ view model =
22
+ -- The inline style is being used for example purposes in order to keep this example simple and
23
+ -- avoid loading additional resources. Use a proper stylesheet when building your own app.
24
+ h1 [style [("display", "flex"), ("justify-content", "center")]]
25
+ [text "Hello Elm!"]
26
+
27
+ -- MESSAGE
28
+
29
+ type Message
30
+ = None
31
+
32
+ -- UPDATE
33
+
34
+ update : Message -> Model -> (Model, Cmd Message)
35
+ update message model =
36
+ (model, Cmd.none)
37
+
38
+ -- SUBSCRIPTIONS
39
+
40
+ subscriptions : Model -> Sub Message
41
+ subscriptions model =
42
+ Sub.none
43
+
44
+ -- MAIN
45
+
46
+ main : Program Never Model Message
47
+ main =
48
+ Html.program
49
+ {
50
+ init = init,
51
+ view = view,
52
+ update = update,
53
+ subscriptions = subscriptions
54
+ }
@@ -0,0 +1,12 @@
1
+ // Run this example by adding <%= javascript_pack_tag "hello_elm" %> to the
2
+ // head of your layout file, like app/views/layouts/application.html.erb.
3
+ // It will render "Hello Elm!" within the page.
4
+
5
+ import Elm from '../Main'
6
+
7
+ document.addEventListener('DOMContentLoaded', () => {
8
+ const target = document.createElement('div')
9
+
10
+ document.body.appendChild(target)
11
+ Elm.Main.embed(target)
12
+ })
@@ -0,0 +1,6 @@
1
+ // Run this example by adding <%%= javascript_pack_tag 'hello_erb' %> to the head of your layout file,
2
+ // like app/views/layouts/application.html.erb.
3
+
4
+ <% name = 'Erb' %>
5
+
6
+ console.log('Hello world from <%= name %>')
@@ -0,0 +1,6 @@
1
+ {
2
+ "presets": [
3
+ ["env", { "modules": false } ],
4
+ "react"
5
+ ]
6
+ }
@@ -0,0 +1,26 @@
1
+ // Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
2
+ // like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
3
+ // of the page.
4
+
5
+ import React from 'react'
6
+ import ReactDOM from 'react-dom'
7
+ import PropTypes from 'prop-types'
8
+
9
+ const Hello = props => (
10
+ <div>Hello {props.name}!</div>
11
+ )
12
+
13
+ Hello.defaultProps = {
14
+ name: 'David'
15
+ }
16
+
17
+ Hello.propTypes = {
18
+ name: PropTypes.string
19
+ }
20
+
21
+ document.addEventListener('DOMContentLoaded', () => {
22
+ ReactDOM.render(
23
+ <Hello name="React" />,
24
+ document.body.appendChild(document.createElement('div')),
25
+ )
26
+ })
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <div id="app">
3
+ <p>{{ message }}</p>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ data: function () {
10
+ return {
11
+ message: "Hello Vue!"
12
+ }
13
+ }
14
+ }
15
+ </script>
16
+
17
+ <style scoped>
18
+ p {
19
+ font-size: 2em;
20
+ text-align: center;
21
+ }
22
+ </style>