Best practice for importing a package like motion as a module in a script module? #72256
silaskoehler
started this conversation in
Interactivity API
Replies: 1 comment
-
|
I'm not sure if a discussion is the right place for this question. If not, please let me know. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What is the best way to use third party packages inside the view.js script modules of a custom block?
I tried to use "motion" as an script module but it doesn't work.
I use the '--experimental-modules' flag and the @wordpress/interactivity works.
This is my block:
the script module is created correctly on the frontend...
...but my module does not appear in the import map.
@wordpress/scripts give me this error:
I tried to understand this article here ...
https://make.wordpress.org/core/2024/03/04/script-modules-in-6-5/
https://make.wordpress.org/core/2024/10/14/updates-to-script-modules-in-6-7/
... but unfortunately I can't get any further.
I also tried to override the DependencyExtractionWebpackPlugin in my webpack.config but that seemed too complicated to me just because I wanted to use a script module.
Is there a simple way to use a package like motion in multiple script modules (interactive blocks) without include it in every view.js file?
I'm super thankful for any help
Beta Was this translation helpful? Give feedback.
All reactions