To upgrade to Stimulus 3.0 and minimize the side effects of the npm package name change here is my suggestion
# add the proxy package
yarn add stimulus
# add the new @hotwired/stimulus package
yarn add @hotwired/stimulus
# add the dedicated package for the Webpack helpers
yarn add @hotwired/stimulus-webpack-helpers
Update your webpack imports
-import { Application } from 'stimulus'
-import { definitionsFromContext } from 'stimulus/webpack-helpers'
+import { Application } from '@hotwired/stimulus'
+import { definitionsFromContext } from '@hotwired/stimulus-webpack-helpers'
and in your controllers find and replace
-import { Controller } from 'stimulus'
+import { Controller } from '@hotwired/stimulus'
If you are using Webpacker 6, remove the loose: true option from Babel until rails/webpacker#3153 is resolved.
{
useBuiltIns: 'entry',
corejs: '3.8',
modules: 'auto',
bugfixes: true,
- loose: true,
exclude: ['transform-typeof-symbol']
}