Skip to content

Commit

Permalink
Ensure ESM compilation correctly detects file extension (#7446)
Browse files Browse the repository at this point in the history
* Ensure ESM compilation correctly detects file extension

* Treat .js files as .jsx when using ReactComponent
  • Loading branch information
philippjfr authored Oct 27, 2024
1 parent 26c2e7a commit d4e02f4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion panel/io/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def generate_project(
name = component.__name__
esm_path = component._esm_path(compiled=False)
if esm_path:
ext = esm_path.suffix
ext = esm_path.suffix.lstrip('.')
else:
ext = 'jsx' if issubclass(component, ReactComponent) else 'js'
code, component_deps = extract_dependencies(component)
Expand Down Expand Up @@ -391,6 +391,8 @@ def compile_components(
print(f"An error occurred while running npm install:\n{RED}{e.stderr}{RESET}") # noqa
return None

if any(issubclass(c, ReactComponent) for c in components):
extra_args.append('--loader:.js=jsx')
if minify:
extra_args.append('--minify')
if out:
Expand Down

0 comments on commit d4e02f4

Please sign in to comment.