Commit Graph

20 Commits

Author SHA1 Message Date
Hartley McGuire f761780899
Fix rails-ujs auto start() in bundled environments
An issue was recently raised that users were seeing an error when
upgrading `@rails/ujs` to 7.1.0+:

```
Uncaught Error: rails-ujs has already been loaded!
```

Generally this issue appears due to the difference in how rails-ujs is
expected to behave in a pure sprockets environment (js appending) vs a
bundled environment (webpack, esbuild, etc.). The sprockets environment
is supposed to call start() automatically, while the bundled environment
is supposed to require users to import and call start() themselves.

As part of the transition from coffeescript to javascript, a condition
was added that was intended to detect whether the current environment
was a bundler so that it would only call start() when in sprockets.
However, this condition is not working as expected, and I was able to
reproduce the error appearing when using rails-ujs with importmaps and
esbuild. Interestingly, the issue did not appear when using Webpack as a
bundler.

I believe the best fix here is to make the condition very explicit.
Since sprockets users should not be using the esm version of rails-ujs,
we can use the rollup replace plugin to explicitly opt the esm bundle
out of _ever_ calling start() automatically. This works because terser
will run after the replace plugin and remove the whole condition as dead
code (since it sees true == false).

Co-authored-by: Ryunosuke Sato <tricknotes.rs@gmail.com>
2023-10-17 20:47:12 -04:00
Hartley McGuire 2146aade71
Remove webpack as runtime dep of Action Text
This appears to have been erroneously [added][1] when the Trix
dependency was updated.

[1]: 48b8285f4d
2023-10-05 07:50:57 -04:00
Rafael Mendonça França fb6c6007d0
Development of Rails 7.2 starts now
🎉
2023-09-27 03:59:11 +00:00
Rafael Mendonça França e5386cb402
Preparing for 7.1.0.rc1 release 2023-09-27 03:08:31 +00:00
Rafael Mendonça França 699dfdb426
Preparing for 7.1.0.beta1 release 2023-09-13 00:36:01 +00:00
Rafael Mendonça França 27b12e9249
Update yarn.lock
It seems those lines are not needed.
2023-08-05 02:58:39 +00:00
Sarah Ridge 48b8285f4d
Update Action Text's Trix dependency (2.0.4) 2023-03-28 12:23:01 -04:00
Sean Doyle fab1b522cd Update Action Text's Trix dependency
There is a new [Trix.js][] release, bumping the version from `1.3.1` to
`2.0.4`.

Applications that consume Action Text through the `@rails/actiontext`
npm package can manage their own Trix dependency version.

Similarly, Importmaps users can `pin "trix", to: "..."` to a CDN serving
`2.0.4`.

For the sake of applications that depend on Trix through the
`action_text` gem, this commit updates the pre-bundled JS and CSS code.

These changes were generated by executing the following:

```sh
cd actiontext
yarn build
cp ../node_modules/trix/dist/trix.css app/assets/stylesheets/trix.css
cp ../node_modules/trix/dist/trix.esm.js app/assets/javascripts/trix.js
```

[Trix.js]: https://trix-editor.org
[v2.0.4]: https://github.com/basecamp/trix/releases/tag/v2.0.4
2023-01-23 10:39:51 -05:00
Lachlan Sylvester d9e79ce7f4 use Karma as the test runner for the UJS tests 2022-12-31 23:03:09 +11:00
Hartley McGuire 7d116c93cf
Convert rails-ujs to ES2015 modules
Building and linting are setup similar to other packages

Most of the changes are related to converting from sprockets requires to
ESM imports/export. However, there are a few notable changes as well:

- A few methods have been refactored to store the Rails object in a
  closure so that properties on it can be overriden by applications (as
  documented and tested). This also resulted in the "start" module
  getting inlined so that it can use the resulting functions.

- The logic for running Rails.start() automatically had to change
  because Rollup uses a slightly different module format than the
  previous coffeescript bundle. The Rollup bundle does not set
  window.Rails until the end up the bundle, so the condition had to be
  updated and window.Rails had to be set manually to ensure backwards
  compatability with scripts listening to the rails:attachBindings event
2022-07-07 21:52:08 -04:00
Azzen Abidi 3f13828392
[ci skip] Added a note about Github Codespaces' warning (#44148)
* Added a note about Github Codespaces warning

Related discussion: https://discuss.rubyonrails.org/t/issues-with-github-codespaces-setup-to-contribute-to-rails/79731

* updated docs to omit Codespace's warning 

