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

Problems using UMD version #99

Closed
kokujin opened this Issue Feb 10, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@kokujin

kokujin commented Feb 10, 2018

Hi there!
I tried to get something up quickly to test Stimulus, so I decided to use the UMD version without a build system. Can someone point me to a full working example?

This is what I tried, it emitted an error, "Uncaught SyntaxError: Unexpected token = ". I am using Chrome version 63, so ES6 syntax should not be an issue.

Thanks

 <script src="/node_modules/stimulus/dist/stimulus.umd.js"></script>

    <script>
        (function() {
            const application = Stimulus.Application.start();

            class Hello extends Stimulus.Controller {
                static targets = ["name"] // <-- This seems to be problematic
                greet() {
                    console.log(`Hello, ${this.name}!`)
                }

                get name() {
                    return this.nameTarget.value
                }
            }

            application.register("hello", Hello)

        })()
    </script>
@javan

This comment has been minimized.

Contributor

javan commented Feb 10, 2018

The Stimulus Discourse community forum is a good place for questions like this. See https://discourse.stimulusjs.org/t/syntax-error-when-using-targets/23/5.

@javan javan closed this Feb 10, 2018

@bdavidxyz

This comment has been minimized.

bdavidxyz commented Feb 11, 2018

Yes, it is a bug since the StimulusJS docs suggest to use the umd, and the example "as is", which does not work. Docs should be updated with a possible solution to the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment