webpacker 6.0.0.pre.2 → 6.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/jest.yml +5 -2
  3. data/.github/workflows/js-lint.yml +5 -2
  4. data/.github/workflows/rubocop.yml +1 -1
  5. data/.github/workflows/ruby.yml +17 -14
  6. data/.node-version +1 -1
  7. data/.rubocop.yml +106 -0
  8. data/CHANGELOG.md +36 -9
  9. data/CONTRIBUTING.md +1 -1
  10. data/Gemfile.lock +93 -90
  11. data/README.md +363 -107
  12. data/config/README.md +3 -0
  13. data/config/webpacker.yml +1 -0
  14. data/docs/deployment.md +9 -29
  15. data/docs/developing_webpacker.md +29 -0
  16. data/docs/troubleshooting.md +57 -25
  17. data/docs/v6_upgrade.md +75 -0
  18. data/gemfiles/Gemfile-rails-edge +1 -1
  19. data/gemfiles/Gemfile-rails.6.1.x +12 -0
  20. data/lib/install/config/webpacker.yml +5 -7
  21. data/lib/install/{javascript/packs → packs/entrypoints}/application.js +4 -3
  22. data/lib/install/template.rb +17 -10
  23. data/lib/tasks/webpacker/binstubs.rake +2 -2
  24. data/lib/tasks/webpacker/check_node.rake +3 -0
  25. data/lib/tasks/webpacker/check_yarn.rake +4 -1
  26. data/lib/tasks/webpacker/clobber.rake +1 -1
  27. data/lib/tasks/webpacker/install.rake +2 -2
  28. data/lib/tasks/webpacker/verify_config.rake +14 -0
  29. data/lib/tasks/webpacker/verify_install.rake +1 -11
  30. data/lib/webpacker.rb +1 -1
  31. data/lib/webpacker/commands.rb +2 -1
  32. data/lib/webpacker/compiler.rb +9 -3
  33. data/lib/webpacker/configuration.rb +19 -8
  34. data/lib/webpacker/dev_server.rb +6 -0
  35. data/lib/webpacker/dev_server_runner.rb +7 -2
  36. data/lib/webpacker/env.rb +5 -1
  37. data/lib/webpacker/helper.rb +26 -50
  38. data/lib/webpacker/instance.rb +4 -0
  39. data/lib/webpacker/manifest.rb +1 -2
  40. data/lib/webpacker/railtie.rb +1 -2
  41. data/lib/webpacker/runner.rb +1 -1
  42. data/lib/webpacker/version.rb +1 -1
  43. data/lib/webpacker/webpack_runner.rb +1 -0
  44. data/package.json +25 -29
  45. data/package/__tests__/development.js +3 -2
  46. data/package/__tests__/env.js +8 -4
  47. data/package/__tests__/index.js +9 -0
  48. data/package/babel/preset.js +24 -14
  49. data/package/env.js +7 -1
  50. data/package/environments/__tests__/base.js +7 -7
  51. data/package/environments/base.js +25 -25
  52. data/package/environments/development.js +7 -8
  53. data/package/environments/production.js +28 -30
  54. data/package/index.js +9 -2
  55. data/package/inliningCss.js +7 -0
  56. data/package/rules/babel.js +1 -1
  57. data/package/rules/coffee.js +5 -5
  58. data/package/rules/erb.js +5 -3
  59. data/package/rules/file.js +5 -3
  60. data/package/rules/index.js +9 -17
  61. data/package/rules/less.js +14 -10
  62. data/package/rules/raw.js +5 -0
  63. data/package/rules/sass.js +12 -9
  64. data/package/rules/stylus.js +26 -0
  65. data/package/utils/get_style_rule.js +28 -30
  66. data/package/utils/helpers.js +25 -0
  67. data/test/configuration_test.rb +3 -3
  68. data/test/dev_server_runner_test.rb +13 -2
  69. data/test/helper_test.rb +59 -60
  70. data/test/manifest_test.rb +16 -0
  71. data/test/mounted_app/test/dummy/config/webpacker.yml +4 -4
  72. data/test/test_app/app/{javascript/packs → packs/entrypoints}/application.js +1 -1
  73. data/test/test_app/app/{javascript/packs → packs/entrypoints}/multi_entry.css +0 -0
  74. data/test/test_app/app/{javascript/packs → packs/entrypoints}/multi_entry.js +0 -0
  75. data/test/test_app/config/webpacker.yml +4 -6
  76. data/test/test_app/config/webpacker_other_location.yml +79 -0
  77. data/test/test_app/public/packs/manifest.json +19 -5
  78. data/test/webpacker_test.rb +17 -0
  79. data/yarn.lock +1567 -1039
  80. metadata +24 -36
  81. data/docs/assets.md +0 -135
  82. data/docs/cloud9.md +0 -310
  83. data/docs/css.md +0 -303
  84. data/docs/docker.md +0 -68
  85. data/docs/engines.md +0 -213
  86. data/docs/env.md +0 -68
  87. data/docs/es6.md +0 -72
  88. data/docs/folder-structure.md +0 -66
  89. data/docs/integrations.md +0 -220
  90. data/docs/misc.md +0 -23
  91. data/docs/props.md +0 -187
  92. data/docs/react.md +0 -183
  93. data/docs/target.md +0 -22
  94. data/docs/testing.md +0 -147
  95. data/docs/typescript.md +0 -190
  96. data/docs/v4-upgrade.md +0 -142
  97. data/docs/webpack-dev-server.md +0 -94
  98. data/docs/webpack.md +0 -315
  99. data/docs/yarn.md +0 -23
  100. data/lib/install/examples/vue3/app.vue +0 -27
  101. data/lib/install/examples/vue3/hello_vue.js +0 -15
  102. data/lib/install/javascript/packs/application.css +0 -9
  103. data/package/babel/preset-react.js +0 -62
  104. data/package/rules/svg.js +0 -23
