shakapacker 6.5.4 → 7.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.js +1 -0
- data/.github/FUNDING.yml +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +11 -7
- data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +14 -0
- data/.github/workflows/dummy.yml +21 -0
- data/.github/workflows/generator.yml +37 -0
- data/.github/workflows/jest.yml +2 -2
- data/.github/workflows/js-lint.yml +2 -2
- data/.github/workflows/rubocop.yml +1 -1
- data/.github/workflows/ruby-backward-compatibility.yml +39 -0
- data/.github/workflows/ruby.yml +5 -7
- data/.gitignore +6 -3
- data/.rspec +1 -0
- data/CHANGELOG.md +83 -2
- data/CONTRIBUTING.md +84 -18
- data/Gemfile.development_dependencies +3 -1
- data/README.md +159 -97
- data/Rakefile +46 -6
- data/config/shakapacker.yml +1 -0
- data/docs/deployment.md +11 -10
- data/docs/{developing_webpacker.md → developing_shakapacker.md} +5 -5
- data/docs/react.md +10 -6
- data/docs/style_loader_vs_mini_css.md +3 -3
- data/docs/troubleshooting.md +22 -18
- data/docs/using_esbuild_loader.md +5 -3
- data/docs/using_swc_loader.md +2 -2
- data/docs/v6_upgrade.md +9 -13
- data/docs/v7_upgrade.md +59 -0
- data/gemfiles/Gemfile-rails-edge +1 -1
- data/gemfiles/Gemfile-rails.6.0.x +1 -1
- data/gemfiles/Gemfile-rails.6.1.x +1 -1
- data/gemfiles/Gemfile-rails.7.0.x +1 -1
- data/lib/install/bin/shakapacker +13 -0
- data/lib/install/bin/shakapacker-dev-server +13 -0
- data/lib/install/binstubs.rb +3 -1
- data/lib/install/config/{webpacker.yml → shakapacker.yml} +28 -11
- data/lib/install/config/webpack/webpack.config.js +3 -2
- data/lib/install/template.rb +51 -34
- data/lib/{webpacker → shakapacker}/base_strategy.rb +2 -2
- data/lib/{webpacker → shakapacker}/commands.rb +4 -4
- data/lib/{webpacker → shakapacker}/compiler.rb +43 -15
- data/lib/{webpacker → shakapacker}/compiler_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/configuration.rb +52 -21
- data/lib/shakapacker/deprecation_helper.rb +87 -0
- data/lib/{webpacker → shakapacker}/dev_server.rb +27 -4
- data/lib/{webpacker → shakapacker}/dev_server_proxy.rb +4 -4
- data/lib/shakapacker/dev_server_runner.rb +104 -0
- data/lib/{webpacker → shakapacker}/digest_strategy.rb +6 -6
- data/lib/{webpacker → shakapacker}/env.rb +8 -8
- data/lib/{webpacker → shakapacker}/helper.rb +40 -29
- data/lib/shakapacker/instance.rb +50 -0
- data/lib/{webpacker → shakapacker}/manifest.rb +14 -14
- data/lib/{webpacker → shakapacker}/mtime_strategy.rb +5 -5
- data/lib/shakapacker/railtie.rb +70 -0
- data/lib/shakapacker/runner.rb +28 -0
- data/lib/shakapacker/utils/version_syntax_converter.rb +2 -2
- data/lib/{webpacker → shakapacker}/version.rb +2 -2
- data/lib/{webpacker → shakapacker}/version_checker.rb +8 -8
- data/lib/shakapacker/webpack_runner.rb +67 -0
- data/lib/shakapacker.rb +51 -1
- data/lib/tasks/shakapacker/binstubs.rake +15 -0
- data/lib/tasks/shakapacker/check_binstubs.rake +29 -0
- data/lib/tasks/shakapacker/check_node.rake +31 -0
- data/lib/tasks/shakapacker/check_yarn.rake +33 -0
- data/lib/tasks/shakapacker/clean.rake +23 -0
- data/lib/tasks/shakapacker/clobber.rake +18 -0
- data/lib/tasks/shakapacker/compile.rake +28 -0
- data/lib/tasks/shakapacker/info.rake +21 -0
- data/lib/tasks/shakapacker/install.rake +17 -0
- data/lib/tasks/shakapacker/verify_config.rake +12 -0
- data/lib/tasks/shakapacker/verify_install.rake +4 -0
- data/lib/tasks/shakapacker/yarn_install.rake +24 -0
- data/lib/tasks/shakapacker.rake +18 -0
- data/lib/tasks/webpacker/binstubs.rake +5 -11
- data/lib/tasks/webpacker/check_binstubs.rake +6 -9
- data/lib/tasks/webpacker/check_node.rake +5 -27
- data/lib/tasks/webpacker/check_yarn.rake +5 -29
- data/lib/tasks/webpacker/clean.rake +5 -19
- data/lib/tasks/webpacker/clobber.rake +6 -13
- data/lib/tasks/webpacker/compile.rake +5 -38
- data/lib/tasks/webpacker/info.rake +5 -17
- data/lib/tasks/webpacker/install.rake +5 -13
- data/lib/tasks/webpacker/verify_config.rake +6 -11
- data/lib/tasks/webpacker/verify_install.rake +7 -2
- data/lib/tasks/webpacker/yarn_install.rake +5 -20
- data/lib/tasks/webpacker.rake +15 -13
- data/lib/webpacker/dev_server_runner.rb +9 -96
- data/lib/webpacker/webpack_runner.rb +9 -58
- data/lib/webpacker.rb +3 -47
- data/package/__tests__/config-bc.js +27 -0
- data/package/__tests__/config.js +6 -5
- data/package/__tests__/dev_server-bc.js +46 -0
- data/package/__tests__/dev_server.js +9 -8
- data/package/__tests__/development-bc.js +66 -0
- data/package/__tests__/development.js +36 -5
- data/package/__tests__/env-bc.js +59 -0
- data/package/__tests__/env.js +3 -2
- data/package/__tests__/index-bc.js +22 -0
- data/package/__tests__/index.js +13 -0
- data/package/__tests__/production-bc.js +51 -0
- data/package/__tests__/production.js +25 -3
- data/package/__tests__/staging-bc.js +53 -0
- data/package/__tests__/staging.js +27 -4
- data/package/__tests__/test-bc.js +43 -0
- data/package/__tests__/test.js +22 -4
- data/package/babel/preset.js +1 -4
- data/package/config.js +25 -7
- data/package/dev_server.js +7 -4
- data/package/env.js +22 -3
- data/package/environments/__tests__/base-bc.js +107 -0
- data/package/environments/__tests__/base.js +15 -15
- data/package/environments/__tests__/development.js +53 -0
- data/package/environments/__tests__/production.js +92 -0
- data/package/environments/base.js +5 -4
- data/package/environments/development.js +4 -46
- data/package/environments/production.js +10 -1
- data/package/index.js +35 -5
- data/package/rules/__tests__/__utils__/webpack.js +50 -0
- data/package/rules/__tests__/babel.js +63 -0
- data/package/rules/__tests__/esbuild.js +64 -0
- data/package/rules/__tests__/file.js +27 -0
- data/package/rules/__tests__/index.js +0 -4
- data/package/rules/__tests__/swc.js +63 -0
- data/package/rules/babel.js +13 -24
- data/package/rules/esbuild.js +2 -13
- data/package/rules/file.js +2 -2
- data/package/rules/jscommon.js +26 -0
- data/package/rules/swc.js +2 -13
- data/package/utils/configPath.js +19 -0
- data/package/utils/defaultConfigPath.js +2 -0
- data/package/utils/get_style_rule.js +5 -2
- data/package/utils/helpers.js +25 -2
- data/package/utils/inliningCss.js +7 -0
- data/package/utils/snakeToCamelCase +7 -0
- data/package/webpackDevServerConfig.js +68 -0
- data/package.json +11 -5
- data/{webpacker.gemspec → shakapacker.gemspec} +3 -3
- data/spec/backward_compatibility_specs/command_spec.rb +116 -0
- data/spec/backward_compatibility_specs/compiler_spec.rb +59 -0
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +22 -0
- data/spec/backward_compatibility_specs/configuration_spec.rb +286 -0
- data/{test/dev_server_runner_test.rb → spec/backward_compatibility_specs/dev_server_runner_spec.rb} +37 -39
- data/spec/backward_compatibility_specs/dev_server_spec.rb +47 -0
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +35 -0
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +44 -0
- data/spec/backward_compatibility_specs/env_spec.rb +23 -0
- data/spec/backward_compatibility_specs/helper_spec.rb +243 -0
- data/spec/backward_compatibility_specs/instance_spec.rb +31 -0
- data/spec/backward_compatibility_specs/manifest_spec.rb +100 -0
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +55 -0
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +37 -0
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +24 -0
- data/{test/webpack_runner_test.rb → spec/backward_compatibility_specs/webpack_runner_spec.rb} +15 -16
- data/spec/backward_compatibility_specs/webpacker_spec.rb +41 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +2 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/application.js +1 -1
- data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +11 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker.yml +1 -1
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_css_extract_ignore_order_warnings.yml +1 -1
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_defaults_fallback.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +7 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_other_location.yml +85 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_public_root.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +13 -0
- data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/public/packs/manifest.json +8 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +1 -0
- data/spec/dummy/.browserslistrc +1 -0
- data/spec/dummy/.gitignore +20 -0
- data/spec/dummy/.prettierrc.yaml +4 -0
- data/spec/dummy/Gemfile +63 -0
- data/spec/dummy/Procfile.dev +5 -0
- data/spec/dummy/Procfile.dev-static +9 -0
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/hello_world_controller.rb +9 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/javascript/Globals.d.ts +3 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.module.css +25 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorld.tsx +47 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/HelloWorldServer.tsx +5 -0
- data/spec/dummy/app/javascript/bundles/HelloWorld/components/logo.svg +7 -0
- data/spec/dummy/app/javascript/packs/application.js +17 -0
- data/spec/dummy/app/javascript/packs/hello-world-bundle.ts +8 -0
- data/spec/dummy/app/javascript/packs/server-bundle.ts +8 -0
- data/spec/dummy/app/jobs/application_job.rb +7 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/hello_world/index.html.erb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/hello_world.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/babel.config.js +30 -0
- data/spec/dummy/bin/bundle +114 -0
- data/spec/dummy/bin/dev +30 -0
- data/spec/dummy/bin/dev-static +30 -0
- data/spec/dummy/bin/rails +9 -0
- data/spec/dummy/bin/rake +9 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/bin/shakapacker +13 -0
- data/spec/dummy/bin/shakapacker-dev-server +13 -0
- data/spec/dummy/bin/spring +17 -0
- data/spec/dummy/bin/yarn +18 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +106 -0
- data/spec/dummy/config/environments/test.rb +49 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +58 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +38 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config/shakapacker.yml +62 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/config/webpack/ServerClientOrBoth.js +34 -0
- data/spec/dummy/config/webpack/clientWebpackConfig.js +15 -0
- data/spec/dummy/config/webpack/commonWebpackConfig.js +18 -0
- data/spec/dummy/config/webpack/development.js +32 -0
- data/spec/dummy/config/webpack/production.js +9 -0
- data/spec/dummy/config/webpack/serverWebpackConfig.js +116 -0
- data/spec/dummy/config/webpack/test.js +7 -0
- data/spec/dummy/config/webpack/webpack.config.js +24 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/package.json +44 -0
- data/spec/dummy/postcss.config.js +12 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +1 -0
- data/spec/dummy/spec/rails_helper.rb +118 -0
- data/spec/dummy/spec/spec_helper.rb +96 -0
- data/spec/dummy/spec/system/hello_world_spec.rb +19 -0
- data/spec/dummy/tsconfig.json +21 -0
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/dummy/yarn.lock +4697 -0
- data/spec/generator_specs/e2e_template/files/app/controllers/home_controller.rb +4 -0
- data/spec/generator_specs/e2e_template/files/app/javascript/components/App.js +12 -0
- data/spec/generator_specs/e2e_template/files/app/javascript/packs/application.js +10 -0
- data/spec/generator_specs/e2e_template/files/app/views/home/index.html.erb +2 -0
- data/spec/generator_specs/e2e_template/files/app/views/layouts/application.html.erb +17 -0
- data/spec/generator_specs/e2e_template/files/config/routes.rb +3 -0
- data/spec/generator_specs/e2e_template/files/spec/system/test_react_component_renders_spec.rb +13 -0
- data/spec/generator_specs/e2e_template/template.rb +21 -0
- data/spec/generator_specs/generator_spec.rb +169 -0
- data/{test → spec}/mounted_app/test/dummy/config/application.rb +1 -1
- data/{test → spec}/mounted_app/test/dummy/config/webpacker.yml +11 -5
- data/spec/shakapacker/command_spec.rb +116 -0
- data/spec/shakapacker/compiler_spec.rb +59 -0
- data/spec/shakapacker/compiler_strategy_spec.rb +22 -0
- data/spec/shakapacker/configuration_spec.rb +323 -0
- data/spec/shakapacker/dev_server_runner_spec.rb +72 -0
- data/spec/shakapacker/dev_server_spec.rb +133 -0
- data/spec/shakapacker/digest_strategy_spec.rb +35 -0
- data/spec/shakapacker/engine_rake_tasks_spec.rb +43 -0
- data/spec/shakapacker/env_spec.rb +23 -0
- data/spec/shakapacker/helper_spec.rb +243 -0
- data/spec/shakapacker/instance_spec.rb +31 -0
- data/spec/shakapacker/manifest_spec.rb +100 -0
- data/spec/shakapacker/mtime_strategy_spec.rb +55 -0
- data/spec/shakapacker/rake_tasks_spec.rb +93 -0
- data/spec/shakapacker/shakapacker_spec.rb +41 -0
- data/spec/shakapacker/spec_helper_initializer.rb +24 -0
- data/spec/shakapacker/test_app/.gitignore +2 -0
- data/spec/shakapacker/test_app/Rakefile +3 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/application.js +10 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/generated/something.js +2 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.css +4 -0
- data/spec/shakapacker/test_app/app/javascript/entrypoints/multi_entry.js +4 -0
- data/{test/test_app/bin/webpacker-dev-server → spec/shakapacker/test_app/bin/shakapacker} +3 -3
- data/{test/test_app/bin/webpacker → spec/shakapacker/test_app/bin/shakapacker-dev-server} +3 -3
- data/{test → spec/shakapacker}/test_app/config/application.rb +1 -1
- data/spec/shakapacker/test_app/config/environment.rb +4 -0
- data/spec/shakapacker/test_app/config/initializers/inspect_autoload_paths.rb +1 -0
- data/spec/shakapacker/test_app/config/shakapacker.yml +82 -0
- data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +84 -0
- data/spec/shakapacker/test_app/config/shakapacker_defaults_fallback.yml +11 -0
- data/{test/test_app/config/webpacker_other_location.yml → spec/shakapacker/test_app/config/shakapacker_manifest_path.yml} +6 -5
- data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +83 -0
- data/spec/shakapacker/test_app/config/shakapacker_no_precompile.yml +7 -0
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +85 -0
- data/spec/shakapacker/test_app/config/shakapacker_public_root.yml +18 -0
- data/spec/shakapacker/test_app/config/webpack/webpack.config.js +0 -0
- data/spec/shakapacker/test_app/config.ru +5 -0
- data/spec/shakapacker/test_app/public/packs/manifest.json +58 -0
- data/spec/shakapacker/test_app/some.config.js +0 -0
- data/spec/shakapacker/test_app/yarn.lock +11 -0
- data/spec/shakapacker/version_checker_spec.rb +951 -0
- data/spec/shakapacker/webpack_runner_spec.rb +55 -0
- data/spec/spec_helper.rb +98 -0
- data/yarn.lock +846 -844
- metadata +314 -213
- data/.github/ISSUE_TEMPLATE/feature-request.md +0 -18
- data/config/webpacker.yml +0 -1
- data/gemfiles/Gemfile-rails.5.2.x +0 -9
- data/lib/tasks/yarn.rake +0 -44
- data/lib/webpacker/instance.rb +0 -45
- data/lib/webpacker/railtie.rb +0 -70
- data/lib/webpacker/runner.rb +0 -23
- data/package/configPath.js +0 -3
- data/package/inliningCss.js +0 -7
- data/test/command_test.rb +0 -109
- data/test/compiler_strategy_test.rb +0 -27
- data/test/compiler_test.rb +0 -60
- data/test/configuration_test.rb +0 -186
- data/test/dev_server_test.rb +0 -47
- data/test/digest_strategy_test.rb +0 -33
- data/test/engine_rake_tasks_test.rb +0 -39
- data/test/env_test.rb +0 -23
- data/test/helper_test.rb +0 -248
- data/test/manifest_test.rb +0 -89
- data/test/mtime_strategy_test.rb +0 -42
- data/test/rake_tasks_test.rb +0 -37
- data/test/test_app/config/webpacker_no_precompile.yml +0 -7
- data/test/test_helper.rb +0 -33
- data/test/version_checker_test.rb +0 -826
- data/test/webpacker_test.rb +0 -49
- /data/{test/mounted_app/test/dummy → spec/backward_compatibility_specs/webpacker_test_app}/Rakefile +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/generated/something.js +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.css +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/app/packs/entrypoints/multi_entry.js +0 -0
- /data/{lib/install → spec/backward_compatibility_specs/webpacker_test_app}/bin/webpacker-dev-server +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/environment.rb +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/initializers/inspect_autoload_paths.rb +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpack/webpack.config.js +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_manifest_path.yml +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/config/webpacker_nested_entries.yml +0 -0
- /data/{test/mounted_app/test/dummy → spec/backward_compatibility_specs/webpacker_test_app}/config.ru +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/some.config.js +0 -0
- /data/{test/test_app → spec/backward_compatibility_specs/webpacker_test_app}/yarn.lock +0 -0
- /data/{test → spec}/fixtures/beta_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/beta_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/beta_package.json +0 -0
- /data/{test → spec}/fixtures/beta_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/beta_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/git_url_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/git_url_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/git_url_package.json +0 -0
- /data/{test → spec}/fixtures/git_url_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/git_url_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/github_url_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/github_url_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/github_url_package.json +0 -0
- /data/{test → spec}/fixtures/github_url_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/github_url_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/relative_path_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/relative_path_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/relative_path_package.json +0 -0
- /data/{test → spec}/fixtures/relative_path_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/relative_path_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/semver_caret_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/semver_caret_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/semver_caret_package.json +0 -0
- /data/{test → spec}/fixtures/semver_caret_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/semver_caret_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/semver_exact_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/semver_exact_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/semver_exact_package.json +0 -0
- /data/{test → spec}/fixtures/semver_exact_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/semver_exact_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/semver_tilde_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/semver_tilde_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/semver_tilde_package.json +0 -0
- /data/{test → spec}/fixtures/semver_tilde_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/semver_tilde_yarn.v2.lock +0 -0
- /data/{test → spec}/fixtures/without_package-lock.v1.json +0 -0
- /data/{test → spec}/fixtures/without_package-lock.v2.json +0 -0
- /data/{test → spec}/fixtures/without_package.json +0 -0
- /data/{test → spec}/fixtures/without_yarn.v1.lock +0 -0
- /data/{test → spec}/fixtures/without_yarn.v2.lock +0 -0
- /data/{test → spec}/mounted_app/Rakefile +0 -0
- /data/{test/test_app → spec/mounted_app/test/dummy}/Rakefile +0 -0
- /data/{test → spec}/mounted_app/test/dummy/bin/rails +0 -0
- /data/{test → spec}/mounted_app/test/dummy/bin/rake +0 -0
- /data/{test → spec}/mounted_app/test/dummy/config/environment.rb +0 -0
- /data/{test/test_app → spec/mounted_app/test/dummy}/config.ru +0 -0
- /data/{test → spec}/mounted_app/test/dummy/package.json +0 -0
- /data/{test → spec/shakapacker}/test_app/package.json +0 -0
@@ -1,15 +1,17 @@
|
|
1
|
-
# Note: You must restart bin/
|
1
|
+
# Note: You must restart bin/shakapacker-dev-server for changes to take effect
|
2
|
+
# This file contains the defaults used by shakapacker.
|
2
3
|
|
3
4
|
default: &default
|
4
5
|
source_path: app/javascript
|
5
6
|
|
6
7
|
# You can have a subdirectory of the source_path, like 'packs' (recommended).
|
7
8
|
# Alternatively, you can use '/' to use the whole source_path directory.
|
8
|
-
|
9
|
+
# Notice that this is a relative path to source_path
|
10
|
+
source_entry_path: packs
|
9
11
|
|
10
12
|
# If nested_entries is true, then we'll pick up subdirectories within the source_entry_path.
|
11
13
|
# You cannot set this option to true if you set source_entry_path to '/'
|
12
|
-
nested_entries:
|
14
|
+
nested_entries: true
|
13
15
|
|
14
16
|
# While using a File-System-based automated bundle generation feature, miscellaneous warnings suggesting css order
|
15
17
|
# conflicts may arise due to the mini-css-extract-plugin. For projects where css ordering has been mitigated through
|
@@ -19,10 +21,10 @@ default: &default
|
|
19
21
|
|
20
22
|
public_root_path: public
|
21
23
|
public_output_path: packs
|
22
|
-
cache_path: tmp/
|
24
|
+
cache_path: tmp/shakapacker
|
23
25
|
webpack_compile_output: true
|
24
26
|
# See https://github.com/shakacode/shakapacker#deployment
|
25
|
-
|
27
|
+
shakapacker_precompile: true
|
26
28
|
|
27
29
|
# Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
|
28
30
|
# manifest_path: public/packs/manifest.json
|
@@ -43,25 +45,36 @@ default: &default
|
|
43
45
|
# Select whether the compiler will use SHA digest ('digest' option) or most most recent modified timestamp ('mtime') to determine freshness
|
44
46
|
compiler_strategy: digest
|
45
47
|
|
48
|
+
# Select whether the compiler will always use a content hash and not just in production
|
49
|
+
# Don't use contentHash except for production for performance
|
50
|
+
# https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
|
51
|
+
useContentHash: false
|
52
|
+
|
46
53
|
development:
|
47
54
|
<<: *default
|
48
55
|
compile: true
|
49
56
|
compiler_strategy: mtime
|
50
57
|
|
51
58
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
59
|
+
# Keys not described there are documented inline and in https://github.com/shakacode/shakapacker/
|
52
60
|
dev_server:
|
53
|
-
https:
|
61
|
+
# For running dev server with https, set `server: https`.
|
62
|
+
# You may use `https: true` instead but notice that it is deprecated in favor of `server: https`
|
63
|
+
# Ensure only one of these entries is set.
|
64
|
+
# server: https
|
65
|
+
|
54
66
|
host: localhost
|
55
67
|
port: 3035
|
56
68
|
# Hot Module Replacement updates modules while the application is running without a full reload
|
69
|
+
# Used instead of the `hot` key in https://webpack.js.org/configuration/dev-server/#devserverhot
|
57
70
|
hmr: false
|
58
71
|
# If HMR is on, CSS will by inlined by delivering it as part of the script payload via style-loader. Be sure
|
59
72
|
# that you add style-loader to your project dependencies.
|
60
73
|
#
|
61
|
-
# If you want to instead deliver CSS via <link> with the mini-extract-
|
74
|
+
# If you want to instead deliver CSS via <link> with the mini-css-extract-plugin, set inline_css to false.
|
62
75
|
# In that case, style-loader is not needed as a dependency.
|
63
76
|
#
|
64
|
-
# mini-extract-
|
77
|
+
# mini-css-extract-plugin is a required dependency in both cases.
|
65
78
|
inline_css: true
|
66
79
|
# Defaults to the inverse of hmr. Uncomment to manually set this.
|
67
80
|
# live_reload: true
|
@@ -70,13 +83,14 @@ development:
|
|
70
83
|
overlay: true
|
71
84
|
# May also be a string
|
72
85
|
# webSocketURL:
|
73
|
-
# hostname:
|
74
|
-
# pathname:
|
86
|
+
# hostname: '0.0.0.0'
|
87
|
+
# pathname: '/ws'
|
75
88
|
# port: 8080
|
76
89
|
# Should we use gzip compression?
|
77
90
|
compress: true
|
78
91
|
# Note that apps that do not check the host are vulnerable to DNS rebinding attacks
|
79
|
-
allowed_hosts:
|
92
|
+
allowed_hosts: 'auto'
|
93
|
+
# Shows progress and colorizes output of bin/shakapacker[-dev-server]
|
80
94
|
pretty: true
|
81
95
|
headers:
|
82
96
|
'Access-Control-Allow-Origin': '*'
|
@@ -97,5 +111,8 @@ production:
|
|
97
111
|
# Production depends on precompilation of packs prior to booting for performance.
|
98
112
|
compile: false
|
99
113
|
|
114
|
+
# Use content hash for naming assets. Cannot be overridden by for production.
|
115
|
+
useContentHash: true
|
116
|
+
|
100
117
|
# Cache manifest.json for performance
|
101
118
|
cache_manifest: true
|
@@ -1,5 +1,6 @@
|
|
1
|
-
const { webpackConfig } = require('shakapacker')
|
2
|
-
|
3
1
|
// See the shakacode/shakapacker README and docs directory for advice on customizing your webpackConfig.
|
2
|
+
const { generateWebpackConfig } = require('shakapacker')
|
3
|
+
|
4
|
+
const webpackConfig = generateWebpackConfig()
|
4
5
|
|
5
6
|
module.exports = webpackConfig
|
data/lib/install/template.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require "shakapacker/utils/version_syntax_converter"
|
2
|
+
|
3
|
+
# Install Shakapacker
|
4
|
+
|
5
|
+
force_option = ENV["FORCE"] ? { force: true } : {}
|
6
|
+
|
7
|
+
copy_file "#{__dir__}/config/shakapacker.yml", "config/shakapacker.yml", force_option
|
8
|
+
copy_file "#{__dir__}/package.json", "package.json", force_option
|
4
9
|
|
5
10
|
say "Copying webpack core config"
|
6
|
-
directory "#{__dir__}/config/webpack", "config/webpack"
|
11
|
+
directory "#{__dir__}/config/webpack", "config/webpack", force_option
|
7
12
|
|
8
|
-
if Dir.exist?(
|
13
|
+
if Dir.exist?(Shakapacker.config.source_path)
|
9
14
|
say "The packs app source directory already exists"
|
10
15
|
else
|
11
16
|
say "Creating packs app source directory"
|
@@ -36,56 +41,68 @@ else
|
|
36
41
|
say %( Add <%= javascript_pack_tag "application" %> within the <head> tag in your custom layout.)
|
37
42
|
end
|
38
43
|
|
44
|
+
# Ensure there is `system!("bin/yarn")` command in `./bin/setup` file
|
39
45
|
if (setup_path = Rails.root.join("bin/setup")).exist?
|
40
46
|
say "Run bin/yarn during bin/setup"
|
41
|
-
|
47
|
+
|
48
|
+
if File.read(setup_path).match? Regexp.escape(" # system('bin/yarn')\n")
|
49
|
+
gsub_file(setup_path, "# system('bin/yarn')", "system!('bin/yarn')")
|
50
|
+
else
|
51
|
+
# Due to the inconsistency of quotation usage in Rails 7 compared to
|
52
|
+
# earlier versions, we check both single and double quotations here.
|
53
|
+
pattern = /system\(['"]bundle check['"]\) \|\| system!\(['"]bundle install['"]\)\n/
|
54
|
+
|
55
|
+
string_to_add = <<-RUBY
|
42
56
|
|
43
57
|
# Install JavaScript dependencies
|
44
|
-
system!
|
58
|
+
system!("bin/yarn")
|
45
59
|
RUBY
|
46
|
-
end
|
47
60
|
|
48
|
-
if
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
61
|
+
if File.read(setup_path).match? pattern
|
62
|
+
insert_into_file(setup_path, string_to_add, after: pattern)
|
63
|
+
else
|
64
|
+
say <<~MSG, :red
|
65
|
+
It seems your `bin/setup` file doesn't have the expected content.
|
66
|
+
Please review the file and manually add `system!("bin/yarn")` before any
|
67
|
+
other command that requires JavaScript dependencies being already installed.
|
68
|
+
MSG
|
69
|
+
end
|
70
|
+
end
|
54
71
|
end
|
55
72
|
|
56
73
|
results = []
|
57
74
|
|
58
75
|
Dir.chdir(Rails.root) do
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
else
|
63
|
-
say "Installing shakapacker@next"
|
64
|
-
results << run("yarn add shakapacker@next --exact")
|
65
|
-
end
|
76
|
+
npm_version = Shakapacker::Utils::VersionSyntaxConverter.new.rubygem_to_npm(Shakapacker::VERSION)
|
77
|
+
say "Installing shakapacker@#{npm_version}"
|
78
|
+
results << run("yarn add shakapacker@#{npm_version} --exact")
|
66
79
|
|
67
80
|
package_json = File.read("#{__dir__}/../../package.json")
|
68
81
|
peers = JSON.parse(package_json)["peerDependencies"]
|
69
|
-
|
82
|
+
dev_dependency_packages = ["webpack-dev-server"]
|
83
|
+
|
84
|
+
dependencies_to_add = []
|
85
|
+
dev_dependencies_to_add = []
|
86
|
+
|
87
|
+
peers.each do |(package, version)|
|
70
88
|
major_version = version.match(/(\d+)/)[1]
|
71
|
-
|
72
|
-
|
89
|
+
entry = "#{package}@#{major_version}"
|
90
|
+
|
91
|
+
if dev_dependency_packages.include? package
|
92
|
+
dev_dependencies_to_add << entry
|
93
|
+
else
|
94
|
+
dependencies_to_add << entry
|
95
|
+
end
|
96
|
+
end
|
73
97
|
|
74
98
|
say "Adding shakapacker peerDependencies"
|
75
|
-
results << run("yarn add #{
|
99
|
+
results << run("yarn add #{dependencies_to_add.join(' ')}")
|
76
100
|
|
77
101
|
say "Installing webpack-dev-server for live reloading as a development dependency"
|
78
|
-
results << run("yarn add --dev
|
79
|
-
end
|
80
|
-
|
81
|
-
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
|
82
|
-
say "You need to allow webpack-dev-server host as allowed origin for connect-src.", :yellow
|
83
|
-
say "This can be done in Rails 5.2+ for development environment in the CSP initializer", :yellow
|
84
|
-
say "config/initializers/content_security_policy.rb with a snippet like this:", :yellow
|
85
|
-
say "policy.connect_src :self, :https, \"http://localhost:3035\", \"ws://localhost:3035\" if Rails.env.development?", :yellow
|
102
|
+
results << run("yarn add --dev #{dev_dependencies_to_add.join(' ')}")
|
86
103
|
end
|
87
104
|
|
88
105
|
unless results.all?
|
89
|
-
say "
|
106
|
+
say "Shakapacker installation failed 😭 See above for details.", :red
|
90
107
|
exit 1
|
91
108
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class
|
2
|
-
delegate :config, :compiler, :manifest, :logger, to: :@
|
1
|
+
class Shakapacker::Commands
|
2
|
+
delegate :config, :compiler, :manifest, :logger, to: :@instance
|
3
3
|
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(instance)
|
5
|
+
@instance = instance
|
6
6
|
end
|
7
7
|
|
8
8
|
# Cleanup old assets in the compile directory. By default it will
|
@@ -1,16 +1,17 @@
|
|
1
1
|
require "open3"
|
2
|
-
require "
|
2
|
+
require "shakapacker/compiler_strategy"
|
3
|
+
require "fileutils"
|
3
4
|
|
4
|
-
class
|
5
|
+
class Shakapacker::Compiler
|
5
6
|
# Additional environment variables that the compiler is being run with
|
6
|
-
#
|
7
|
+
# Shakapacker::Compiler.env['FRONTEND_API_KEY'] = 'your_secret_key'
|
7
8
|
cattr_accessor(:env) { {} }
|
8
9
|
|
9
|
-
delegate :config, :logger, :strategy, to: :
|
10
|
+
delegate :config, :logger, :strategy, to: :instance
|
10
11
|
delegate :fresh?, :stale?, :after_compile_hook, to: :strategy
|
11
12
|
|
12
|
-
def initialize(
|
13
|
-
@
|
13
|
+
def initialize(instance)
|
14
|
+
@instance = instance
|
14
15
|
end
|
15
16
|
|
16
17
|
def compile
|
@@ -32,7 +33,7 @@ class Webpacker::Compiler
|
|
32
33
|
end
|
33
34
|
|
34
35
|
private
|
35
|
-
attr_reader :
|
36
|
+
attr_reader :instance
|
36
37
|
|
37
38
|
def acquire_ipc_lock
|
38
39
|
open_lock_file do |lf|
|
@@ -55,15 +56,24 @@ class Webpacker::Compiler
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def open_lock_file
|
58
|
-
|
59
|
-
|
59
|
+
create_lock_file_dir unless File.exist?(lock_file_path)
|
60
|
+
|
61
|
+
File.open(lock_file_path, File::CREAT) do |lf|
|
60
62
|
return yield lf
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
66
|
+
def create_lock_file_dir
|
67
|
+
dirname = File.dirname(lock_file_path)
|
68
|
+
FileUtils.mkdir_p(dirname)
|
69
|
+
end
|
70
|
+
|
71
|
+
def lock_file_path
|
72
|
+
config.root_path.join("tmp/shakapacker.lock")
|
73
|
+
end
|
74
|
+
|
64
75
|
def optionalRubyRunner
|
65
|
-
|
66
|
-
first_line = File.readlines(bin_webpack_path).first.chomp
|
76
|
+
first_line = File.readlines(bin_shakapacker_path).first.chomp
|
67
77
|
/ruby/.match?(first_line) ? RbConfig.ruby : ""
|
68
78
|
end
|
69
79
|
|
@@ -72,7 +82,7 @@ class Webpacker::Compiler
|
|
72
82
|
|
73
83
|
stdout, stderr, status = Open3.capture3(
|
74
84
|
webpack_env,
|
75
|
-
"#{optionalRubyRunner}
|
85
|
+
"#{optionalRubyRunner} #{bin_shakapacker_path}",
|
76
86
|
chdir: File.expand_path(config.root_path)
|
77
87
|
)
|
78
88
|
|
@@ -94,8 +104,26 @@ class Webpacker::Compiler
|
|
94
104
|
def webpack_env
|
95
105
|
return env unless defined?(ActionController::Base)
|
96
106
|
|
97
|
-
|
98
|
-
|
99
|
-
|
107
|
+
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
|
108
|
+
|
109
|
+
env.merge("SHAKAPACKER_ASSET_HOST" => ENV.fetch("SHAKAPACKER_ASSET_HOST", ActionController::Base.helpers.compute_asset_host),
|
110
|
+
"SHAKAPACKER_RELATIVE_URL_ROOT" => ENV.fetch("SHAKAPACKER_RELATIVE_URL_ROOT", ActionController::Base.relative_url_root),
|
111
|
+
"SHAKAPACKER_CONFIG" => instance.config_path.to_s)
|
112
|
+
end
|
113
|
+
|
114
|
+
def bin_shakapacker_path
|
115
|
+
if File.exist?(config.root_path.join("bin/shakapacker"))
|
116
|
+
config.root_path.join("bin/shakapacker")
|
117
|
+
elsif File.exist?(config.root_path.join("bin/webpacker"))
|
118
|
+
Shakapacker.puts_deprecation_message(
|
119
|
+
Shakapacker.short_deprecation_message(
|
120
|
+
"bin/webpacker",
|
121
|
+
"bin/shakapacker"
|
122
|
+
)
|
123
|
+
)
|
124
|
+
config.root_path.join("bin/webpacker")
|
125
|
+
else
|
126
|
+
config.root_path.join("bin/shakapacker")
|
127
|
+
end
|
100
128
|
end
|
101
129
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
1
|
+
require "shakapacker/mtime_strategy"
|
2
|
+
require "shakapacker/digest_strategy"
|
3
3
|
|
4
|
-
module
|
4
|
+
module Shakapacker
|
5
5
|
class CompilerStrategy
|
6
6
|
def self.from_config
|
7
|
-
strategy_from_config =
|
7
|
+
strategy_from_config = Shakapacker.config.compiler_strategy
|
8
8
|
|
9
9
|
case strategy_from_config
|
10
10
|
when "mtime"
|
11
|
-
|
11
|
+
Shakapacker::MtimeStrategy.new
|
12
12
|
when "digest"
|
13
|
-
|
13
|
+
Shakapacker::DigestStrategy.new
|
14
14
|
else
|
15
15
|
raise "Unknown strategy '#{strategy_from_config}'. " \
|
16
16
|
"Available options are 'mtime' and 'digest'."
|
@@ -2,7 +2,7 @@ require "yaml"
|
|
2
2
|
require "active_support/core_ext/hash/keys"
|
3
3
|
require "active_support/core_ext/hash/indifferent_access"
|
4
4
|
|
5
|
-
class
|
5
|
+
class Shakapacker::Configuration
|
6
6
|
class << self
|
7
7
|
attr_accessor :installing
|
8
8
|
end
|
@@ -11,8 +11,11 @@ class Webpacker::Configuration
|
|
11
11
|
|
12
12
|
def initialize(root_path:, config_path:, env:)
|
13
13
|
@root_path = root_path
|
14
|
-
@config_path = config_path
|
15
14
|
@env = env
|
15
|
+
|
16
|
+
# For backward compatibility
|
17
|
+
Shakapacker.set_shakapacker_env_variables_for_backward_compatibility
|
18
|
+
@config_path = Pathname.new(ENV["SHAKAPACKER_CONFIG"] || config_path)
|
16
19
|
end
|
17
20
|
|
18
21
|
def dev_server
|
@@ -31,13 +34,24 @@ class Webpacker::Configuration
|
|
31
34
|
fetch(:ensure_consistent_versioning)
|
32
35
|
end
|
33
36
|
|
34
|
-
def
|
37
|
+
def shakapacker_precompile?
|
35
38
|
# ENV of false takes precedence
|
36
|
-
return false if %w(no false n f).include?(ENV["
|
37
|
-
return true if %w(yes true y t).include?(ENV["
|
39
|
+
return false if %w(no false n f).include?(ENV["SHAKAPACKER_PRECOMPILE"])
|
40
|
+
return true if %w(yes true y t).include?(ENV["SHAKAPACKER_PRECOMPILE"])
|
38
41
|
|
39
42
|
return false unless config_path.exist?
|
40
|
-
fetch(:
|
43
|
+
fetch(:shakapacker_precompile)
|
44
|
+
end
|
45
|
+
|
46
|
+
def webpacker_precompile?
|
47
|
+
Shakapacker.puts_deprecation_message(
|
48
|
+
Shakapacker.short_deprecation_message(
|
49
|
+
"webpacker_precompile?",
|
50
|
+
"shakapacker_precompile?"
|
51
|
+
)
|
52
|
+
)
|
53
|
+
|
54
|
+
shakapacker_precompile?
|
41
55
|
end
|
42
56
|
|
43
57
|
def source_path
|
@@ -49,7 +63,7 @@ class Webpacker::Configuration
|
|
49
63
|
end
|
50
64
|
|
51
65
|
def source_entry_path
|
52
|
-
source_path.join(fetch(:source_entry_path))
|
66
|
+
source_path.join(relative_path(fetch(:source_entry_path)))
|
53
67
|
end
|
54
68
|
|
55
69
|
def manifest_path
|
@@ -80,14 +94,6 @@ class Webpacker::Configuration
|
|
80
94
|
root_path.join(fetch(:cache_path))
|
81
95
|
end
|
82
96
|
|
83
|
-
def check_yarn_integrity=(value)
|
84
|
-
warn <<~EOS
|
85
|
-
Webpacker::Configuration#check_yarn_integrity=(value) is obsolete. The integrity
|
86
|
-
check has been removed from Webpacker (https://github.com/rails/webpacker/pull/2518)
|
87
|
-
so changing this setting will have no effect.
|
88
|
-
EOS
|
89
|
-
end
|
90
|
-
|
91
97
|
def webpack_compile_output?
|
92
98
|
fetch(:webpack_compile_output)
|
93
99
|
end
|
@@ -97,7 +103,17 @@ class Webpacker::Configuration
|
|
97
103
|
end
|
98
104
|
|
99
105
|
def fetch(key)
|
100
|
-
data.fetch(key, defaults[key])
|
106
|
+
return data.fetch(key, defaults[key]) unless key == :webpacker_precompile
|
107
|
+
|
108
|
+
# for backward compatibility
|
109
|
+
Shakapacker.puts_deprecation_message(
|
110
|
+
Shakapacker.short_deprecation_message(
|
111
|
+
"webpacker_precompile",
|
112
|
+
"shakapacker_precompile"
|
113
|
+
)
|
114
|
+
)
|
115
|
+
|
116
|
+
data.fetch(key, defaults[:shakapacker_precompile])
|
101
117
|
end
|
102
118
|
|
103
119
|
private
|
@@ -111,13 +127,22 @@ class Webpacker::Configuration
|
|
111
127
|
rescue ArgumentError
|
112
128
|
YAML.load_file(config_path.to_s)
|
113
129
|
end
|
114
|
-
config[env].deep_symbolize_keys
|
130
|
+
symbolized_config = config[env].deep_symbolize_keys
|
131
|
+
|
132
|
+
# For backward compatibility
|
133
|
+
if symbolized_config.key?(:shakapacker_precompile) && !symbolized_config.key?(:webpacker_precompile)
|
134
|
+
symbolized_config[:webpacker_precompile] = symbolized_config[:shakapacker_precompile]
|
135
|
+
elsif !symbolized_config.key?(:shakapacker_precompile) && symbolized_config.key?(:webpacker_precompile)
|
136
|
+
symbolized_config[:shakapacker_precompile] = symbolized_config[:webpacker_precompile]
|
137
|
+
end
|
138
|
+
|
139
|
+
return symbolized_config
|
115
140
|
rescue Errno::ENOENT => e
|
116
141
|
if self.class.installing
|
117
142
|
{}
|
118
143
|
else
|
119
|
-
raise "
|
120
|
-
"Please run rails
|
144
|
+
raise "Shakapacker configuration file not found #{config_path}. " \
|
145
|
+
"Please run rails shakapacker:install " \
|
121
146
|
"Error: #{e.message}"
|
122
147
|
end
|
123
148
|
rescue Psych::SyntaxError => e
|
@@ -128,13 +153,19 @@ class Webpacker::Configuration
|
|
128
153
|
|
129
154
|
def defaults
|
130
155
|
@defaults ||= begin
|
131
|
-
path = File.expand_path("../../install/config/
|
156
|
+
path = File.expand_path("../../install/config/shakapacker.yml", __FILE__)
|
132
157
|
config = begin
|
133
158
|
YAML.load_file(path, aliases: true)
|
134
159
|
rescue ArgumentError
|
135
160
|
YAML.load_file(path)
|
136
161
|
end
|
137
|
-
HashWithIndifferentAccess.new(config[env] || config[
|
162
|
+
HashWithIndifferentAccess.new(config[env] || config[Shakapacker::DEFAULT_ENV])
|
138
163
|
end
|
139
164
|
end
|
165
|
+
|
166
|
+
def relative_path(path)
|
167
|
+
return ".#{path}" if path.start_with?("/")
|
168
|
+
|
169
|
+
path
|
170
|
+
end
|
140
171
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Shakapacker
|
4
|
+
DEPRECATION_GUIDE_URL = "https://github.com/shakacode/shakapacker/docs/v7_upgrade.md"
|
5
|
+
DEPRECATION_MESSAGE = <<~MSG
|
6
|
+
DEPRECATION NOTICE:
|
7
|
+
|
8
|
+
Using webpacker spelling is deprecated in Shakapacker.
|
9
|
+
Update your project with the new spelling.
|
10
|
+
|
11
|
+
For more information about this process, check:
|
12
|
+
#{DEPRECATION_GUIDE_URL}
|
13
|
+
MSG
|
14
|
+
SHELL = Thor::Shell::Color.new
|
15
|
+
|
16
|
+
def get_config_file_path_with_backward_compatibility(config_path)
|
17
|
+
if config_path.to_s.end_with?("shakapacker.yml") && !File.exist?(config_path)
|
18
|
+
webpacker_config_path = if config_path.class == Pathname
|
19
|
+
Pathname.new(config_path.to_s.gsub("shakapacker.yml", "webpacker.yml"))
|
20
|
+
else
|
21
|
+
config_path.gsub("shakapacker.yml", "webpacker.yml")
|
22
|
+
end
|
23
|
+
|
24
|
+
if File.exist?(webpacker_config_path)
|
25
|
+
puts_deprecation_message(
|
26
|
+
short_deprecation_message(
|
27
|
+
"config/webpacker.yml",
|
28
|
+
"config/shakapacker.yml"
|
29
|
+
)
|
30
|
+
)
|
31
|
+
return webpacker_config_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
config_path
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_shakapacker_env_variables_for_backward_compatibility
|
39
|
+
webpacker_env_variables = ENV.select { |key| key.start_with?("WEBPACKER_") }
|
40
|
+
|
41
|
+
deprecation_message_body = ""
|
42
|
+
|
43
|
+
webpacker_env_variables.each do |webpacker_key, _|
|
44
|
+
shakapacker_key = webpacker_key.gsub("WEBPACKER_", "SHAKAPACKER_")
|
45
|
+
next if ENV.key?(shakapacker_key)
|
46
|
+
|
47
|
+
deprecation_message_body += <<~MSG
|
48
|
+
Use `#{shakapacker_key}` instead of the deprecated `#{webpacker_key}`.
|
49
|
+
MSG
|
50
|
+
|
51
|
+
ENV[shakapacker_key] = ENV[webpacker_key]
|
52
|
+
end
|
53
|
+
|
54
|
+
if deprecation_message_body.present?
|
55
|
+
Shakapacker.puts_deprecation_message(
|
56
|
+
<<~MSG
|
57
|
+
DEPRECATION NOTICE:
|
58
|
+
|
59
|
+
#{deprecation_message_body}
|
60
|
+
Read more: #{Shakapacker::DEPRECATION_GUIDE_URL}
|
61
|
+
MSG
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def short_deprecation_message(old_usage, new_usage)
|
67
|
+
<<~MSG
|
68
|
+
DEPRECATION NOTICE:
|
69
|
+
|
70
|
+
Consider using `#{new_usage}` instead of the deprecated `#{old_usage}`.
|
71
|
+
Read more: #{DEPRECATION_GUIDE_URL}
|
72
|
+
MSG
|
73
|
+
end
|
74
|
+
|
75
|
+
def puts_deprecation_message(message)
|
76
|
+
SHELL.say "\n#{message}\n", :yellow
|
77
|
+
end
|
78
|
+
|
79
|
+
def puts_rake_deprecation_message(webpacker_task_name)
|
80
|
+
Shakapacker.puts_deprecation_message(
|
81
|
+
Shakapacker.short_deprecation_message(
|
82
|
+
"rake #{webpacker_task_name}",
|
83
|
+
"rake #{webpacker_task_name.gsub("webpacker", "shakapacker")}"
|
84
|
+
)
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class
|
2
|
-
DEFAULT_ENV_PREFIX = "
|
1
|
+
class Shakapacker::DevServer
|
2
|
+
DEFAULT_ENV_PREFIX = "SHAKAPACKER_DEV_SERVER".freeze
|
3
3
|
|
4
4
|
# Configure dev server connection timeout (in seconds), default: 0.1
|
5
|
-
#
|
5
|
+
# Shakapacker.dev_server.connect_timeout = 1
|
6
6
|
cattr_accessor(:connect_timeout) { 0.1 }
|
7
7
|
|
8
8
|
attr_reader :config
|
@@ -39,8 +39,29 @@ class Webpacker::DevServer
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def server
|
43
|
+
server_value = fetch(:server)
|
44
|
+
server_type = server_value.is_a?(Hash) ? server_value[:type] : server_value
|
45
|
+
|
46
|
+
return server_type if ["http", "https"].include?(server_type)
|
47
|
+
|
48
|
+
return "http" if server_type.nil?
|
49
|
+
|
50
|
+
puts <<~MSG
|
51
|
+
WARNING:
|
52
|
+
`server: #{server_type}` is not a valid configuration in Shakapacker.
|
53
|
+
Falling back to default `server: http`.
|
54
|
+
MSG
|
55
|
+
|
56
|
+
"http"
|
57
|
+
rescue KeyError
|
58
|
+
"http"
|
59
|
+
end
|
60
|
+
|
42
61
|
def protocol
|
43
|
-
https
|
62
|
+
return "https" if server == "https" || https? == true
|
63
|
+
|
64
|
+
"http"
|
44
65
|
end
|
45
66
|
|
46
67
|
def host_with_port
|
@@ -73,6 +94,8 @@ class Webpacker::DevServer
|
|
73
94
|
return nil unless config.dev_server.present?
|
74
95
|
|
75
96
|
ENV["#{env_prefix}_#{key.upcase}"] || config.dev_server.fetch(key, defaults[key])
|
97
|
+
rescue
|
98
|
+
nil
|
76
99
|
end
|
77
100
|
|
78
101
|
def defaults
|