-
Notifications
You must be signed in to change notification settings - Fork 754
New Babel Transformer #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
3b6d6bd
9c19706
82f7b19
8eb1dd6
9f97a06
caa8df4
5d0a087
8ab2873
3ba4366
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'babel/transpiler' | ||
module React | ||
module JSX | ||
class BabelTransformer | ||
DEPRECATED_OPTIONS = [:harmony, :strip_types, :asset_path] | ||
|
||
def initialize(options) | ||
_options = options.dup | ||
has_old_opts = DEPRECATED_OPTIONS.map do |option| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any downside to passing the deprecated keys to Babel? Are they ignored or do they raise errors? If they're just ignored, this could be simplified a bit: if (options.keys & DEPRECATED_OPTIONS).any?
# deprecation warning ...
end |
||
_options.delete option | ||
end.any? | ||
|
||
if has_old_opts | ||
ActiveSupport::Deprecation.warn("Setting config.react.jsx_transform_options for :harmony, :strip_types, and :asset_path keys is now deprecated and has no effect with the default Babel Transformer."+ | ||
"Please use new Babel Transformer options :whitelist, :plugin instead.") | ||
end | ||
|
||
@transform_options = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about moving the defaults to Then just @transform_options = DEFAULT_OPTIONS.merge(options) |
||
blacklist: ['spec.functionName', 'validation.react'] | ||
}.merge(_options) | ||
end | ||
|
||
def transform(code) | ||
puts @transform_options | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, probably don't need this anymore :) |
||
Babel::Transpiler.transform(code)['code'] | ||
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we merge this with the "## Coffeescript" section below?