[Original answer](https://github.com/rails/rails/pull/44148#issuecomment-1015022184)

* updated gems delayed_job to 4.1.10 && delayed_job_active record to 4.1.7

[Azzen Abidi + Rafael Mendonça França]
2022-01-21 09:08:50 -05:00
David Heinemeier Hansson af7428c4ac
Replace webpack with importmapped Hotwire as default js (#42999)
* Turbolinks is being replaced with Hotwire

* Make --webpack opt-in

* Don't use specific webpacker installers any more in preparation for next Webpacker

* Update railties/lib/rails/app_updater.rb

Co-authored-by: Alex Ghiculescu <alex@tanda.co>

* Trailing whitespace

* Convert to Turbo data attribute for tracking

* Default is no webpack, no hotwire

* Swap out turbolinks references for hotwire

* Drop explicit return

* Only generate package.json if using webpack

* Only create package.json in webpack mode

* Only create app/javascript in webpack mode

* Generate correct style/js links based on js mode

* Fix tests from changed output format

Not sure why these are showing up in this PR, though.

* Rubocopping

* Stick with webpack for the test app for now

* Adjust tests

* Replace minitest-reporters with minitest-ci (#43016)

minitest-reporters is used to create junit xml reports on CI.

But when it loads before rails minitest plugin makes
`Rails::TestUnitReporter` not being added as a reporter.

minitest-ci is now only loaded at ci and does not interferes with
rails minitest plugins. And keeps junit reports workings

* Too heavy handed to actually run bundle

Just like we don't auto-migrate

* Pin js frameworks in importmap

Instead of having importmap preconfigure it.

* Match updated app/javascript path

* No need for the explaining comment

* Fixes test cases for replace webpack with importmapped Hotwire as default js (#42999)

* Fix rubocop issues

* Fix more railities test cases

* Fix plugin generator railties shared test cases

* Fix Action Text install generator asset pipeline spec

* They're modules, not files

* Let dev use the latest release as well

So we don't have to replace unexisting dev releases with latest release

* Make Webpack responsible for generating all the JS files it needs

Webpacker 6 has already moved from app/javascript to app/packs.

* Don't add rails/ujs by default any longer

All the ajax/form functionality has been superseded by Turbo. The rest lives in a weird inbetween land we need to address through other means.

* Use new importmap location

* Switch to using turbo-rails and stimulus-rails directly

The hotwire-rails gem does not offer enough value for its indirection

* Use latest Webpacker

* Prevent version resolution requests from getting swallowed

* Use ESM syntax for imports

* Move management of yarn, package.json, etc to Webpacker 6

* Update for Webpacker 6

* Move bin/setup addition to Webpacker as well

* Remove dead tests

* Bump to Webpacker 6.0.0.rc.2

* No longer relevant given the new default is no webpacker

* Rely on Webpacker 6

* No longer relevant

* No longer relevant

* Make cable channel generator work for both webpacker and importmap setups

* Fix tests

* For tests testing importmap way

* Use Webpacker 6 dummy

* RuboCopping

* One more bump to fix webpack-dev-server

* Another bump. Hopefully the last one!

* Also enough to not want turbo tracking on

* Fix tests

* Latest

* Fix tests

* Fix more tests

* Fix tests

Co-authored-by: Alex Ghiculescu <alex@tanda.co>
Co-authored-by: André Luis Leal Cardoso Junior <andrehjr@gmail.com>
Co-authored-by: Abhay Nikam <nikam.abhay1@gmail.com>
Co-authored-by: Guillermo Iguaran <guilleiguaran@gmail.com>
2021-08-26 10:39:36 +02:00
David Heinemeier Hansson 4a23cb3415
Output Action Cable JS without transpiling and as ESM (#42856)
* Output Action Cable JS without transpiling and as ESM

* Retain umd version under the old name, generate ESM version + duplicate under new name

* Precompile JavaScripts for direct asset pipeline use

* We've dropped support for IE11

* Include deprecation notice for the old file reference

Thanks @rafaelfranca 👍

* Allow app to opt out of precompiling actioncable js assets

cc @rafaelfranca

* Add changelog entries
2021-08-06 14:00:43 +02:00
Rafael Mendonça França 8c5badec99
Update yarn.lock 2021-08-06 03:41:31 +00:00
Santiago Bartesaghi f1a02cc887 Upgrade kind-of 2020-04-19 23:59:27 -03:00
Yash Ladha 4b1c65de34
chore: updated package.json to include fsevents compatible version for
node 12
2020-03-04 11:45:11 +05:30
Prathamesh Sonpatki 88ebb94280
Fix outdated yarn.lock 2019-04-25 14:27:11 +05:30
yuuji.yaginuma 16dae7684e Fix `yarn.lock`
The trix moved to a peer dependency since 11b73c40c2.
So that does not include in `yarn.lock`.
2019-04-19 07:42:54 +09:00
Javan Makhmali 86b489e3d6 Move all npm packages to @rails scope
Fixes #33083
2019-01-10 11:01:57 -05:00
Richard Macklin fb0c81d349 Remove obsolete yarn.lock files and check in root yarn.lock file 2018-12-02 10:02:14 -08:00