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

Use leaflet and react-leaflet as external packages #146

Closed
wants to merge 1 commit into from
Closed

Use leaflet and react-leaflet as external packages #146

wants to merge 1 commit into from

Conversation

pikhovkin
Copy link
Contributor

@pikhovkin pikhovkin commented Jun 25, 2022

I propose to make the leaflet and the react-leaflet external. This would allow development of plugins for the dash-leaflet. This would allow you to take your existing plugins outside and develop them as separate python packages.
Developing, maintaining, and updating new plugins will be faster with the help of the community.
I want to make a plugin for the dash-leaflet based on the leaflet-geoman.

@emilhe
Copy link
Owner

emilhe commented Jun 25, 2022

That sounds interesting. The diff is rather huge at the point, could you comment on what you changed?

@pikhovkin
Copy link
Contributor Author

The main files and main changes are

  • webpack.config.js
    const externals = ('externals' in overrides) ? overrides.externals : ({
        react: 'React',
        'react-dom': 'ReactDOM',
        'plotly.js': 'Plotly',
        'prop-types': 'PropTypes',
        'leaflet': 'L',  // <<
        'react-leaflet': 'ReactLeaflet',  // <<
    });
  • dash_leaflet dir - I added leaflet@1.7.1.css, leaflet@1.7.1.js, react-leaflet@2.8.0.js
  • dash_leaflet/__init__.py - I plugged in the scripts and styles above

The other files changed on their own during compilation. You might as well not merge them.

@pikhovkin
Copy link
Contributor Author

pikhovkin commented Jun 25, 2022

I made dash-leaflet-measure external plugin based on your internal plugin for an example. Here is an example of how to use

@pikhovkin
Copy link
Contributor Author

@emilhe
Copy link
Owner

emilhe commented Jun 28, 2022

I am not sure that I can merge only part of the PR (do you have a link on docs on how to do so?). Otherwise, would it be possible for you to just include the files with relevant changes?¨

In your example, you explicitly specify,

app.scripts.config.serve_locally = True
app.css.config.serve_locally = True

Is that necessary for the custom component to work?

@pikhovkin
Copy link
Contributor Author

Otherwise, would it be possible for you to just include the files with relevant changes?

I'l try to change the pull request

Is that necessary for the custom component to work?

Yes, this component (its scripts) is not registered with unpkg, so its scripts are only available locally.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants