bugsnag 6.11.1 → 6.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/CONTRIBUTING.md +6 -1
  4. data/Gemfile +18 -11
  5. data/README.md +3 -3
  6. data/UPGRADING.md +22 -0
  7. data/VERSION +1 -1
  8. data/features/fixtures/docker-compose.yml +37 -0
  9. data/features/fixtures/rails3/app/Gemfile +1 -1
  10. data/features/fixtures/rails4/app/Gemfile +1 -1
  11. data/features/fixtures/rails5/app/Gemfile +1 -1
  12. data/features/fixtures/rails6/.dockerignore +1 -0
  13. data/features/fixtures/rails6/Dockerfile +26 -0
  14. data/features/fixtures/rails6/app/.browserslistrc +1 -0
  15. data/features/fixtures/rails6/app/.gitignore +35 -0
  16. data/features/fixtures/rails6/app/.ruby-version +1 -0
  17. data/features/fixtures/rails6/app/Gemfile +57 -0
  18. data/features/fixtures/rails6/app/README.md +24 -0
  19. data/features/fixtures/rails6/app/Rakefile +6 -0
  20. data/features/fixtures/rails6/app/app/assets/config/manifest.js +2 -0
  21. data/features/fixtures/rails6/app/app/assets/images/.keep +0 -0
  22. data/features/fixtures/rails6/app/app/assets/stylesheets/application.css +15 -0
  23. data/features/fixtures/rails6/app/app/channels/application_cable/channel.rb +4 -0
  24. data/features/fixtures/rails6/app/app/channels/application_cable/connection.rb +4 -0
  25. data/features/fixtures/rails6/app/app/controllers/api_key_controller.rb +16 -0
  26. data/features/fixtures/rails6/app/app/controllers/app_type_controller.rb +16 -0
  27. data/features/fixtures/rails6/app/app/controllers/app_version_controller.rb +21 -0
  28. data/features/fixtures/rails6/app/app/controllers/application_controller.rb +7 -0
  29. data/features/fixtures/rails6/app/app/controllers/auto_notify_controller.rb +27 -0
  30. data/features/fixtures/rails6/app/app/controllers/before_notify_controller.rb +40 -0
  31. data/features/fixtures/rails6/app/app/controllers/breadcrumbs_controller.rb +24 -0
  32. data/features/fixtures/rails6/app/app/controllers/clearance_controller.rb +33 -0
  33. data/features/fixtures/rails6/app/app/controllers/concerns/.keep +0 -0
  34. data/features/fixtures/rails6/app/app/controllers/handled_controller.rb +22 -0
  35. data/features/fixtures/rails6/app/app/controllers/ignore_classes_controller.rb +19 -0
  36. data/features/fixtures/rails6/app/app/controllers/metadata_filters_controller.rb +12 -0
  37. data/features/fixtures/rails6/app/app/controllers/project_root_controller.rb +21 -0
  38. data/features/fixtures/rails6/app/app/controllers/release_stage_controller.rb +16 -0
  39. data/features/fixtures/rails6/app/app/controllers/send_code_controller.rb +16 -0
  40. data/features/fixtures/rails6/app/app/controllers/send_environment_controller.rb +8 -0
  41. data/features/fixtures/rails6/app/app/controllers/session_tracking_controller.rb +20 -0
  42. data/features/fixtures/rails6/app/app/controllers/unhandled_controller.rb +7 -0
  43. data/features/fixtures/rails6/app/app/helpers/application_helper.rb +2 -0
  44. data/features/fixtures/rails6/app/app/javascript/channels/consumer.js +6 -0
  45. data/features/fixtures/rails6/app/app/javascript/channels/index.js +5 -0
  46. data/features/fixtures/rails6/app/app/javascript/packs/application.js +9 -0
  47. data/features/fixtures/rails6/app/app/jobs/application_job.rb +7 -0
  48. data/features/fixtures/rails6/app/app/jobs/notify_job.rb +5 -0
  49. data/features/fixtures/rails6/app/app/mailers/application_mailer.rb +4 -0
  50. data/features/fixtures/rails6/app/app/models/application_record.rb +3 -0
  51. data/features/fixtures/rails6/app/app/models/concerns/.keep +0 -0
  52. data/features/fixtures/rails6/app/app/models/user.rb +3 -0
  53. data/features/fixtures/rails6/app/app/views/layouts/application.html.erb +15 -0
  54. data/features/fixtures/rails6/app/app/views/layouts/mailer.html.erb +13 -0
  55. data/features/fixtures/rails6/app/app/views/layouts/mailer.text.erb +1 -0
  56. data/features/fixtures/rails6/app/babel.config.js +70 -0
  57. data/features/fixtures/rails6/app/config.ru +5 -0
  58. data/features/fixtures/rails6/app/config/application.rb +19 -0
  59. data/features/fixtures/rails6/app/config/boot.rb +4 -0
  60. data/features/fixtures/rails6/app/config/cable.yml +13 -0
  61. data/features/fixtures/rails6/app/config/credentials.yml.enc +1 -0
  62. data/features/fixtures/rails6/app/config/database.yml +29 -0
  63. data/features/fixtures/rails6/app/config/environment.rb +5 -0
  64. data/features/fixtures/rails6/app/config/environments/development.rb +62 -0
  65. data/features/fixtures/rails6/app/config/environments/production.rb +112 -0
  66. data/features/fixtures/rails6/app/config/environments/rails_env.rb +55 -0
  67. data/features/fixtures/rails6/app/config/environments/test.rb +47 -0
  68. data/features/fixtures/rails6/app/config/initializers/application_controller_renderer.rb +8 -0
  69. data/features/fixtures/rails6/app/config/initializers/assets.rb +14 -0
  70. data/features/fixtures/rails6/app/config/initializers/backtrace_silencers.rb +7 -0
  71. data/features/fixtures/rails6/app/config/initializers/bugsnag.rb +20 -0
  72. data/features/fixtures/rails6/app/config/initializers/content_security_policy.rb +27 -0
  73. data/features/fixtures/rails6/app/config/initializers/cookies_serializer.rb +5 -0
  74. data/features/fixtures/rails6/app/config/initializers/filter_parameter_logging.rb +5 -0
  75. data/features/fixtures/rails6/app/config/initializers/inflections.rb +16 -0
  76. data/features/fixtures/rails6/app/config/initializers/mime_types.rb +4 -0
  77. data/features/fixtures/rails6/app/config/initializers/wrap_parameters.rb +14 -0
  78. data/features/fixtures/rails6/app/config/locales/en.yml +33 -0
  79. data/features/fixtures/rails6/app/config/puma.rb +35 -0
  80. data/features/fixtures/rails6/app/config/routes.rb +58 -0
  81. data/features/fixtures/rails6/app/config/secrets.yml +25 -0
  82. data/features/fixtures/rails6/app/config/spring.rb +6 -0
  83. data/features/fixtures/rails6/app/config/storage.yml +34 -0
  84. data/features/fixtures/rails6/app/config/webpack/development.js +5 -0
  85. data/features/fixtures/rails6/app/config/webpack/environment.js +3 -0
  86. data/features/fixtures/rails6/app/config/webpack/production.js +5 -0
  87. data/features/fixtures/rails6/app/config/webpack/rails_env.js +5 -0
  88. data/features/fixtures/rails6/app/config/webpack/test.js +5 -0
  89. data/features/fixtures/rails6/app/config/webpacker.yml +121 -0
  90. data/features/fixtures/rails6/app/db/migrate/20180426095545_create_users.rb +17 -0
  91. data/features/fixtures/rails6/app/db/schema.rb +29 -0
  92. data/features/fixtures/rails6/app/db/seeds.rb +7 -0
  93. data/features/fixtures/rails6/app/lib/assets/.keep +0 -0
  94. data/features/fixtures/rails6/app/lib/tasks/.keep +0 -0
  95. data/features/fixtures/rails6/app/log/.keep +0 -0
  96. data/features/fixtures/rails6/app/package.json +15 -0
  97. data/features/fixtures/rails6/app/postcss.config.js +12 -0
  98. data/features/fixtures/rails6/app/public/404.html +67 -0
  99. data/features/fixtures/rails6/app/public/422.html +67 -0
  100. data/features/fixtures/rails6/app/public/500.html +66 -0
  101. data/features/fixtures/rails6/app/public/apple-touch-icon-precomposed.png +0 -0
  102. data/features/fixtures/rails6/app/public/apple-touch-icon.png +0 -0
  103. data/features/fixtures/rails6/app/public/favicon.ico +0 -0
  104. data/features/fixtures/rails6/app/public/robots.txt +1 -0
  105. data/features/fixtures/rails6/app/storage/.keep +0 -0
  106. data/features/fixtures/rails6/app/test/application_system_test_case.rb +5 -0
  107. data/features/fixtures/rails6/app/test/channels/application_cable/connection_test.rb +11 -0
  108. data/features/fixtures/rails6/app/test/controllers/.keep +0 -0
  109. data/features/fixtures/rails6/app/test/fixtures/.keep +0 -0
  110. data/features/fixtures/rails6/app/test/fixtures/files/.keep +0 -0
  111. data/features/fixtures/rails6/app/test/helpers/.keep +0 -0
  112. data/features/fixtures/rails6/app/test/integration/.keep +0 -0
  113. data/features/fixtures/rails6/app/test/mailers/.keep +0 -0
  114. data/features/fixtures/rails6/app/test/models/.keep +0 -0
  115. data/features/fixtures/rails6/app/test/system/.keep +0 -0
  116. data/features/fixtures/rails6/app/test/test_helper.rb +13 -0
  117. data/features/fixtures/rails6/app/tmp/.keep +0 -0
  118. data/features/fixtures/rails6/app/yarn.lock +6082 -0
  119. data/features/rails_features/api_key.feature +3 -1
  120. data/features/rails_features/app_type.feature +3 -1
  121. data/features/rails_features/app_version.feature +4 -1
  122. data/features/rails_features/auto_capture_sessions.feature +5 -1
  123. data/features/rails_features/auto_notify.feature +5 -1
  124. data/features/rails_features/before_notify.feature +3 -0
  125. data/features/rails_features/breadcrumbs.feature +5 -0
  126. data/features/rails_features/handled.feature +3 -0
  127. data/features/rails_features/ignore_classes.feature +3 -1
  128. data/features/rails_features/meta_data_filters.feature +1 -0
  129. data/features/rails_features/project_root.feature +3 -0
  130. data/features/rails_features/release_stage.feature +4 -1
  131. data/features/rails_features/send_code.feature +2 -0
  132. data/features/rails_features/send_environment.feature +2 -1
  133. data/features/rails_features/unhandled.feature +2 -1
  134. data/features/rails_features/user_info.feature +3 -1
  135. data/lib/bugsnag/breadcrumbs/validator.rb +2 -2
  136. data/lib/bugsnag/configuration.rb +4 -0
  137. data/lib/bugsnag/integrations/que.rb +16 -11
  138. data/lib/bugsnag/integrations/rack.rb +4 -1
  139. data/lib/bugsnag/integrations/railtie.rb +1 -0
  140. data/lib/bugsnag/integrations/rake.rb +58 -26
  141. data/lib/bugsnag/integrations/resque.rb +6 -1
  142. data/lib/bugsnag/integrations/sidekiq.rb +1 -0
  143. data/lib/bugsnag/middleware/rails3_request.rb +0 -7
  144. data/lib/bugsnag/report.rb +4 -1
  145. data/lib/bugsnag/session_tracker.rb +2 -1
  146. data/spec/breadcrumbs/validator_spec.rb +1 -0
  147. data/spec/configuration_spec.rb +31 -0
  148. data/spec/fixtures/tasks/Rakefile +12 -0
  149. data/spec/integrations/logger_spec.rb +4 -8
  150. data/spec/integrations/que_spec.rb +35 -1
  151. data/spec/integrations/rack_spec.rb +23 -1
  152. data/spec/integrations/rake_spec.rb +11 -12
  153. data/spec/integrations/resque_spec.rb +8 -1
  154. data/spec/integrations/sidekiq_spec.rb +2 -0
  155. data/spec/report_spec.rb +13 -1
  156. data/spec/session_tracker_spec.rb +1 -0
  157. metadata +110 -3
