Skip to content

Getting An Error When Compiling Scripts using wp-scripts #64446

@LaTableRouge

Description

@LaTableRouge

Hello,

I'm currently writing a plugin with multiple react blocks inside.

Environment info

  • Wordpress Version 6.6.1
  • @wordpress/scripts 28.5.0
  • package.json

Description

Here's how it's organized :
image

For all thoses blocks I use the command: wp-scripts build --webpack-src-dir=blocks/src --output-path=blocks/build

The blocks are registered like so: https://github.com/LaTableRouge/Mappps/blob/experimental/blockcohabitation/includes/blocks/blocks-register.php

Some blocks are using the same leaflet package (this one)

When there was only one block using this package, everything went fine. But as soon as there was two of them using it, I went through an error. If I compile only one block that use this package it works (doesn't matter which one).
Here's the error:

TypeError: L.MarkerClusterGroup is not a constructor
    markerClusterGroup leaflet.markercluster-src.js:1409
    node_modules index.js:11
    useImmutableLeafletElement element.js:13
    usePath path.js:22
    ContainerComponent component.js:6
    hu react-dom.min.js:2
    wo react-dom.min.js:2
    xi react-dom.min.js:2
    bs react-dom.min.js:2
    vs react-dom.min.js:2
    gs react-dom.min.js:2
    as react-dom.min.js:2
    is react-dom.min.js:2
    Hl react-dom.min.js:2
    ws react-dom.min.js:2
    ws react-dom.min.js:2
    ls react-dom.min.js:2
    S react-dom.min.js:2
    T react-dom.min.js:2
    463 react-dom.min.js:2
    t react-dom.min.js:2
    982 react-dom.min.js:2
    t react-dom.min.js:2
    551 react-dom.min.js:2
    t react-dom.min.js:2
    961 react-dom.min.js:2
    t react-dom.min.js:2
    <anonymous> react-dom.min.js:2
    <anonymous> react-dom.min.js:2
react-dom.min.js:2:71400

I don't know if it's a problem from the package in itself, but it seems unlikely. My hypothesis is that is from a lack of scoping from the wp-scripts

I found theses issues that seems to have the same problem, but without success for my problem:

I'm a bit stuck and I didn't found where to put this issue haha.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions