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,42 +1,9 @@
|
|
1
|
-
$stdout.sync = true
|
2
|
-
|
3
|
-
def yarn_install_available?
|
4
|
-
rails_major = Rails::VERSION::MAJOR
|
5
|
-
rails_minor = Rails::VERSION::MINOR
|
6
|
-
|
7
|
-
rails_major > 5 || (rails_major == 5 && rails_minor >= 1)
|
8
|
-
end
|
9
|
-
|
10
|
-
def enhance_assets_precompile
|
11
|
-
# yarn:install was added in Rails 5.1
|
12
|
-
deps = yarn_install_available? ? [] : ["webpacker:yarn_install"]
|
13
|
-
Rake::Task["assets:precompile"].enhance(deps) do |task|
|
14
|
-
prefix = task.name.split(/#|assets:precompile/).first
|
15
|
-
|
16
|
-
Rake::Task["#{prefix}webpacker:compile"].invoke
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
1
|
namespace :webpacker do
|
21
|
-
desc "Compile JavaScript packs using webpack for production with digests"
|
22
|
-
task compile
|
23
|
-
|
24
|
-
Webpacker.ensure_log_goes_to_stdout do
|
25
|
-
if Webpacker.compile
|
26
|
-
# Successful compilation!
|
27
|
-
else
|
28
|
-
# Failed compilation
|
29
|
-
exit!
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
2
|
+
desc "DEPRECATED - Compile JavaScript packs using webpack for production with digests"
|
3
|
+
task :compile do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
35
5
|
|
36
|
-
|
37
|
-
|
38
|
-
enhance_assets_precompile
|
39
|
-
else
|
40
|
-
Rake::Task.define_task("assets:precompile" => ["webpacker:yarn_install", "webpacker:compile"])
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:compile"].invoke
|
41
8
|
end
|
42
9
|
end
|
@@ -1,21 +1,9 @@
|
|
1
|
-
require "webpacker/version"
|
2
|
-
|
3
1
|
namespace :webpacker do
|
4
|
-
desc "Provide information on
|
5
|
-
task :info do
|
6
|
-
|
7
|
-
$stdout.puts "Ruby: #{`ruby --version`}"
|
8
|
-
$stdout.puts "Rails: #{Rails.version}"
|
9
|
-
$stdout.puts "Webpacker: #{Webpacker::VERSION}"
|
10
|
-
$stdout.puts "Node: #{`node --version`}"
|
11
|
-
$stdout.puts "Yarn: #{`yarn --version`}"
|
12
|
-
|
13
|
-
$stdout.puts "\n"
|
14
|
-
$stdout.puts "shakapacker: \n#{`npm list shakapacker version`}"
|
2
|
+
desc "DEPRECATED - Provide information on Shakapacker's environment"
|
3
|
+
task :info do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
15
5
|
|
16
|
-
|
17
|
-
|
18
|
-
$stdout.puts "Is bin/yarn present?: #{File.exist? 'bin/yarn'}"
|
19
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:info"].invoke
|
20
8
|
end
|
21
9
|
end
|
@@ -1,17 +1,9 @@
|
|
1
|
-
install_template_path = File.expand_path("../../install/template.rb", __dir__).freeze
|
2
|
-
bin_path = ENV["BUNDLE_BIN"] || Rails.root.join("bin")
|
3
|
-
|
4
1
|
namespace :webpacker do
|
5
|
-
desc "Install
|
6
|
-
task install
|
7
|
-
|
8
|
-
|
9
|
-
prefix = task.name.split(/#|webpacker:install/).first
|
2
|
+
desc "DEPRECATED - Install Shakapacker in this application"
|
3
|
+
task :install do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
10
5
|
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'"
|
15
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:install"].invoke
|
16
8
|
end
|
17
9
|
end
|
@@ -1,14 +1,9 @@
|
|
1
|
-
require "webpacker/configuration"
|
2
|
-
|
3
1
|
namespace :webpacker do
|
4
|
-
desc "Verifies if the
|
5
|
-
task :verify_config do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"running dependent tasks"
|
11
|
-
exit!
|
12
|
-
end
|
2
|
+
desc "DEPRECATED - Verifies if the Shakapacker config is present"
|
3
|
+
task :verify_config do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
5
|
+
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:verify_config"].invoke
|
13
8
|
end
|
14
9
|
end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
namespace :webpacker do
|
2
|
-
desc "Verifies if
|
3
|
-
task verify_install
|
2
|
+
desc "DEPRECATED - Verifies if Shakapacker is installed"
|
3
|
+
task :verify_install do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
5
|
+
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:verify_install"].invoke
|
8
|
+
end
|
4
9
|
end
|
@@ -1,24 +1,9 @@
|
|
1
1
|
namespace :webpacker do
|
2
|
-
desc "Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
|
-
task :yarn_install do
|
4
|
-
|
5
|
-
Shakapacker - Automatic installation of yarn packages is deprecated
|
6
|
-
Automatic installation of yarn packages when assets are precompiled is deprecated and will be removed in Shakapacker v7.
|
7
|
-
Please ensure you are installing yarn packages explicitly before the asset compilation.
|
8
|
-
MSG
|
2
|
+
desc "DEPRECATED - Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn"
|
3
|
+
task :yarn_install do |task|
|
4
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
9
5
|
|
10
|
-
|
11
|
-
|
12
|
-
valid_node_envs.include?(Rails.env) ? Rails.env : "production"
|
13
|
-
end
|
14
|
-
Dir.chdir(Rails.root) do
|
15
|
-
yarn_flags =
|
16
|
-
if `yarn --version`.start_with?("1")
|
17
|
-
"--no-progress --frozen-lockfile"
|
18
|
-
else
|
19
|
-
"--immutable"
|
20
|
-
end
|
21
|
-
system({ "NODE_ENV" => node_env }, "yarn install #{yarn_flags}")
|
22
|
-
end
|
6
|
+
prefix = task.name.split(/#|webpacker:/).first
|
7
|
+
Rake::Task["#{prefix}shakapacker:yarn_install"].invoke
|
23
8
|
end
|
24
9
|
end
|
data/lib/tasks/webpacker.rake
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
tasks = {
|
2
|
-
"webpacker:info" => "Provides information on
|
3
|
-
"webpacker:install" => "Installs and setup webpack with Yarn",
|
4
|
-
"webpacker:compile" => "Compiles webpack bundles based on environment",
|
5
|
-
"webpacker:clean" => "Remove old compiled
|
6
|
-
"webpacker:clobber" => "Removes the webpack compiled output directory",
|
7
|
-
"webpacker:check_node" => "Verifies if Node.js is installed",
|
8
|
-
"webpacker:check_yarn" => "Verifies if Yarn is installed",
|
9
|
-
"webpacker:check_binstubs" => "Verifies that bin/
|
10
|
-
"webpacker:binstubs" => "Installs
|
11
|
-
"webpacker:verify_install" => "Verifies if
|
2
|
+
"webpacker:info" => "DEPRECATED - Provides information on Shakapacker's environment",
|
3
|
+
"webpacker:install" => "DEPRECATED - Installs and setup webpack with Yarn",
|
4
|
+
"webpacker:compile" => "DEPRECATED - Compiles webpack bundles based on environment",
|
5
|
+
"webpacker:clean" => "DEPRECATED - Remove old compiled bundles",
|
6
|
+
"webpacker:clobber" => "DEPRECATED - Removes the webpack compiled output directory",
|
7
|
+
"webpacker:check_node" => "DEPRECATED - Verifies if Node.js is installed",
|
8
|
+
"webpacker:check_yarn" => "DEPRECATED - Verifies if Yarn is installed",
|
9
|
+
"webpacker:check_binstubs" => "DEPRECATED - Verifies that bin/shakapacker is present",
|
10
|
+
"webpacker:binstubs" => "DEPRECATED - Installs Shakapacker binstubs in this application",
|
11
|
+
"webpacker:verify_install" => "DEPRECATED - Verifies if Shakapacker is installed",
|
12
12
|
}.freeze
|
13
13
|
|
14
|
-
desc "Lists all available tasks in Webpacker"
|
15
|
-
task :webpacker do
|
16
|
-
puts "Available Webpacker tasks are:"
|
14
|
+
desc "DEPRECATED - Lists all available tasks in Webpacker"
|
15
|
+
task :webpacker do |task|
|
16
|
+
puts "DEPRECATED - Available Webpacker tasks are:"
|
17
17
|
tasks.each { |task, message| puts task.ljust(30) + message }
|
18
|
+
|
19
|
+
Shakapacker.puts_rake_deprecation_message(task.name)
|
18
20
|
end
|
@@ -1,96 +1,9 @@
|
|
1
|
-
|
2
|
-
require "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
load_config
|
11
|
-
detect_unsupported_switches!
|
12
|
-
detect_port!
|
13
|
-
execute_cmd
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def load_config
|
19
|
-
app_root = Pathname.new(@app_path)
|
20
|
-
|
21
|
-
@config = Configuration.new(
|
22
|
-
root_path: app_root,
|
23
|
-
config_path: Pathname.new(@webpacker_config),
|
24
|
-
env: ENV["RAILS_ENV"]
|
25
|
-
)
|
26
|
-
|
27
|
-
dev_server = DevServer.new(@config)
|
28
|
-
|
29
|
-
@hostname = dev_server.host
|
30
|
-
@port = dev_server.port
|
31
|
-
@pretty = dev_server.pretty?
|
32
|
-
@https = dev_server.https?
|
33
|
-
@hot = dev_server.hmr?
|
34
|
-
|
35
|
-
rescue Errno::ENOENT, NoMethodError
|
36
|
-
$stdout.puts "webpack dev_server configuration not found in #{@config.config_path}[#{ENV["RAILS_ENV"]}]."
|
37
|
-
$stdout.puts "Please run bundle exec rails webpacker:install to install Webpacker"
|
38
|
-
exit!
|
39
|
-
end
|
40
|
-
|
41
|
-
UNSUPPORTED_SWITCHES = %w[--host --port]
|
42
|
-
private_constant :UNSUPPORTED_SWITCHES
|
43
|
-
def detect_unsupported_switches!
|
44
|
-
unsupported_switches = UNSUPPORTED_SWITCHES & @argv
|
45
|
-
if unsupported_switches.any?
|
46
|
-
$stdout.puts "The following CLI switches are not supported by Webpacker: #{unsupported_switches.join(' ')}. Please edit your command and try again."
|
47
|
-
exit!
|
48
|
-
end
|
49
|
-
|
50
|
-
if @argv.include?("--https") && !@https
|
51
|
-
$stdout.puts "Please set https: true in webpacker.yml to use the --https command line flag."
|
52
|
-
exit!
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def detect_port!
|
57
|
-
server = TCPServer.new(@hostname, @port)
|
58
|
-
server.close
|
59
|
-
|
60
|
-
rescue Errno::EADDRINUSE
|
61
|
-
$stdout.puts "Another program is running on port #{@port}. Set a new port in #{@config.config_path} for dev_server"
|
62
|
-
exit!
|
63
|
-
end
|
64
|
-
|
65
|
-
def execute_cmd
|
66
|
-
env = Webpacker::Compiler.env
|
67
|
-
env["WEBPACKER_CONFIG"] = @webpacker_config
|
68
|
-
env["WEBPACK_SERVE"] = "true"
|
69
|
-
|
70
|
-
cmd = if node_modules_bin_exist?
|
71
|
-
["#{@node_modules_bin_path}/webpack", "serve"]
|
72
|
-
else
|
73
|
-
["yarn", "webpack", "serve"]
|
74
|
-
end
|
75
|
-
|
76
|
-
if @argv.include?("--debug-webpacker")
|
77
|
-
cmd = [ "node", "--inspect-brk", "--trace-warnings" ] + cmd
|
78
|
-
@argv.delete "--debug-webpacker"
|
79
|
-
end
|
80
|
-
|
81
|
-
cmd += ["--config", @webpack_config]
|
82
|
-
cmd += ["--progress", "--color"] if @pretty
|
83
|
-
|
84
|
-
cmd += ["--hot"] if @hot
|
85
|
-
cmd += @argv
|
86
|
-
|
87
|
-
Dir.chdir(@app_path) do
|
88
|
-
Kernel.exec env, *cmd
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def node_modules_bin_exist?
|
93
|
-
File.exist?("#{@node_modules_bin_path}/webpack-dev-server")
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
1
|
+
# This file exists for backward compatibility
|
2
|
+
require "shakapacker/dev_server_runner"
|
3
|
+
|
4
|
+
Shakapacker.puts_deprecation_message(
|
5
|
+
Shakapacker.short_deprecation_message(
|
6
|
+
"bin/webpacker-dev-server",
|
7
|
+
"bin/shakapacker-dev-server"
|
8
|
+
)
|
9
|
+
)
|
@@ -1,58 +1,9 @@
|
|
1
|
-
|
2
|
-
require "
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"-h",
|
11
|
-
"version",
|
12
|
-
"v",
|
13
|
-
"--version",
|
14
|
-
"-v",
|
15
|
-
"info",
|
16
|
-
"i"
|
17
|
-
].freeze
|
18
|
-
|
19
|
-
def run
|
20
|
-
env = Webpacker::Compiler.env
|
21
|
-
env["WEBPACKER_CONFIG"] = @webpacker_config
|
22
|
-
|
23
|
-
cmd = if node_modules_bin_exist?
|
24
|
-
["#{@node_modules_bin_path}/webpack"]
|
25
|
-
else
|
26
|
-
["yarn", "webpack"]
|
27
|
-
end
|
28
|
-
|
29
|
-
if @argv.delete "--debug-webpacker"
|
30
|
-
cmd = ["node", "--inspect-brk"] + cmd
|
31
|
-
end
|
32
|
-
|
33
|
-
if @argv.delete "--trace-deprecation"
|
34
|
-
cmd = ["node", "--trace-deprecation"] + cmd
|
35
|
-
end
|
36
|
-
|
37
|
-
if @argv.delete "--no-deprecation"
|
38
|
-
cmd = ["node", "--no-deprecation"] + cmd
|
39
|
-
end
|
40
|
-
|
41
|
-
# Webpack commands are not compatible with --config option.
|
42
|
-
if (@argv & WEBPACK_COMMANDS).empty?
|
43
|
-
cmd += ["--config", @webpack_config]
|
44
|
-
end
|
45
|
-
|
46
|
-
cmd += @argv
|
47
|
-
|
48
|
-
Dir.chdir(@app_path) do
|
49
|
-
Kernel.exec env, *cmd
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
def node_modules_bin_exist?
|
55
|
-
File.exist?("#{@node_modules_bin_path}/webpack")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
1
|
+
# This file exists for backward compatibility
|
2
|
+
require "shakapacker/webpack_runner"
|
3
|
+
|
4
|
+
Shakapacker.puts_deprecation_message(
|
5
|
+
Shakapacker.short_deprecation_message(
|
6
|
+
"bin/webpacker",
|
7
|
+
"bin/shakapacker"
|
8
|
+
)
|
9
|
+
)
|
data/lib/webpacker.rb
CHANGED
@@ -1,48 +1,4 @@
|
|
1
|
-
|
2
|
-
require "
|
3
|
-
require "active_support/logger"
|
4
|
-
require "active_support/tagged_logging"
|
1
|
+
# This file exists for backward compatibility
|
2
|
+
require "shakapacker"
|
5
3
|
|
6
|
-
|
7
|
-
extend self
|
8
|
-
|
9
|
-
DEFAULT_ENV = "production".freeze
|
10
|
-
|
11
|
-
def instance=(instance)
|
12
|
-
@instance = instance
|
13
|
-
end
|
14
|
-
|
15
|
-
def instance
|
16
|
-
@instance ||= Webpacker::Instance.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def with_node_env(env)
|
20
|
-
original = ENV["NODE_ENV"]
|
21
|
-
ENV["NODE_ENV"] = env
|
22
|
-
yield
|
23
|
-
ensure
|
24
|
-
ENV["NODE_ENV"] = original
|
25
|
-
end
|
26
|
-
|
27
|
-
def ensure_log_goes_to_stdout
|
28
|
-
old_logger = Webpacker.logger
|
29
|
-
Webpacker.logger = Logger.new(STDOUT)
|
30
|
-
yield
|
31
|
-
ensure
|
32
|
-
Webpacker.logger = old_logger
|
33
|
-
end
|
34
|
-
|
35
|
-
delegate :logger, :logger=, :env, :inlining_css?, to: :instance
|
36
|
-
delegate :config, :compiler, :manifest, :commands, :dev_server, to: :instance
|
37
|
-
delegate :bootstrap, :clean, :clobber, :compile, to: :commands
|
38
|
-
end
|
39
|
-
|
40
|
-
require "webpacker/instance"
|
41
|
-
require "webpacker/env"
|
42
|
-
require "webpacker/configuration"
|
43
|
-
require "webpacker/manifest"
|
44
|
-
require "webpacker/compiler"
|
45
|
-
require "webpacker/commands"
|
46
|
-
require "webpacker/dev_server"
|
47
|
-
|
48
|
-
require "webpacker/railtie" if defined?(Rails)
|
4
|
+
Shakapacker.puts_deprecation_message(Shakapacker::DEPRECATION_MESSAGE)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* global test expect, describe */
|
2
|
+
const { resolve } = require('path')
|
3
|
+
const { chdirWebpackerTestApp, resetEnv } = require('../utils/helpers')
|
4
|
+
|
5
|
+
const rootPath = process.cwd()
|
6
|
+
chdirWebpackerTestApp()
|
7
|
+
|
8
|
+
const config = require('../config')
|
9
|
+
|
10
|
+
describe('Backward Compatibility - Config', () => {
|
11
|
+
beforeEach(() => jest.resetModules() && resetEnv())
|
12
|
+
afterAll(() => process.chdir(rootPath))
|
13
|
+
|
14
|
+
test('x public path with asset host', () => {
|
15
|
+
process.env.RAILS_ENV = 'development'
|
16
|
+
process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/'
|
17
|
+
const config = require('../config')
|
18
|
+
|
19
|
+
expect(config.publicPath).toEqual('http://foo.com/packs/')
|
20
|
+
})
|
21
|
+
|
22
|
+
test('x should allow overriding manifestPath', () => {
|
23
|
+
process.env.WEBPACKER_CONFIG = 'config/webpacker_manifest_path.yml'
|
24
|
+
const config = require('../config')
|
25
|
+
expect(config.manifestPath).toEqual(resolve('app/packs/manifest.json'))
|
26
|
+
})
|
27
|
+
})
|
data/package/__tests__/config.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
/* global test expect, describe */
|
2
2
|
|
3
|
-
const {
|
3
|
+
const { chdirTestApp, resetEnv } = require('../utils/helpers')
|
4
4
|
const { resolve } = require('path')
|
5
5
|
|
6
|
+
const rootPath = process.cwd()
|
6
7
|
chdirTestApp()
|
7
8
|
|
8
9
|
const config = require('../config')
|
9
10
|
|
10
11
|
describe('Config', () => {
|
11
12
|
beforeEach(() => jest.resetModules() && resetEnv())
|
12
|
-
afterAll(
|
13
|
+
afterAll(() => process.chdir(rootPath))
|
13
14
|
|
14
15
|
test('public path', () => {
|
15
16
|
process.env.RAILS_ENV = 'development'
|
@@ -19,7 +20,7 @@ describe('Config', () => {
|
|
19
20
|
|
20
21
|
test('public path with asset host', () => {
|
21
22
|
process.env.RAILS_ENV = 'development'
|
22
|
-
process.env.
|
23
|
+
process.env.SHAKAPACKER_ASSET_HOST = 'http://foo.com/'
|
23
24
|
const config = require('../config')
|
24
25
|
expect(config.publicPath).toEqual('http://foo.com/packs/')
|
25
26
|
})
|
@@ -38,8 +39,8 @@ describe('Config', () => {
|
|
38
39
|
})
|
39
40
|
|
40
41
|
test('should allow overriding manifestPath', () => {
|
41
|
-
process.env.
|
42
|
+
process.env.SHAKAPACKER_CONFIG = 'config/shakapacker_manifest_path.yml'
|
42
43
|
const config = require('../config')
|
43
|
-
expect(config.manifestPath).toEqual(resolve('app/
|
44
|
+
expect(config.manifestPath).toEqual(resolve('app/javascript/manifest.json'))
|
44
45
|
})
|
45
46
|
})
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/* global test expect, describe */
|
2
|
+
|
3
|
+
const { chdirWebpackerTestApp } = require('../utils/helpers')
|
4
|
+
|
5
|
+
const rootPath = process.cwd()
|
6
|
+
chdirWebpackerTestApp()
|
7
|
+
|
8
|
+
describe('Backward Compatibility - DevServer', () => {
|
9
|
+
beforeEach(() => jest.resetModules())
|
10
|
+
afterAll(() => process.chdir(rootPath))
|
11
|
+
|
12
|
+
test('with NODE_ENV and RAILS_ENV set to development', () => {
|
13
|
+
process.env.NODE_ENV = 'development'
|
14
|
+
process.env.RAILS_ENV = 'development'
|
15
|
+
process.env.WEBPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
16
|
+
process.env.WEBPACKER_DEV_SERVER_PORT = 5000
|
17
|
+
process.env.WEBPACKER_DEV_SERVER_DISABLE_HOST_CHECK = false
|
18
|
+
|
19
|
+
const devServer = require('../dev_server')
|
20
|
+
expect(devServer).toBeDefined()
|
21
|
+
expect(devServer.host).toEqual('0.0.0.0')
|
22
|
+
expect(devServer.port).toEqual('5000')
|
23
|
+
expect(devServer.disable_host_check).toBe(false)
|
24
|
+
})
|
25
|
+
|
26
|
+
test('with custom env prefix', () => {
|
27
|
+
const config = require('../config')
|
28
|
+
config.dev_server.env_prefix = 'TEST_WEBPACKER_DEV_SERVER'
|
29
|
+
|
30
|
+
process.env.NODE_ENV = 'development'
|
31
|
+
process.env.RAILS_ENV = 'development'
|
32
|
+
process.env.TEST_WEBPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
33
|
+
process.env.TEST_WEBPACKER_DEV_SERVER_PORT = 5000
|
34
|
+
|
35
|
+
const devServer = require('../dev_server')
|
36
|
+
expect(devServer).toBeDefined()
|
37
|
+
expect(devServer.host).toEqual('0.0.0.0')
|
38
|
+
expect(devServer.port).toEqual('5000')
|
39
|
+
})
|
40
|
+
|
41
|
+
test('with NODE_ENV and RAILS_ENV set to production', () => {
|
42
|
+
process.env.RAILS_ENV = 'production'
|
43
|
+
process.env.NODE_ENV = 'production'
|
44
|
+
expect(require('../dev_server')).toEqual({})
|
45
|
+
})
|
46
|
+
})
|
@@ -1,19 +1,20 @@
|
|
1
1
|
/* global test expect, describe */
|
2
2
|
|
3
|
-
const { chdirTestApp
|
3
|
+
const { chdirTestApp } = require('../utils/helpers')
|
4
4
|
|
5
|
+
const rootPath = process.cwd()
|
5
6
|
chdirTestApp()
|
6
7
|
|
7
8
|
describe('DevServer', () => {
|
8
9
|
beforeEach(() => jest.resetModules())
|
9
|
-
afterAll(
|
10
|
+
afterAll(() => process.chdir(rootPath))
|
10
11
|
|
11
12
|
test('with NODE_ENV and RAILS_ENV set to development', () => {
|
12
13
|
process.env.NODE_ENV = 'development'
|
13
14
|
process.env.RAILS_ENV = 'development'
|
14
|
-
process.env.
|
15
|
-
process.env.
|
16
|
-
process.env.
|
15
|
+
process.env.SHAKAPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
16
|
+
process.env.SHAKAPACKER_DEV_SERVER_PORT = 5000
|
17
|
+
process.env.SHAKAPACKER_DEV_SERVER_DISABLE_HOST_CHECK = false
|
17
18
|
|
18
19
|
const devServer = require('../dev_server')
|
19
20
|
expect(devServer).toBeDefined()
|
@@ -24,12 +25,12 @@ describe('DevServer', () => {
|
|
24
25
|
|
25
26
|
test('with custom env prefix', () => {
|
26
27
|
const config = require('../config')
|
27
|
-
config.dev_server.env_prefix = '
|
28
|
+
config.dev_server.env_prefix = 'TEST_SHAKAPACKER_DEV_SERVER'
|
28
29
|
|
29
30
|
process.env.NODE_ENV = 'development'
|
30
31
|
process.env.RAILS_ENV = 'development'
|
31
|
-
process.env.
|
32
|
-
process.env.
|
32
|
+
process.env.TEST_SHAKAPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
33
|
+
process.env.TEST_SHAKAPACKER_DEV_SERVER_PORT = 5000
|
33
34
|
|
34
35
|
const devServer = require('../dev_server')
|
35
36
|
expect(devServer).toBeDefined()
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/* test expect, describe, afterAll, beforeEach */
|
2
|
+
|
3
|
+
const { resolve } = require('path')
|
4
|
+
const { chdirWebpackerTestApp, resetEnv } = require('../utils/helpers')
|
5
|
+
|
6
|
+
const rootPath = process.cwd()
|
7
|
+
chdirWebpackerTestApp()
|
8
|
+
|
9
|
+
describe('Backward Compatibility - Development environment', () => {
|
10
|
+
beforeEach(() => jest.resetModules() && resetEnv())
|
11
|
+
afterAll(() => process.chdir(rootPath))
|
12
|
+
|
13
|
+
describe('generateWebpackConfig', () => {
|
14
|
+
beforeEach(() => jest.resetModules())
|
15
|
+
|
16
|
+
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
|
17
|
+
process.env.RAILS_ENV = 'development'
|
18
|
+
process.env.NODE_ENV = 'development'
|
19
|
+
process.env.WEBPACK_SERVE = 'true'
|
20
|
+
const { generateWebpackConfig } = require('../index')
|
21
|
+
|
22
|
+
const webpackConfig = generateWebpackConfig()
|
23
|
+
|
24
|
+
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
25
|
+
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
26
|
+
})
|
27
|
+
|
28
|
+
test('should use development config and environment if WEBPACK_SERVE', () => {
|
29
|
+
process.env.RAILS_ENV = 'development'
|
30
|
+
process.env.NODE_ENV = 'development'
|
31
|
+
process.env.WEBPACK_SERVE = undefined
|
32
|
+
const { generateWebpackConfig } = require('../index')
|
33
|
+
|
34
|
+
const webpackConfig = generateWebpackConfig()
|
35
|
+
|
36
|
+
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
37
|
+
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
38
|
+
expect(webpackConfig.devServer).toEqual(undefined)
|
39
|
+
})
|
40
|
+
})
|
41
|
+
|
42
|
+
describe('globalMutableWebpackConfig', () => {
|
43
|
+
beforeEach(() => jest.resetModules())
|
44
|
+
|
45
|
+
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
|
46
|
+
process.env.RAILS_ENV = 'development'
|
47
|
+
process.env.NODE_ENV = 'development'
|
48
|
+
process.env.WEBPACK_SERVE = 'true'
|
49
|
+
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
50
|
+
|
51
|
+
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
52
|
+
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
53
|
+
})
|
54
|
+
|
55
|
+
test('should use development config and environment if WEBPACK_SERVE', () => {
|
56
|
+
process.env.RAILS_ENV = 'development'
|
57
|
+
process.env.NODE_ENV = 'development'
|
58
|
+
process.env.WEBPACK_SERVE = undefined
|
59
|
+
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
60
|
+
|
61
|
+
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
62
|
+
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
63
|
+
expect(webpackConfig.devServer).toEqual(undefined)
|
64
|
+
})
|
65
|
+
})
|
66
|
+
})
|