etpinard / dash-textarea-autocomplete

Dash component wrapper for `react-textarea-autocomplete`
MIT License
13 stars 1 forks source link

Fix unpkg.com url for `serve_locally=False` apps #23

Closed etpinard closed 2 years ago

etpinard commented 2 years ago

I was about to submit a PR to plotly/dash, when I realised that our problems with the unpkg.com URLs were entirely caused by ... me :facepalm:

Back in https://github.com/etpinard/dash-textarea-autocomplete/commit/75ab848ba4f8f714aa8ed45972aa16682315df5a, I decided to replace _ to - in the package.json name field to follow the convention that other dash component packages are using like e.g. dash-core-components (on npm and pypi). But in turn, this change parted ways with the dash-component-boilerplate template and made the __init__.py template file not function as planned.

I also learned that these unpkg.com URLs are used when the serve_locally dash app option is turned off. So starting with the usage.py and applying this patch

--- a/usage.py
+++ b/usage.py
@@ -7,7 +7,8 @@ WORD_LIST = ['apple', 'application', 'apartment',

 external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

-app = Dash(__name__, external_stylesheets=external_stylesheets)
+app = Dash(__name__, external_stylesheets=external_stylesheets,
+           serve_locally=False)

 app.layout = html.Div([
     dash_textarea_autocomplete.DashTextareaAutocomplete(
@@ -40,4 +41,4 @@ def display_output2(n_clicks, value):

 if __name__ == '__main__':
-    app.run_server(debug=True)
+    app.run_server()

currently gives:

image


Fixing this __init__.py file makes the sed fixup unnecessary as dash-generate-components script uses the __init__.py file to generate the src/DashTextareaAutocomplete.jl content.

cc @Felix-Gauthier

Felix-Gauthier commented 2 years ago

Perfect! One step closer to not needing postbuild.sh at all

etpinard commented 2 years ago

Thanks for the review! I'll merge and release on Monday as v1.3.2