@@ -0,0 +1,16 @@
1
+ class AppTypeController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def initializer
5
+ Bugsnag.notify("handled string")
6
+ render json: {}
7
+ end
8
+
9
+ def after
10
+ Bugsnag.configure do |conf|
11
+ conf.app_type = params[:type]
12
+ end
13
+ Bugsnag.notify("handled string")
14
+ render json: {}
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ class AppVersionController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def default
5
+ Bugsnag.notify("handled string")
6
+ render json: {}
7
+ end
8
+
9
+ def initializer
10
+ Bugsnag.notify("handled string")
11
+ render json: {}
12
+ end
13
+
14
+ def after
15
+ Bugsnag.configure do |conf|
16
+ conf.app_version = params[:version]
17
+ end
18
+ Bugsnag.notify("handled string")
19
+ render json: {}
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def index
5
+ render json: {}
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ class AutoNotifyController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def unhandled
5
+ generate_unhandled_error
6
+ end
7
+
8
+ def handled
9
+ Bugsnag.notify("handled string")
10
+ render json: {}
11
+ end
12
+
13
+ def unhandled_after
14
+ Bugsnag.configure do |conf|
15
+ conf.auto_notify = false
16
+ end
17
+ generate_unhandled_error
18
+ end
19
+
20
+ def handled_after
21
+ Bugsnag.configure do |conf|
22
+ conf.auto_notify = false
23
+ end
24
+ Bugsnag.notify("handled string")
25
+ render json: {}
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ class BeforeNotifyController < ActionController::Base
2
+ protect_from_forgery
3
+ before_bugsnag_notify :add_diagnostics_to_bugsnag
4
+
5
+ def handled
6
+ Bugsnag.before_notify_callbacks << Proc.new do |report|
7
+ report.add_tab(:before_notify, {
8
+ :source => "rails_before_handled"
9
+ })
10
+ end
11
+ Bugsnag.notify("handled string")
12
+ render json: {}
13
+ end
14
+
15
+ def unhandled
16
+ Bugsnag.before_notify_callbacks << Proc.new do |report|
17
+ report.add_tab(:before_notify, {
18
+ :source => "rails_before_unhandled"
19
+ })
20
+ end
21
+ generate_unhandled_error
22
+ end
23
+
24
+ def inline
25
+ Bugsnag.notify("handled string") do |report|
26
+ report.add_tab(:before_notify, {
27
+ :source => "rails_inline"
28
+ })
29
+ end
30
+ render json: {}
31
+ end
32
+
33
+ private
34
+
35
+ def add_diagnostics_to_bugsnag(report)
36
+ report.add_tab(:controller, {
37
+ :name => "BeforeNotifyController"
38
+ })
39
+ end
40
+ end
@@ -0,0 +1,24 @@
1
+ class BreadcrumbsController < ApplicationController
2
+ def handled
3
+ Bugsnag.notify("Request breadcrumb")
4
+ render json: {}
5
+ end
6
+
7
+ def sql_breadcrumb
8
+ User.find_by(email: "foo")
9
+ Bugsnag.notify("SQL breadcrumb")
10
+ render json: {}
11
+ end
12
+
13
+ def active_job
14
+ NotifyJob.perform_later
15
+ render json: {}
16
+ end
17
+
18
+ def cache_read
19
+ Rails.cache.write('test', true)
20
+ Rails.cache.read('test')
21
+ Bugsnag.notify("Cache breadcrumb")
22
+ render json: {}
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ class ClearanceController < Clearance::BaseController
2
+ protect_from_forgery
3
+ def create
4
+ user = User.find_by(:email => "testtest@test.test")
5
+ User.new({
6
+ :email => "testtest@test.test",
7
+ :name => "Clearance User",
8
+ :first_name => "Clearance",
9
+ :last_name => "User",
10
+ :password => "Password"
11
+ }).save if user.nil?
12
+ render json: {}
13
+ end
14
+
15
+ def unhandled
16
+ user = User.find_by(:email => "testtest@test.test")
17
+ unless user.nil?
18
+ @current_user = user
19
+ cookies['remember_token'] = user.remember_token
20
+ end
21
+ generate_unhandled_error
22
+ end
23
+
24
+ def handled
25
+ user = User.find_by(:email => "testtest@test.test")
26
+ unless user.nil?
27
+ @current_user = user
28
+ cookies['remember_token'] = user.remember_token
29
+ end
30
+ Bugsnag.notify("handled string")
31
+ render json: {}
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ class HandledController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+
4
+ def unthrown
5
+ Bugsnag.notify(RuntimeError.new("handled unthrown error"))
6
+ render json: {}
7
+ end
8
+
9
+ def thrown
10
+ begin
11
+ generate_unhandled_error
12
+ rescue Exception => e
13
+ Bugsnag.notify(e)
14
+ end
15
+ render json: {}
16
+ end
17
+
18
+ def string_notify
19
+ Bugsnag.notify("handled string")
20
+ render json: {}
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ class IgnoredError < RuntimeError
2
+ end
3
+
4
+ class IgnoreClassesController < ActionController::Base
5
+ protect_from_forgery
6
+
7
+ def initializer
8
+ Bugsnag.notify(IgnoredError.new)
9
+ render json: {}
10
+ end
11
+
12
+ def after
13
+ Bugsnag.configure do |conf|
14
+ conf.ignore_classes << Kernel.const_get(params[:ignore])
15
+ end
16
+ Bugsnag.notify(IgnoredError.new)
17
+ render json: {}
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ class MetadataFiltersController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def filter
5
+ Bugsnag.notify("handled string") do |report|
6
+ report.add_tab(:my_specific_filter, {
7
+ :foo => "bar"
8
+ })
9
+ end
10
+ render json: {}
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ class ProjectRootController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def default
5
+ Bugsnag.notify("handled string")
6
+ render json: {}
7
+ end
8
+
9
+ def initializer
10
+ Bugsnag.notify("handled string")
11
+ render json: {}
12
+ end
13
+
14
+ def after
15
+ Bugsnag.configure do |conf|
16
+ conf.project_root = '/test/root/here'
17
+ end
18
+ Bugsnag.notify("handled string")
19
+ render json: {}
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ class ReleaseStageController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def default
5
+ Bugsnag.notify("handled string")
6
+ render json: {}
7
+ end
8
+
9
+ def after
10
+ Bugsnag.configure do |conf|
11
+ conf.release_stage = params[:stage]
12
+ end
13
+ Bugsnag.notify("handled string")
14
+ render json: {}
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class SendCodeController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def initializer
5
+ Bugsnag.notify("handled string")
6
+ render json: {}
7
+ end
8
+
9
+ def after
10
+ Bugsnag.configure do |conf|
11
+ conf.send_code = false
12
+ end
13
+ Bugsnag.notify("handled string")
14
+ render json: {}
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ class SendEnvironmentController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def initializer
5
+ Bugsnag.notify("handled string")
6
+ render json: {}
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ class SessionTrackingController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def initializer
5
+ Bugsnag.session_tracker.send_sessions()
6
+ render json: {}
7
+ end
8
+
9
+ def manual
10
+ Bugsnag.start_session
11
+ Bugsnag.session_tracker.send_sessions
12
+ render json: {}
13
+ end
14
+
15
+ def multi_sessions
16
+ (0...100).each { Bugsnag.start_session }
17
+ Bugsnag.session_tracker.send_sessions
18
+ render json: {}
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ class UnhandledController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+
4
+ def error
5
+ generate_unhandled_error
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,6 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+
4
+ import { createConsumer } from "@rails/actioncable"
5
+
6
+ export default createConsumer()
@@ -0,0 +1,5 @@
1
+ // Load all the channels within this directory and all subdirectories.
2
+ // Channel files must be named *_channel.js.
3
+
4
+ const channels = require.context('.', true, /_channel\.js$/)
5
+ channels.keys().forEach(channels)
@@ -0,0 +1,9 @@
1
+ // This file is automatically compiled by Webpack, along with any other files
2
+ // present in this directory. You're encouraged to place your actual application logic in
3
+ // a relevant structure within app/javascript and only use these pack files to reference
4
+ // that code so it'll be compiled.
5
+
6
+ require("@rails/ujs").start()
7
+ require("turbolinks").start()
8
+ require("@rails/activestorage").start()
9
+ require("channels")
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,5 @@
1
+ class NotifyJob < ApplicationJob
2
+ def perform
3
+ Bugsnag.notify("Failed")
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,3 @@
1
+ class User < ApplicationRecord
2
+ include Clearance::User
3
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>App</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,70 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ require('@babel/preset-env').default,
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ }
26
+ }
27
+ ],
28
+ (isProductionEnv || isDevelopmentEnv) && [
29
+ require('@babel/preset-env').default,
30
+ {
31
+ forceAllTransforms: true,
32
+ useBuiltIns: 'entry',
33
+ modules: false,
34
+ exclude: ['transform-typeof-symbol']
35
+ }
36
+ ]
37
+ ].filter(Boolean),
38
+ plugins: [
39
+ require('babel-plugin-macros'),
40
+ require('@babel/plugin-syntax-dynamic-import').default,
41
+ isTestEnv && require('babel-plugin-dynamic-import-node'),
42
+ require('@babel/plugin-transform-destructuring').default,
43
+ [
44
+ require('@babel/plugin-proposal-class-properties').default,
45
+ {
46
+ loose: true
47
+ }
48
+ ],
49
+ [
50
+ require('@babel/plugin-proposal-object-rest-spread').default,
51
+ {
52
+ useBuiltIns: true
53
+ }
54
+ ],
55
+ [
56
+ require('@babel/plugin-transform-runtime').default,
57
+ {
58
+ helpers: false,
59
+ regenerator: true
60
+ }
61
+ ],
62
+ [
63
+ require('@babel/plugin-transform-regenerator').default,
64
+ {
65
+ async: false
66
+ }
67
+ ]
68
+ ].filter(Boolean)
69
+ }
70
+ }