Skip to content

Instantly share code, notes, and snippets.

@adrienpoly
Created September 24, 2021 09:32
Show Gist options
  • Save adrienpoly/6b4f2531e043fd45f9ddea305767c13a to your computer and use it in GitHub Desktop.
Save adrienpoly/6b4f2531e043fd45f9ddea305767c13a to your computer and use it in GitHub Desktop.
Upgrade to Stimulus 3 recommandations

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']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment