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
@@ -0,0 +1,64 @@
|
|
1
|
+
const path = require("path");
|
2
|
+
const {
|
3
|
+
app_javascript,
|
4
|
+
node_modules,
|
5
|
+
node_modules_included,
|
6
|
+
createTestCompiler,
|
7
|
+
createTrackLoader,
|
8
|
+
} = require("./__utils__/webpack");
|
9
|
+
const esbuildConfig = require("../esbuild");
|
10
|
+
|
11
|
+
jest.mock("../../config", () => {
|
12
|
+
const original = jest.requireActual("../../config");
|
13
|
+
return {
|
14
|
+
...original,
|
15
|
+
webpack_loader: "esbuild",
|
16
|
+
additional_paths: [...original.additional_paths, "node_modules/included"],
|
17
|
+
};
|
18
|
+
});
|
19
|
+
|
20
|
+
const createWebpackConfig = (file, use) => {
|
21
|
+
return {
|
22
|
+
entry: { file },
|
23
|
+
module: {
|
24
|
+
rules: [
|
25
|
+
{
|
26
|
+
...esbuildConfig,
|
27
|
+
use,
|
28
|
+
},
|
29
|
+
],
|
30
|
+
},
|
31
|
+
output: {
|
32
|
+
path: "/",
|
33
|
+
filename: "scripts-bundled.js",
|
34
|
+
},
|
35
|
+
};
|
36
|
+
};
|
37
|
+
|
38
|
+
describe("swc", () => {
|
39
|
+
test("process source path", async () => {
|
40
|
+
const normalPath = `${app_javascript}/a.js`;
|
41
|
+
const [tracked, loader] = createTrackLoader();
|
42
|
+
const compiler = createTestCompiler(
|
43
|
+
createWebpackConfig(normalPath, loader)
|
44
|
+
);
|
45
|
+
await compiler.run();
|
46
|
+
expect(tracked[normalPath]).toBeTruthy();
|
47
|
+
});
|
48
|
+
|
49
|
+
test("exclude node_modules", async () => {
|
50
|
+
const ignored = `${node_modules}/a.js`;
|
51
|
+
const [tracked, loader] = createTrackLoader();
|
52
|
+
const compiler = createTestCompiler(createWebpackConfig(ignored, loader));
|
53
|
+
await compiler.run();
|
54
|
+
expect(tracked[ignored]).toBeUndefined();
|
55
|
+
});
|
56
|
+
|
57
|
+
test("explicitly included node_modules should be transpiled", async () => {
|
58
|
+
const included = `${node_modules_included}/a.js`;
|
59
|
+
const [tracked, loader] = createTrackLoader();
|
60
|
+
const compiler = createTestCompiler(createWebpackConfig(included, loader));
|
61
|
+
await compiler.run();
|
62
|
+
expect(tracked[included]).toBeTruthy();
|
63
|
+
});
|
64
|
+
});
|
@@ -32,4 +32,31 @@ describe('file', () => {
|
|
32
32
|
]
|
33
33
|
types.forEach(type => expect(file.exclude.test(type)).toBe(true))
|
34
34
|
})
|
35
|
+
|
36
|
+
test('correct generated output path is returned for top level files', () => {
|
37
|
+
const pathData = {
|
38
|
+
filename: 'app/javascript/image.svg',
|
39
|
+
};
|
40
|
+
expect(file.generator.filename(pathData)).toEqual(
|
41
|
+
'static/[name]-[hash][ext][query]'
|
42
|
+
);
|
43
|
+
});
|
44
|
+
|
45
|
+
test('correct generated output path is returned for nested files', () => {
|
46
|
+
const pathData = {
|
47
|
+
filename: 'app/javascript/images/image.svg',
|
48
|
+
};
|
49
|
+
expect(file.generator.filename(pathData)).toEqual(
|
50
|
+
'static/images/[name]-[hash][ext][query]'
|
51
|
+
);
|
52
|
+
})
|
53
|
+
|
54
|
+
test('correct generated output path is returned for deeply nested files', () => {
|
55
|
+
const pathData = {
|
56
|
+
filename: 'app/javascript/images/nested/deeply/image.svg',
|
57
|
+
};
|
58
|
+
expect(file.generator.filename(pathData)).toEqual(
|
59
|
+
'static/images/nested/deeply/[name]-[hash][ext][query]'
|
60
|
+
);
|
61
|
+
});
|
35
62
|
})
|
@@ -4,8 +4,4 @@ describe('index', () => {
|
|
4
4
|
test('rule tests are regexes', () => {
|
5
5
|
rules.forEach(rule => expect(rule.test instanceof RegExp).toBe(true))
|
6
6
|
})
|
7
|
-
|
8
|
-
test('rule excludes are regexes', () => {
|
9
|
-
rules.forEach(rule => expect(rule.exclude instanceof RegExp).toBe(true))
|
10
|
-
})
|
11
7
|
})
|
@@ -0,0 +1,63 @@
|
|
1
|
+
const {
|
2
|
+
app_javascript,
|
3
|
+
node_modules,
|
4
|
+
node_modules_included,
|
5
|
+
createTestCompiler,
|
6
|
+
createTrackLoader,
|
7
|
+
} = require("./__utils__/webpack");
|
8
|
+
const swcConfig = require("../swc");
|
9
|
+
|
10
|
+
jest.mock("../../config", () => {
|
11
|
+
const original = jest.requireActual("../../config");
|
12
|
+
return {
|
13
|
+
...original,
|
14
|
+
webpack_loader: "swc",
|
15
|
+
additional_paths: [...original.additional_paths, "node_modules/included"],
|
16
|
+
};
|
17
|
+
});
|
18
|
+
|
19
|
+
const createWebpackConfig = (file, use) => {
|
20
|
+
return {
|
21
|
+
entry: { file },
|
22
|
+
module: {
|
23
|
+
rules: [
|
24
|
+
{
|
25
|
+
...swcConfig,
|
26
|
+
use,
|
27
|
+
},
|
28
|
+
],
|
29
|
+
},
|
30
|
+
output: {
|
31
|
+
path: "/",
|
32
|
+
filename: "scripts-bundled.js",
|
33
|
+
},
|
34
|
+
};
|
35
|
+
};
|
36
|
+
|
37
|
+
describe("swc", () => {
|
38
|
+
test("process files in source_path", async () => {
|
39
|
+
const normalPath = `${app_javascript}/a.js`;
|
40
|
+
const [tracked, loader] = createTrackLoader();
|
41
|
+
const compiler = createTestCompiler(
|
42
|
+
createWebpackConfig(normalPath, loader)
|
43
|
+
);
|
44
|
+
await compiler.run();
|
45
|
+
expect(tracked[normalPath]).toBeTruthy();
|
46
|
+
});
|
47
|
+
|
48
|
+
test("exclude node_modules", async () => {
|
49
|
+
const ignored = `${node_modules}/a.js`;
|
50
|
+
const [tracked, loader] = createTrackLoader();
|
51
|
+
const compiler = createTestCompiler(createWebpackConfig(ignored, loader));
|
52
|
+
await compiler.run();
|
53
|
+
expect(tracked[ignored]).toBeUndefined();
|
54
|
+
});
|
55
|
+
|
56
|
+
test("explicitly included node_modules should be transpiled", async () => {
|
57
|
+
const included = `${node_modules_included}/a.js`;
|
58
|
+
const [tracked, loader] = createTrackLoader();
|
59
|
+
const compiler = createTestCompiler(createWebpackConfig(included, loader));
|
60
|
+
await compiler.run();
|
61
|
+
expect(tracked[included]).toBeTruthy();
|
62
|
+
});
|
63
|
+
});
|
data/package/rules/babel.js
CHANGED
@@ -1,32 +1,21 @@
|
|
1
|
-
const { resolve } = require('path')
|
2
|
-
const { realpathSync } = require('fs')
|
3
1
|
const { loaderMatches } = require('../utils/helpers')
|
4
|
-
|
5
2
|
const {
|
6
|
-
source_path: sourcePath,
|
7
|
-
additional_paths: additionalPaths,
|
8
3
|
webpack_loader: webpackLoader
|
9
4
|
} = require('../config')
|
10
5
|
const { isProduction } = require('../env')
|
6
|
+
const jscommon = require('./jscommon')
|
11
7
|
|
12
8
|
module.exports = loaderMatches(webpackLoader, 'babel', () => ({
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
use: [
|
23
|
-
{
|
24
|
-
loader: require.resolve('babel-loader'),
|
25
|
-
options: {
|
26
|
-
cacheDirectory: true,
|
27
|
-
cacheCompression: isProduction,
|
28
|
-
compact: isProduction
|
29
|
-
}
|
9
|
+
test: /\.(js|jsx|mjs|ts|tsx|coffee)?(\.erb)?$/,
|
10
|
+
...jscommon,
|
11
|
+
use: [
|
12
|
+
{
|
13
|
+
loader: require.resolve('babel-loader'),
|
14
|
+
options: {
|
15
|
+
cacheDirectory: true,
|
16
|
+
cacheCompression: isProduction,
|
17
|
+
compact: isProduction
|
30
18
|
}
|
31
|
-
|
32
|
-
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}))
|
data/package/rules/esbuild.js
CHANGED
@@ -1,23 +1,12 @@
|
|
1
|
-
const { resolve } = require('path')
|
2
|
-
const { realpathSync } = require('fs')
|
3
1
|
const { loaderMatches } = require('../utils/helpers')
|
4
2
|
const { getEsbuildLoaderConfig } = require('../esbuild')
|
5
|
-
|
6
3
|
const {
|
7
|
-
source_path: sourcePath,
|
8
|
-
additional_paths: additionalPaths,
|
9
4
|
webpack_loader: webpackLoader
|
10
5
|
} = require('../config')
|
6
|
+
const jscommon = require('./jscommon')
|
11
7
|
|
12
8
|
module.exports = loaderMatches(webpackLoader, 'esbuild', () => ({
|
13
9
|
test: /\.(ts|tsx|js|jsx|mjs|coffee)?(\.erb)?$/,
|
14
|
-
|
15
|
-
try {
|
16
|
-
return realpathSync(p)
|
17
|
-
} catch (e) {
|
18
|
-
return resolve(p)
|
19
|
-
}
|
20
|
-
}),
|
21
|
-
exclude: /node_modules/,
|
10
|
+
...jscommon,
|
22
11
|
use: ({ resource }) => getEsbuildLoaderConfig(resource)
|
23
12
|
}))
|
data/package/rules/file.js
CHANGED
@@ -8,9 +8,9 @@ module.exports = {
|
|
8
8
|
generator: {
|
9
9
|
filename: (pathData) => {
|
10
10
|
const folders = dirname(pathData.filename)
|
11
|
-
.replace(`${sourcePath}
|
11
|
+
.replace(`${sourcePath}`, '')
|
12
12
|
.split('/')
|
13
|
-
.
|
13
|
+
.filter(Boolean)
|
14
14
|
|
15
15
|
const foldersWithStatic = ['static', ...folders].join('/')
|
16
16
|
return `${foldersWithStatic}/[name]-[hash][ext][query]`
|
@@ -0,0 +1,26 @@
|
|
1
|
+
const { resolve } = require('path')
|
2
|
+
const { realpathSync } = require('fs')
|
3
|
+
const {
|
4
|
+
source_path: sourcePath,
|
5
|
+
additional_paths: additionalPaths
|
6
|
+
} = require('../config')
|
7
|
+
|
8
|
+
const inclusions = [sourcePath, ...additionalPaths].map(p => {
|
9
|
+
try {
|
10
|
+
return realpathSync(p)
|
11
|
+
} catch (e) {
|
12
|
+
return resolve(p)
|
13
|
+
}
|
14
|
+
})
|
15
|
+
|
16
|
+
module.exports = {
|
17
|
+
include: inclusions,
|
18
|
+
exclude: [
|
19
|
+
{
|
20
|
+
// exclude all node_modules from running through babel-loader
|
21
|
+
and: [resolve('node_modules')],
|
22
|
+
// Do not exclude inclusions, as otherwise these won't be transpiled
|
23
|
+
not: [...inclusions]
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
data/package/rules/swc.js
CHANGED
@@ -1,23 +1,12 @@
|
|
1
|
-
const { resolve } = require('path')
|
2
|
-
const { realpathSync } = require('fs')
|
3
1
|
const { loaderMatches } = require('../utils/helpers')
|
4
2
|
const { getSwcLoaderConfig } = require('../swc')
|
5
|
-
|
6
3
|
const {
|
7
|
-
source_path: sourcePath,
|
8
|
-
additional_paths: additionalPaths,
|
9
4
|
webpack_loader: webpackLoader
|
10
5
|
} = require('../config')
|
6
|
+
const jscommon = require('./jscommon')
|
11
7
|
|
12
8
|
module.exports = loaderMatches(webpackLoader, 'swc', () => ({
|
13
9
|
test: /\.(ts|tsx|js|jsx|mjs|coffee)?(\.erb)?$/,
|
14
|
-
|
15
|
-
try {
|
16
|
-
return realpathSync(p)
|
17
|
-
} catch (e) {
|
18
|
-
return resolve(p)
|
19
|
-
}
|
20
|
-
}),
|
21
|
-
exclude: /node_modules/,
|
10
|
+
...jscommon,
|
22
11
|
use: ({ resource }) => getSwcLoaderConfig(resource)
|
23
12
|
}))
|
@@ -0,0 +1,19 @@
|
|
1
|
+
const fs = require('fs')
|
2
|
+
const { resolve } = require('path')
|
3
|
+
const { setShakapackerEnvVariablesForBackwardCompatibility } = require('./helpers')
|
4
|
+
|
5
|
+
setShakapackerEnvVariablesForBackwardCompatibility()
|
6
|
+
|
7
|
+
// For backward compatibility
|
8
|
+
const resolveToPhysicalFilePath = () => {
|
9
|
+
const shakapackerConfigPath = resolve('config', 'shakapacker.yml')
|
10
|
+
const webpackerConfigPath = resolve('config', 'webpacker.yml')
|
11
|
+
|
12
|
+
if (fs.existsSync(shakapackerConfigPath)) return shakapackerConfigPath
|
13
|
+
if (fs.existsSync(webpackerConfigPath)) return webpackerConfigPath
|
14
|
+
|
15
|
+
// If neither of files exist, try to resolve to shakapacker.yml to get more relevant error
|
16
|
+
return shakapackerConfigPath
|
17
|
+
}
|
18
|
+
|
19
|
+
module.exports = process.env.SHAKAPACKER_CONFIG || resolveToPhysicalFilePath()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
const { canProcess, moduleExists } = require('./helpers')
|
3
|
-
const inliningCss = require('
|
3
|
+
const inliningCss = require('./inliningCss')
|
4
4
|
|
5
5
|
const getStyleRule = (test, preprocessors = []) => {
|
6
6
|
if (moduleExists('css-loader')) {
|
@@ -18,7 +18,10 @@ const getStyleRule = (test, preprocessors = []) => {
|
|
18
18
|
loader: require.resolve('css-loader'),
|
19
19
|
options: {
|
20
20
|
sourceMap: true,
|
21
|
-
importLoaders: 2
|
21
|
+
importLoaders: 2,
|
22
|
+
modules: {
|
23
|
+
auto: true
|
24
|
+
}
|
22
25
|
}
|
23
26
|
},
|
24
27
|
tryPostcss(),
|
data/package/utils/helpers.js
CHANGED
@@ -2,7 +2,16 @@ const isArray = (value) => Array.isArray(value)
|
|
2
2
|
const isBoolean = (str) => /^true/.test(str) || /^false/.test(str)
|
3
3
|
const chdirTestApp = () => {
|
4
4
|
try {
|
5
|
-
return process.chdir('
|
5
|
+
return process.chdir('spec/shakapacker/test_app')
|
6
|
+
} catch (e) {
|
7
|
+
return null
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
// For backward compatibility
|
12
|
+
const chdirWebpackerTestApp = () => {
|
13
|
+
try {
|
14
|
+
return process.chdir('spec/backward_compatibility_specs/webpacker_test_app')
|
6
15
|
} catch (e) {
|
7
16
|
return null
|
8
17
|
}
|
@@ -48,15 +57,29 @@ const loaderMatches = (configLoader, loaderToCheck, fn) => {
|
|
48
57
|
|
49
58
|
if (!moduleExists(loaderName)) {
|
50
59
|
throw new Error(
|
51
|
-
`Your
|
60
|
+
`Your Shakapacker config specified using ${configLoader}, but ${loaderName} package is not installed. Please install ${loaderName} first.`
|
52
61
|
)
|
53
62
|
}
|
54
63
|
|
55
64
|
return fn()
|
56
65
|
}
|
57
66
|
|
67
|
+
// For backward compatibility
|
68
|
+
// Set SHAKAPACKER_XYZ only if SHAKAPACKER_XYZ is not defined but WEBPACKER_XYZ is.
|
69
|
+
const setShakapackerEnvVariablesForBackwardCompatibility = () => {
|
70
|
+
const webpackerEnvVariables = Object.entries(process.env).filter((key) => /^WEBPACKER_/.test(key))
|
71
|
+
webpackerEnvVariables.forEach(([webpackerEnvKey, webpackerEnvValue]) => {
|
72
|
+
const shakapackerKey = webpackerEnvKey.replace(/^WEBPACKER/, 'SHAKAPACKER')
|
73
|
+
if (!process.env[shakapackerKey]) {
|
74
|
+
process.env[shakapackerKey] = webpackerEnvValue
|
75
|
+
}
|
76
|
+
})
|
77
|
+
}
|
78
|
+
|
58
79
|
module.exports = {
|
59
80
|
chdirTestApp,
|
81
|
+
chdirWebpackerTestApp,
|
82
|
+
setShakapackerEnvVariablesForBackwardCompatibility,
|
60
83
|
chdirCwd,
|
61
84
|
isArray,
|
62
85
|
isBoolean,
|
@@ -0,0 +1,7 @@
|
|
1
|
+
const { runningWebpackDevServer } = require('../env')
|
2
|
+
const devServer = require('../dev_server')
|
3
|
+
|
4
|
+
// This logic is tied to lib/shakapacker/instance.rb
|
5
|
+
const inliningCss = runningWebpackDevServer && devServer.hmr && devServer.inline_css !== false
|
6
|
+
|
7
|
+
module.exports = inliningCss
|
@@ -0,0 +1,68 @@
|
|
1
|
+
const shakapackerDevServerYamlConfig = require('./dev_server')
|
2
|
+
const snakeToCamelCase = require('./utils/snakeToCamelCase')
|
3
|
+
const { outputPath: contentBase, publicPath } = require('./config')
|
4
|
+
|
5
|
+
const webpackDevServerMappedKeys = new Set([
|
6
|
+
// client, server, liveReload, devMiddleware are handled separately
|
7
|
+
'allowedHosts',
|
8
|
+
'bonjour',
|
9
|
+
'compress',
|
10
|
+
'headers',
|
11
|
+
'historyApiFallback',
|
12
|
+
'host',
|
13
|
+
'hot',
|
14
|
+
'http2',
|
15
|
+
'https',
|
16
|
+
'ipc',
|
17
|
+
'magicHtml',
|
18
|
+
'onAfterSetupMiddleware',
|
19
|
+
'onBeforeSetupMiddleware',
|
20
|
+
'open',
|
21
|
+
'port',
|
22
|
+
'proxy',
|
23
|
+
'server',
|
24
|
+
'setupExitSignals',
|
25
|
+
'setupMiddlewares',
|
26
|
+
'watchFiles',
|
27
|
+
'webSocketServer'
|
28
|
+
])
|
29
|
+
|
30
|
+
function createDevServerConfig() {
|
31
|
+
const devServerYamlConfig = { ...shakapackerDevServerYamlConfig }
|
32
|
+
const liveReload = devServerYamlConfig.live_reload !== undefined ? devServerYamlConfig.live_reload : !devServerYamlConfig.hmr
|
33
|
+
delete devServerYamlConfig.live_reload
|
34
|
+
|
35
|
+
const config = {
|
36
|
+
devMiddleware: {
|
37
|
+
publicPath
|
38
|
+
},
|
39
|
+
liveReload,
|
40
|
+
historyApiFallback: {
|
41
|
+
disableDotRule: true
|
42
|
+
},
|
43
|
+
static: {
|
44
|
+
publicPath: contentBase
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
if (devServerYamlConfig.static) {
|
49
|
+
config.static = { ...config.static, ...devServerYamlConfig.static }
|
50
|
+
delete devServerYamlConfig.static
|
51
|
+
}
|
52
|
+
|
53
|
+
if (devServerYamlConfig.client) {
|
54
|
+
config.client = devServerYamlConfig.client
|
55
|
+
delete devServerYamlConfig.client
|
56
|
+
}
|
57
|
+
|
58
|
+
Object.keys(devServerYamlConfig).forEach((yamlKey) => {
|
59
|
+
const camelYamlKey = snakeToCamelCase(yamlKey)
|
60
|
+
if (webpackDevServerMappedKeys.has(camelYamlKey)) {
|
61
|
+
config[camelYamlKey] = devServerYamlConfig[yamlKey]
|
62
|
+
}
|
63
|
+
})
|
64
|
+
|
65
|
+
return config
|
66
|
+
}
|
67
|
+
|
68
|
+
module.exports = createDevServerConfig
|
data/package.json
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "
|
3
|
+
"version": "7.0.2",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
6
|
"files": [
|
7
7
|
"package",
|
8
|
-
"lib/install/config/
|
8
|
+
"lib/install/config/shakapacker.yml"
|
9
9
|
],
|
10
10
|
"engines": {
|
11
11
|
"node": "^12.13.0 || ^14 || >=16",
|
@@ -16,12 +16,12 @@
|
|
16
16
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
17
17
|
"@babel/preset-env": "^7.16.11",
|
18
18
|
"@babel/runtime": "^7.17.9",
|
19
|
-
"babel-loader": "^8.2.4",
|
19
|
+
"babel-loader": "^8.2.4 || ^9.0.0",
|
20
20
|
"compression-webpack-plugin": "^9.0.0 || ^10.0.0",
|
21
21
|
"terser-webpack-plugin": "^5.3.1",
|
22
22
|
"webpack": "^5.72.0",
|
23
23
|
"webpack-assets-manifest": "^5.0.6",
|
24
|
-
"webpack-cli": "^4.9.2",
|
24
|
+
"webpack-cli": "^4.9.2 || ^5.0.0",
|
25
25
|
"webpack-dev-server": "^4.9.0",
|
26
26
|
"webpack-merge": "^5.8.0"
|
27
27
|
},
|
@@ -40,14 +40,20 @@
|
|
40
40
|
"eslint-plugin-import": "^2.24.2",
|
41
41
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
42
42
|
"eslint-plugin-react": "^7.26.0",
|
43
|
-
"jest": "^
|
43
|
+
"jest": "^28.1.3",
|
44
|
+
"memory-fs": "^0.5.0",
|
44
45
|
"swc-loader": "^0.1.15",
|
46
|
+
"thenify": "^3.3.1",
|
45
47
|
"webpack": "^5.72.0",
|
46
48
|
"webpack-assets-manifest": "^5.0.6",
|
47
49
|
"webpack-merge": "^5.8.0"
|
48
50
|
},
|
49
51
|
"jest": {
|
50
52
|
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$",
|
53
|
+
"testPathIgnorePatterns": [
|
54
|
+
"/__fixtures__/",
|
55
|
+
"/__utils__/"
|
56
|
+
],
|
51
57
|
"roots": [
|
52
58
|
"<rootDir>/package"
|
53
59
|
]
|
@@ -1,16 +1,16 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
|
-
require "
|
2
|
+
require "shakapacker/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "shakapacker"
|
6
|
-
s.version =
|
6
|
+
s.version = Shakapacker::VERSION
|
7
7
|
s.authors = [ "David Heinemeier Hansson", "Gaurav Tiwari", "Justin Gordon" ]
|
8
8
|
s.email = [ "david@basecamp.com", "gaurav@gauravtiwari.co.uk", "justin@shakacode.com" ]
|
9
9
|
s.summary = "Use webpack to manage app-like JavaScript modules in Rails"
|
10
10
|
s.homepage = "https://github.com/shakacode/shakapacker"
|
11
11
|
s.license = "MIT"
|
12
12
|
|
13
|
-
npm_version =
|
13
|
+
npm_version = Shakapacker::VERSION.gsub(".rc", "-rc")
|
14
14
|
s.metadata = {
|
15
15
|
"source_code_uri" => "https://github.com/shakacode/shakapacker/tree/v#{npm_version}",
|
16
16
|
}
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative "spec_helper_initializer"
|
2
|
+
|
3
|
+
describe "Command" do
|
4
|
+
before do
|
5
|
+
allow(Webpacker.logger).to receive(:info)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#compile" do
|
9
|
+
it "returns success status when stale" do
|
10
|
+
expect(Webpacker.compiler).to receive(:stale?).and_return(true)
|
11
|
+
expect(Webpacker.compiler).to receive(:run_webpack).and_return(true)
|
12
|
+
|
13
|
+
expect(Webpacker.commands.compile).to be true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns success status when fresh" do
|
17
|
+
expect(Webpacker.compiler).to receive(:stale?).and_return(false)
|
18
|
+
|
19
|
+
expect(Webpacker.commands.compile).to be true
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns failure status when stale" do
|
23
|
+
expect(Webpacker.compiler).to receive(:stale?).and_return(true)
|
24
|
+
expect(Webpacker.compiler).to receive(:run_webpack).and_return(false)
|
25
|
+
|
26
|
+
expect(Webpacker.commands.compile).to be false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#clean" do
|
31
|
+
let(:now) { Time.parse("2021-01-01 12:34:56 UTC") }
|
32
|
+
let(:prev_files) do
|
33
|
+
# Test assets to be kept and deleted, path and mtime
|
34
|
+
{
|
35
|
+
# recent versions to be kept with Webpacker.commands.clean(count = 2)
|
36
|
+
"js/application-deadbeef.js" => now - 4000,
|
37
|
+
"js/common-deadbeee.js" => now - 4002,
|
38
|
+
"css/common-deadbeed.css" => now - 4004,
|
39
|
+
"media/images/logo-deadbeeb.css" => now - 4006,
|
40
|
+
"js/application-1eadbeef.js" => now - 8000,
|
41
|
+
"js/common-1eadbeee.js" => now - 8002,
|
42
|
+
"css/common-1eadbeed.css" => now - 8004,
|
43
|
+
"media/images/logo-1eadbeeb.css" => now - 8006,
|
44
|
+
# new files to be kept with Webpacker.commands.clean(age = 3600)
|
45
|
+
"js/brandnew-0001.js" => now,
|
46
|
+
"js/brandnew-0002.js" => now - 10,
|
47
|
+
"js/brandnew-0003.js" => now - 20,
|
48
|
+
"js/brandnew-0004.js" => now - 40,
|
49
|
+
}.transform_keys { |path| "#{Webpacker.config.public_output_path}/#{path}" }
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:expired_files) do
|
53
|
+
{
|
54
|
+
# old files that are outside count = 2 or age = 3600 and to be deleted
|
55
|
+
"js/application-0eadbeef.js" => now - 9000,
|
56
|
+
"js/common-0eadbeee.js" => now - 9002,
|
57
|
+
"css/common-0eadbeed.css" => now - 9004,
|
58
|
+
"js/brandnew-0005.js" => now - 3640,
|
59
|
+
}.transform_keys { |path| "#{Webpacker.config.public_output_path}/#{path}" }
|
60
|
+
end
|
61
|
+
|
62
|
+
let(:all_files) { prev_files.merge(expired_files) }
|
63
|
+
|
64
|
+
let(:file_delete_mock) { double("File Delete") }
|
65
|
+
let(:file_mtime_stub) { Proc.new { |longpath| all_files[longpath] } }
|
66
|
+
let(:file_delete_stub) { Proc.new { |longpath| file_delete_mock.delete(longpath) } }
|
67
|
+
|
68
|
+
before :context do
|
69
|
+
@dir_glob_stub = Proc.new { |arg|
|
70
|
+
case arg
|
71
|
+
when "#{Webpacker.config.public_output_path}/**/*"
|
72
|
+
all_files.keys
|
73
|
+
else
|
74
|
+
[]
|
75
|
+
end
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
it "works with nested hashes and without any compiled files" do
|
80
|
+
allow(File).to receive(:delete).and_return(true)
|
81
|
+
expect(Webpacker.commands.clean).to be true
|
82
|
+
end
|
83
|
+
|
84
|
+
it "deletes only and only expired versioned files if no parameter passed" do
|
85
|
+
all_files.keys.each do |longpath|
|
86
|
+
allow(file_delete_mock).to receive(:delete).with(longpath)
|
87
|
+
end
|
88
|
+
|
89
|
+
with_time_dir_and_files_stub do
|
90
|
+
expect(Webpacker.commands.clean).to be true
|
91
|
+
|
92
|
+
# Verify that only and only expired files are deleted
|
93
|
+
all_files.keys.each do |longpath|
|
94
|
+
if expired_files.has_key? longpath
|
95
|
+
expect(file_delete_mock).to have_received(:delete).with(longpath)
|
96
|
+
else
|
97
|
+
expect(file_delete_mock).to_not have_received(:delete).with(longpath)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def with_time_dir_and_files_stub(&proc)
|
106
|
+
allow(Time).to receive(:now).and_return(now)
|
107
|
+
allow(Dir).to receive(:glob) { |arg| @dir_glob_stub.call(arg) }
|
108
|
+
allow(File).to receive(:directory?).and_return(false)
|
109
|
+
allow(File).to receive(:file?).and_return(true)
|
110
|
+
allow(File).to receive(:mtime) { |arg| file_mtime_stub.call(arg) }
|
111
|
+
allow(File).to receive(:delete) { |arg| file_delete_stub.call(arg) }
|
112
|
+
|
113
|
+
yield proc
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|