Skip to content

Conversation

@lxxxvi
Copy link
Contributor

@lxxxvi lxxxvi commented Oct 12, 2021

Hello 👋

Summary

(Addresses #1089)

Stimulus changed the location of their module from stimulus to @hotwired/stimulus.
Depending on that, the import in the stimulus controller template should change.

For stimulus it should be

import { Controller } from "stimulus"

For @hotwired/stimulus it should be

import { Controller } from "@hotwired/stimulus"

This PR adds this logic and tests.

Other Information

My strategy here was to make @hotwired/stimulus the default, unless stimulus appears in the "dependencies" list in package.json. I am not sure if this is best solution or if it should be the other way round?

A different approach would be to introduce a new flag to the generator, let's say --hotwired-stimulus, and modify the template based on that.

Any feedback is welcome, thank you!

@lxxxvi lxxxvi requested a review from a team as a code owner October 12, 2021 09:46
Copy link
Member

@joelhawksley joelhawksley left a comment

Choose a reason for hiding this comment

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

Excellent! Mind adding a CHANGELOG entry?

Stimulus changed the location of their module from `stimulus` to `@hotwired/stimulus`.
Depending on that, the import in the controller template should change.

For `stimulus` it should be

```js
import { Controller } from "stimulus"
```

For `@hotwired/stimulus` it should be

```js
import { Controller } from "@hotwired/stimulus"
```
@lxxxvi lxxxvi force-pushed the identify-stimulus-module-for-controller-template branch from 43392bb to 0ede388 Compare October 22, 2021 05:27
@lxxxvi
Copy link
Contributor Author

lxxxvi commented Oct 22, 2021

@joelhawksley Thanks for the review! The CHANGELOG entry has been added, feel free to rephrase.

@joelhawksley joelhawksley merged commit a66bd60 into ViewComponent:main Oct 22, 2021
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.

3 participants