data/docs/yarn.md DELETED
@@ -1,23 +0,0 @@
1
- # Yarn
2
-
3
- Webpacker by default uses `yarn` as a package manager for `node_modules`
4
-
5
-
6
- ## Add a new npm module
7
-
8
- To add any new JS module you can use `yarn`:
9
-
10
- ```bash
11
- yarn add bootstrap material-ui
12
- ```
13
-
14
- ## Add an npm module to `devDependencies`
15
- To add a new JS module that will only be available to local development:
16
-
17
- ```bash
18
- yarn add --dev browser-sync
19
- ```
20
-
21
- Be careful not to add any build or app related JS modules in this fashion. Adding JS modules to `devDependencies` [will block them from being installed in **any** production environment](https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production-true-false).
22
-
23
- Docs from JS modules may instruct you to use `--dev` or `devDependencies`, but this is generally under the assumption that you are using a `node.js` workflow.
@@ -1,27 +0,0 @@
1
- <template>
2
- <p>
3
- {{ message }}
4
- </p>
5
- </template>
6
-
7
- <script>
8
- import { ref } from 'vue'
9
-
10
- export default {
11
- name: 'HelloWorld',
12
- setup() {
13
- const message = ref('Hello World')
14
-
15
- return {
16
- message
17
- }
18
- }
19
- }
20
- </script>
21
-
22
- <style scoped>
23
- p {
24
- font-size: 2em;
25
- text-align: center;
26
- }
27
- </style>
@@ -1,15 +0,0 @@
1
- /* eslint no-console: 0 */
2
- // Run this example by adding <%= javascript_pack_tag 'hello_vue' %> (and
3
- // <%= stylesheet_pack_tag 'hello_vue' %> if you have styles in your component)
4
- // to the head of your layout file,
5
- // like app/views/layouts/application.html.erb.
6
- // Create a div container with the id 'vue-app' <div id='vue-app'></div>
7
- // It renders <p>Hello Vue</p> into it.
8
-
9
- import { createApp } from "vue";
10
- import App from "../app.vue";
11
-
12
- document.addEventListener("DOMContentLoaded", () => {
13
- const app = createApp(App);
14
- app.mount("#vue-app");
15
- });
@@ -1,9 +0,0 @@
1
- /*
2
- Any CSS added to this file or imported from this file, e.g. `@import '../stylesheets/my-css.css'`,
3
- will be included in the "application" pack. Any CSS imported from application.js or as part of the
4
- application.js dependency graph, e.g. `import '../stylesheets/my-css.css'` will also be included
5
- in the "application" pack.
6
-
7
- To reference this file, add <%= stylesheet_pack_tag 'application' %> to the appropriate
8
- layout file, like app/views/layouts/application.html.erb
9
- */
@@ -1,62 +0,0 @@
1
- module.exports = function config(api) {
2
- const validEnv = ['development', 'test', 'production']
3
- const currentEnv = api.env()
4
- const isDevelopmentEnv = api.env('development')
5
- const isProductionEnv = api.env('production')
6
- const isTestEnv = api.env('test')
7
-
8
- if (!validEnv.includes(currentEnv)) {
9
- throw new Error(
10
- `Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(currentEnv)}".`
11
- )
12
- }
13
-
14
- return {
15
- presets: [
16
- isTestEnv && [
17
- '@babel/preset-env',
18
- {
19
- targets: { node: 'current' },
20
- modules: 'commonjs'
21
- }
22
- ],
23
- (isProductionEnv || isDevelopmentEnv) && [
24
- '@babel/preset-env',
25
- {
26
- useBuiltIns: 'entry',
27
- corejs: '3.8',
28
- modules: false,
29
- bugfixes: true,
30
- loose: true,
31
- exclude: ['transform-typeof-symbol']
32
- }
33
- ],
34
- [
35
- '@babel/preset-react',
36
- {
37
- development: isDevelopmentEnv || isTestEnv,
38
- useBuiltIns: true
39
- }
40
- ]
41
- ].filter(Boolean),
42
- plugins: [
43
- 'babel-plugin-macros',
44
- [
45
- '@babel/plugin-proposal-class-properties',
46
- { loose: true }
47
- ],
48
- [
49
- '@babel/plugin-transform-runtime',
50
- {
51
- helpers: false,
52
- regenerator: true,
53
- corejs: false
54
- }
55
- ],
56
- isProductionEnv && [
57
- 'babel-plugin-transform-react-remove-prop-types',
58
- { removeImport: true }
59
- ]
60
- ].filter(Boolean)
61
- }
62
- }
data/package/rules/svg.js DELETED
@@ -1,23 +0,0 @@
1
- /* eslint global-require: 0 */
2
- /* eslint import/no-dynamic-require: 0 */
3
-
4
- module.exports = {
5
- test: /\.svg$/i,
6
- type: 'asset/inline',
7
- generator: {
8
- dataUrl: (content) => {
9
- let optimisedContent = content
10
-
11
- try {
12
- if (require.resolve('mini-svg-data-uri')) {
13
- const svgToMiniDataURI = require('mini-svg-data-uri')
14
- optimisedContent = svgToMiniDataURI(content.toString())
15
- }
16
- } catch (e) {
17
- /* Work out what to print here */
18
- }
19
-
20
- return optimisedContent
21
- }
22
- }
23
- }