Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoodJob's JavaScript takes precedence over application's JavaScript in GoodJob 3.12.6, Rails 7 #873

Closed
ianterrell opened this issue Mar 1, 2023 · 4 comments · Fixed by #874

Comments

@ianterrell
Copy link

ianterrell commented Mar 1, 2023

Using GoodJob 3.12.6 results in what appears to be the GoodJob's application.js being used instead of my own application's application.js. This occurs whether or not I mount the engine.

Observed

On my page output by <%= javascript_importmap_tags %> I see something like:

<link rel="modulepreload" href="/assets/application-39085....js">
<link rel="modulepreload" href="/assets/turbo.min-f309b....js">
<!-- etc -->

Viewing the contents of the application.js file built by the asset pipeline show the GoodJob JavaScript:

/*jshint esversion: 6, strict: false */

import renderCharts from "charts";
import checkboxToggle from "checkbox_toggle";
import documentReady from "document_ready";
import showToasts from "toasts";
import setupPopovers from "popovers";
import LivePoll from "live_poll";

import { Application } from "stimulus";
window.Stimulus = Application.start();

documentReady(function() {
  renderCharts();
  showToasts();
  setupPopovers();
  checkboxToggle();

  const livePoll = new LivePoll
  livePoll.start();
});

This breaks all of my site JS.

Expected

On GoodJob 3.12.5 the tags rendered properly link to my application's JavaScript.

Reproduction

New app without GoodJob:

rails new goodjob
rails g controller home index
rails s

Observe that the JS linked is the application's.

open "http://localhost:3000/home/index

Add GoodJob to Gemfile gem "good_job" and bundle install. That will install latest 3.12.6. Observe that the JS is GoodJob's.

Set to 3.12.5 with gem "good_job", "3.12.5" and bundle install. Observe that the JS is the application's.

Environment

❯ rails --version
Rails 7.0.4.2
❯ ruby --version
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin22]
@bensheldon
Copy link
Owner

Ah nuts! Sorry about that!! I think I need to namespace GoodJob's assets to have that not happen. Let me go do that right now.

@bensheldon
Copy link
Owner

@ianterrell I just released https://github.com/bensheldon/good_job/releases/tag/v3.12.7

Could you please update and confirm that it fixes the problem? 😓

@bensheldon bensheldon reopened this Mar 1, 2023
@ianterrell
Copy link
Author

@bensheldon I no longer observe this behavior with 3.12.7. Thank you!

@bensheldon
Copy link
Owner

Fhew! Thank you so much for opening this issue 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants