Skip to content

Add ECMAScript locale modules#6459

Merged
artf merged 1 commit intoGrapesJS:devfrom
padcom:GH-2721
Mar 21, 2025
Merged

Add ECMAScript locale modules#6459
artf merged 1 commit intoGrapesJS:devfrom
padcom:GH-2721

Conversation

@padcom
Copy link
Contributor

@padcom padcom commented Mar 21, 2025

Implements a possible workaround for #2721

What's happening during the build is that first the source locale files are copied over from packages/core/src/locale to packages/core/locale and then pushed through webpack for transpilation and the original files are overridden.

For use cases where an ECMAScript module is required (e.g. when importing files using the <script type="importmap">) it is imperative that the files are not transpiled. For that reason, before the transpilation, the original content is copied over to <filename>.mjs thus making a copy of the file in ECMAScript module format, which those files are originally in.

@padcom
Copy link
Contributor Author

padcom commented Mar 21, 2025

With this change it is now possible to do the following:

  <script type="importmap">
    {
      "imports": {
        "grapesjs": "https://unpkg.com/grapesjs/dist/grapes.mjs",
        "grapesjs/locale/en": "https://unpkg.com/grapesjs/locale/en.mjs",
        "grapesjs/locale/pt": "https://unpkg.com/grapesjs/locale/pt.mjs",
      }
    }
  </script>

Make sure you also load the styles correctly:

  <link rel="stylesheet" href="https://unpkg.com/grapesjs/dist/css/grapes.min.css">

Copy link
Member

@artf artf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome 💜

@artf artf merged commit 1ae4040 into GrapesJS:dev Mar 21, 2025
3 checks passed
@padcom padcom deleted the GH-2721 branch March 21, 2025 13:56
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