Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion react/utils/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from pipeline.compilers import CompilerBase
from pipeline.exceptions import CompilerError
from pipeline.conf import settings
from react.jsx import JSXTransformer, TransformError

class JSXCompiler(CompilerBase):
Expand All @@ -31,7 +32,25 @@ def match_file(self, path):
def compile_file(self, infile, outfile, outdated=False, force=False):
if not outdated and not force:
return

# pipeline < 1.6 will raise `AttributeError`
# pipeline >= 1.6 will raise `KeyError`
try:
harmony = settings.REACT_HARMONY
except (KeyError, AttributeError):
harmony = False

try:
strip_types = settings.REACT_STRIP_TYPES
except (KeyError, AttributeError):
strip_types = False

try:
return self.transformer.transform(infile, outfile)
return self.transformer.transform(
infile,
outfile,
harmony=harmony,
strip_types=strip_types,
)
except TransformError as e:
raise CompilerError(str(e))