Rails 7 new stimulus module
I am using Rails 7 and now stimulus is imported a little bit differently
instead of:
import { Controller } from 'stimulus';
it should be
import { Controller } from '@hotwired/stimulus';
Using the first one throws
✘ [ERROR] Could not resolve "stimulus"
I'm usin rails 7.0 and this work form me :
-
Install last version
bin/importmap pin stimulus-flatpickr@beta -
Add css
<link rel="stylesheet" href="https://ga.jspm.io/npm:[email protected]/dist/flatpickr.min.css">
I don't know if the style can be added automatically
Two months later and I have the same problem, because "stimulus" was renamed to "@hotwired/stimulus"
See: https://github.com/hotwired/stimulus/releases/tag/v3.0.0-beta.1
Stimulus is moving package location on npm from stimulus to @hotwired/stimulus. The new package is an all-in-one, so no more individual packages for core, multi map, mutation-observers, etc.
ran into same issue, is this project still under maintaining? flatpickr is really a great project.
It seems there is a published beta/3.0.0 version that fixes our problem: https://github.com/adrienpoly/stimulus-flatpickr/pull/89
Following works when using yarn, as long as v3 is not yet published as a normal release.
yarn add stimulus-flatpickr@beta
Could not find a declaration file for module 'stimulus-flatpickr'. error shows in vs code under "import Flatpickr from 'stimulus-flatpickr' "
Can anyone get this to work under Rails 7?
@philsmy this works
Following works when using
yarn, as long as v3 is not yet published as a normal release.yarn add stimulus-flatpickr@beta
If I do that I get the same error as @1CISP above.
Could not find a declaration file for module 'stimulus-flatpickr'. '/Users/philsmy/development/zm/node_modules/stimulus-flatpickr/dist/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/stimulus-flatpickr` if it exists or add a new declaration (.d.ts) file containing `declare module 'stimulus-flatpickr';`ts(7016)
When doing:
import Flatpickr from 'stimulus-flatpickr'
@philsmy check the version in package.json
"stimulus-flatpickr": "^3.0.0-0",
I'm usin rails 7.0 and this work form me :
- Install last version
bin/importmap pin stimulus-flatpickr@beta- Add css
<link rel="stylesheet" href="https://ga.jspm.io/npm:[email protected]/dist/flatpickr.min.css">I don't know if the style can be added automatically
If you are using scss and esbuild you can include the styles in app/assets/stylesheets/application.xxxx.scss
@import "flatpickr/dist/flatpickr";