Skip to content

Commit

Permalink
Various fixes for custom component compilation (#7381)
Browse files Browse the repository at this point in the history
* Various fixes for custom component compilation

* Apply suggestions from code review

---------

Co-authored-by: Philipp Rudiger <philipp.rudiger@blackstone.com>
  • Loading branch information
2 people authored and ahuang11 committed Oct 18, 2024
1 parent ae110a5 commit 2454da9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions panel/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,11 @@ def _init_params(self) -> dict[str, Any]:
params.pop(k)
data_params[k] = v
bundle_path = self._bundle_path
importmap = self._process_importmap()
if bundle_path:
bundle_hash = hashlib.sha256(str(bundle_path).encode('utf-8')).hexdigest()
importmap = {}
else:
bundle_hash = None
importmap = self._process_importmap()
data_props = self._process_param_change(data_params)
params.update({
'bundle': bundle_hash,
Expand Down Expand Up @@ -614,8 +613,8 @@ def _exports__(cls) -> ExportSpec:
}
if any('@mui' in v for v in imports.values()):
exports.update({
"@emotion/cache": "createCache",
"@emotion/react": ("CacheProvider",)
"@emotion/cache": ["createCache"],
"@emotion/react": [("CacheProvider",)],
})
return exports

Expand Down
4 changes: 2 additions & 2 deletions panel/io/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ def compile_components(
if result.stdout and out:
print(f"npm output:\n{GREEN}{result.stdout}{RESET}") # noqa
if result.stderr:
print("npm errors:\n{RED}{result.stderr}{RESET}") # noqa
return None
print(f"npm errors:\n{RED}{result.stderr}{RESET}") # noqa

except subprocess.CalledProcessError as e:
print(f"An error occurred while running npm install:\n{RED}{e.stderr}{RESET}") # noqa
return None
Expand Down
2 changes: 1 addition & 1 deletion panel/models/react_component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { CacheProvider } from "@emotion/react"`
render_code = `
if (rendered) {
const cache = createCache({
key: 'css-${this.model.id}',
key: 'css-${btoa(this.model.id).replace("=", "-").toLowerCase()}',
prepend: true,
container: view.style_cache,
})
Expand Down

0 comments on commit 2454da9

Please sign in to comment.