Skip to content
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

Various fixes for custom component compilation #7381

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
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
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
Loading