Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Package shared Javascript with yarn and webpack #44

Merged
merged 4 commits into from
Sep 14, 2017
Merged

Conversation

jmckible
Copy link
Contributor

@jmckible jmckible commented Aug 29, 2017

@techvalidate/engineering For your consideration. Feedback welcome. This change enables the refactor at techvalidate/engage#451

This PR begins the process of converting our Javascript asset pipeline to webpack. There does not seem to be a current path forward with engines and webpack, as of rails/webpacker#21

My original thought was to spin up another pano-js repository to cleanly separate our shared ruby and js. However, I feel like we're already juggling too much will multiple production version of Pano and adding yet another repo seems like it would further complicate matters.

The Changes

  1. Rails convention is to store webpack'd files in app/javascripts, not app/assets/javascripts

  2. Since the asset pipeline is not building the require load order, those calls are unnecessary.

  3. UI is now exported and loaded on the window via ProvidedPlugin

  4. Dependencies are loaded via package.json

Statements of Value

I still believe in coffeescript! Given the sprinkle nature of the majority of our js (especially UI), I have not found a situation wherein coffeescript does not provide a more concise solution to the problems we are trying to solve.

Given the breadth and depth of our discussions around Javascript, I expect this will be a controversial position. I am open to any code examples you feel my sway me. As always: strong opinions, weakly held.

To Be Investigated

  1. The main attribute in package.json allows for easy bundling of the global js. Any way to apply this to namespaces?

  2. Any way to simplify global loading with ProvidedPlugin in shared.js?

  3. I have not found an equivalent of require_tree

  4. What about CSS from dependencies? Do we need it, and if so, how do we reference it?

@tjdo
Copy link

tjdo commented Aug 29, 2017

In regards to your statement on require_tree, have a look at this. It may be the answer you seek https://stackoverflow.com/questions/29421409/how-to-load-all-files-in-a-subdirectories-using-webpack-without-require-statemen

@jmckible
Copy link
Contributor Author

Thanks, @tjdo, I will try that out!

@@ -16,7 +16,7 @@ UI.load ->
initialVal = null

if $(datepicker).val().length
initialVal = moment($(datepicker).val()).format('MM/DD/YYYY h:mm A')
initialVal = moment(new Date($(datepicker).val())).format('MM/DD/YYYY h:mm A')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To quiet a warning

@@ -1,7 +1,6 @@
updateFilters = ->
if $('#filter-bar').exists()
$("#filter-bar").stick_in_parent(parent: '#main', offset_top: 88)
$(document.body).trigger("sticky_kit:recalc")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will investigate recovering this. Not sure what it was removed.

# ===================================================

UI.load ->
$("#subnav.sticky-subnav").stick_in_parent(bottoming: false, offset_top: $('#nav').height())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will investigate


$.fn.enable = ->
this.each ->
$(this).prop('disabled', false)
$(this).removeClass('disabled').prop('disabled', false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience for Engage. I don't think this will any downstream effects.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see any downstream effects with this either

hideLoadingSpinner()
# TODO commented out with webpack conversion
# $(window).unload ->
# hideLoadingSpinner()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will investigate re-adding.

@jmckible jmckible self-assigned this Aug 29, 2017
@jmckible jmckible merged commit 5918288 into 3-0-stable Sep 14, 2017
@jmckible jmckible deleted the yarn branch September 14, 2017 05:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants