bugsnag 6.11.1 → 6.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/CONTRIBUTING.md +6 -1
- data/Gemfile +18 -11
- data/README.md +3 -3
- data/UPGRADING.md +22 -0
- data/VERSION +1 -1
- data/features/fixtures/docker-compose.yml +37 -0
- data/features/fixtures/rails3/app/Gemfile +1 -1
- data/features/fixtures/rails4/app/Gemfile +1 -1
- data/features/fixtures/rails5/app/Gemfile +1 -1
- data/features/fixtures/rails6/.dockerignore +1 -0
- data/features/fixtures/rails6/Dockerfile +26 -0
- data/features/fixtures/rails6/app/.browserslistrc +1 -0
- data/features/fixtures/rails6/app/.gitignore +35 -0
- data/features/fixtures/rails6/app/.ruby-version +1 -0
- data/features/fixtures/rails6/app/Gemfile +57 -0
- data/features/fixtures/rails6/app/README.md +24 -0
- data/features/fixtures/rails6/app/Rakefile +6 -0
- data/features/fixtures/rails6/app/app/assets/config/manifest.js +2 -0
- data/features/fixtures/rails6/app/app/assets/images/.keep +0 -0
- data/features/fixtures/rails6/app/app/assets/stylesheets/application.css +15 -0
- data/features/fixtures/rails6/app/app/channels/application_cable/channel.rb +4 -0
- data/features/fixtures/rails6/app/app/channels/application_cable/connection.rb +4 -0
- data/features/fixtures/rails6/app/app/controllers/api_key_controller.rb +16 -0
- data/features/fixtures/rails6/app/app/controllers/app_type_controller.rb +16 -0
- data/features/fixtures/rails6/app/app/controllers/app_version_controller.rb +21 -0
- data/features/fixtures/rails6/app/app/controllers/application_controller.rb +7 -0
- data/features/fixtures/rails6/app/app/controllers/auto_notify_controller.rb +27 -0
- data/features/fixtures/rails6/app/app/controllers/before_notify_controller.rb +40 -0
- data/features/fixtures/rails6/app/app/controllers/breadcrumbs_controller.rb +24 -0
- data/features/fixtures/rails6/app/app/controllers/clearance_controller.rb +33 -0
- data/features/fixtures/rails6/app/app/controllers/concerns/.keep +0 -0
- data/features/fixtures/rails6/app/app/controllers/handled_controller.rb +22 -0
- data/features/fixtures/rails6/app/app/controllers/ignore_classes_controller.rb +19 -0
- data/features/fixtures/rails6/app/app/controllers/metadata_filters_controller.rb +12 -0
- data/features/fixtures/rails6/app/app/controllers/project_root_controller.rb +21 -0
- data/features/fixtures/rails6/app/app/controllers/release_stage_controller.rb +16 -0
- data/features/fixtures/rails6/app/app/controllers/send_code_controller.rb +16 -0
- data/features/fixtures/rails6/app/app/controllers/send_environment_controller.rb +8 -0
- data/features/fixtures/rails6/app/app/controllers/session_tracking_controller.rb +20 -0
- data/features/fixtures/rails6/app/app/controllers/unhandled_controller.rb +7 -0
- data/features/fixtures/rails6/app/app/helpers/application_helper.rb +2 -0
- data/features/fixtures/rails6/app/app/javascript/channels/consumer.js +6 -0
- data/features/fixtures/rails6/app/app/javascript/channels/index.js +5 -0
- data/features/fixtures/rails6/app/app/javascript/packs/application.js +9 -0
- data/features/fixtures/rails6/app/app/jobs/application_job.rb +7 -0
- data/features/fixtures/rails6/app/app/jobs/notify_job.rb +5 -0
- data/features/fixtures/rails6/app/app/mailers/application_mailer.rb +4 -0
- data/features/fixtures/rails6/app/app/models/application_record.rb +3 -0
- data/features/fixtures/rails6/app/app/models/concerns/.keep +0 -0
- data/features/fixtures/rails6/app/app/models/user.rb +3 -0
- data/features/fixtures/rails6/app/app/views/layouts/application.html.erb +15 -0
- data/features/fixtures/rails6/app/app/views/layouts/mailer.html.erb +13 -0
- data/features/fixtures/rails6/app/app/views/layouts/mailer.text.erb +1 -0
- data/features/fixtures/rails6/app/babel.config.js +70 -0
- data/features/fixtures/rails6/app/config.ru +5 -0
- data/features/fixtures/rails6/app/config/application.rb +19 -0
- data/features/fixtures/rails6/app/config/boot.rb +4 -0
- data/features/fixtures/rails6/app/config/cable.yml +13 -0
- data/features/fixtures/rails6/app/config/credentials.yml.enc +1 -0
- data/features/fixtures/rails6/app/config/database.yml +29 -0
- data/features/fixtures/rails6/app/config/environment.rb +5 -0
- data/features/fixtures/rails6/app/config/environments/development.rb +62 -0
- data/features/fixtures/rails6/app/config/environments/production.rb +112 -0
- data/features/fixtures/rails6/app/config/environments/rails_env.rb +55 -0
- data/features/fixtures/rails6/app/config/environments/test.rb +47 -0
- data/features/fixtures/rails6/app/config/initializers/application_controller_renderer.rb +8 -0
- data/features/fixtures/rails6/app/config/initializers/assets.rb +14 -0
- data/features/fixtures/rails6/app/config/initializers/backtrace_silencers.rb +7 -0
- data/features/fixtures/rails6/app/config/initializers/bugsnag.rb +20 -0
- data/features/fixtures/rails6/app/config/initializers/content_security_policy.rb +27 -0
- data/features/fixtures/rails6/app/config/initializers/cookies_serializer.rb +5 -0
- data/features/fixtures/rails6/app/config/initializers/filter_parameter_logging.rb +5 -0
- data/features/fixtures/rails6/app/config/initializers/inflections.rb +16 -0
- data/features/fixtures/rails6/app/config/initializers/mime_types.rb +4 -0
- data/features/fixtures/rails6/app/config/initializers/wrap_parameters.rb +14 -0
- data/features/fixtures/rails6/app/config/locales/en.yml +33 -0
- data/features/fixtures/rails6/app/config/puma.rb +35 -0
- data/features/fixtures/rails6/app/config/routes.rb +58 -0
- data/features/fixtures/rails6/app/config/secrets.yml +25 -0
- data/features/fixtures/rails6/app/config/spring.rb +6 -0
- data/features/fixtures/rails6/app/config/storage.yml +34 -0
- data/features/fixtures/rails6/app/config/webpack/development.js +5 -0
- data/features/fixtures/rails6/app/config/webpack/environment.js +3 -0
- data/features/fixtures/rails6/app/config/webpack/production.js +5 -0
- data/features/fixtures/rails6/app/config/webpack/rails_env.js +5 -0
- data/features/fixtures/rails6/app/config/webpack/test.js +5 -0
- data/features/fixtures/rails6/app/config/webpacker.yml +121 -0
- data/features/fixtures/rails6/app/db/migrate/20180426095545_create_users.rb +17 -0
- data/features/fixtures/rails6/app/db/schema.rb +29 -0
- data/features/fixtures/rails6/app/db/seeds.rb +7 -0
- data/features/fixtures/rails6/app/lib/assets/.keep +0 -0
- data/features/fixtures/rails6/app/lib/tasks/.keep +0 -0
- data/features/fixtures/rails6/app/log/.keep +0 -0
- data/features/fixtures/rails6/app/package.json +15 -0
- data/features/fixtures/rails6/app/postcss.config.js +12 -0
- data/features/fixtures/rails6/app/public/404.html +67 -0
- data/features/fixtures/rails6/app/public/422.html +67 -0
- data/features/fixtures/rails6/app/public/500.html +66 -0
- data/features/fixtures/rails6/app/public/apple-touch-icon-precomposed.png +0 -0
- data/features/fixtures/rails6/app/public/apple-touch-icon.png +0 -0
- data/features/fixtures/rails6/app/public/favicon.ico +0 -0
- data/features/fixtures/rails6/app/public/robots.txt +1 -0
- data/features/fixtures/rails6/app/storage/.keep +0 -0
- data/features/fixtures/rails6/app/test/application_system_test_case.rb +5 -0
- data/features/fixtures/rails6/app/test/channels/application_cable/connection_test.rb +11 -0
- data/features/fixtures/rails6/app/test/controllers/.keep +0 -0
- data/features/fixtures/rails6/app/test/fixtures/.keep +0 -0
- data/features/fixtures/rails6/app/test/fixtures/files/.keep +0 -0
- data/features/fixtures/rails6/app/test/helpers/.keep +0 -0
- data/features/fixtures/rails6/app/test/integration/.keep +0 -0
- data/features/fixtures/rails6/app/test/mailers/.keep +0 -0
- data/features/fixtures/rails6/app/test/models/.keep +0 -0
- data/features/fixtures/rails6/app/test/system/.keep +0 -0
- data/features/fixtures/rails6/app/test/test_helper.rb +13 -0
- data/features/fixtures/rails6/app/tmp/.keep +0 -0
- data/features/fixtures/rails6/app/yarn.lock +6082 -0
- data/features/rails_features/api_key.feature +3 -1
- data/features/rails_features/app_type.feature +3 -1
- data/features/rails_features/app_version.feature +4 -1
- data/features/rails_features/auto_capture_sessions.feature +5 -1
- data/features/rails_features/auto_notify.feature +5 -1
- data/features/rails_features/before_notify.feature +3 -0
- data/features/rails_features/breadcrumbs.feature +5 -0
- data/features/rails_features/handled.feature +3 -0
- data/features/rails_features/ignore_classes.feature +3 -1
- data/features/rails_features/meta_data_filters.feature +1 -0
- data/features/rails_features/project_root.feature +3 -0
- data/features/rails_features/release_stage.feature +4 -1
- data/features/rails_features/send_code.feature +2 -0
- data/features/rails_features/send_environment.feature +2 -1
- data/features/rails_features/unhandled.feature +2 -1
- data/features/rails_features/user_info.feature +3 -1
- data/lib/bugsnag/breadcrumbs/validator.rb +2 -2
- data/lib/bugsnag/configuration.rb +4 -0
- data/lib/bugsnag/integrations/que.rb +16 -11
- data/lib/bugsnag/integrations/rack.rb +4 -1
- data/lib/bugsnag/integrations/railtie.rb +1 -0
- data/lib/bugsnag/integrations/rake.rb +58 -26
- data/lib/bugsnag/integrations/resque.rb +6 -1
- data/lib/bugsnag/integrations/sidekiq.rb +1 -0
- data/lib/bugsnag/middleware/rails3_request.rb +0 -7
- data/lib/bugsnag/report.rb +4 -1
- data/lib/bugsnag/session_tracker.rb +2 -1
- data/spec/breadcrumbs/validator_spec.rb +1 -0
- data/spec/configuration_spec.rb +31 -0
- data/spec/fixtures/tasks/Rakefile +12 -0
- data/spec/integrations/logger_spec.rb +4 -8
- data/spec/integrations/que_spec.rb +35 -1
- data/spec/integrations/rack_spec.rb +23 -1
- data/spec/integrations/rake_spec.rb +11 -12
- data/spec/integrations/resque_spec.rb +8 -1
- data/spec/integrations/sidekiq_spec.rb +2 -0
- data/spec/report_spec.rb +13 -1
- data/spec/session_tracker_spec.rb +1 -0
- 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,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
|
File without changes
|
@@ -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,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,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,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,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
|
File without changes
|
@@ -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 @@
|
|
1
|
+
<%= yield %>
|
@@ -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
|
+
}
|