Best practice for importing a package like motion as a module in a script module? #72256
Replies: 2 comments 1 reply
-
|
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.
-
|
Indeed, the previous method would be to override the @youknowriad is currently working on a v2 of @silaskoehler, if you're still interested in making this work, please let us know and we'll try to put together a set of instructions here to make it work with |
Beta Was this translation helpful? Give feedback.
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