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

fix: enable module loading for custom extensions #531

Closed
wants to merge 1 commit into from

Conversation

CodeWithKyrian
Copy link

Currently, the package loads custom extension scripts as regular JavaScript files, which prevents the use of ES module syntax (import statements). This means even the example snippet in the docs will not work, nor will using extensions from packages like @tiptap-pro, be very straighforward to use

import Hero from "./hero.js";
window.TiptapEditorExtensions = {
    hero: [Hero]
}

This code fails with Uncaught SyntaxError: Cannot use import statement outside a module.

This PR modifies the asset registration to load custom extension scripts as modules by using Filament's module() method, allowing one to use ES module syntax in their extension scripts

@awcodes
Copy link
Owner

awcodes commented Dec 28, 2024

Custom extensions should go through a build process. Using modules in this context is not going to work in production without having all the imports publicly accessible, which doesn't make sense to me, especially when trying to use tiptap pro extensions that would live in node_modules and not be accessible via a url route.

@awcodes awcodes closed this Dec 28, 2024
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