question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Load order not preserved when using arrays for joinTo?

See original GitHub issue

Description

When using an array for joinTo, the load order doesn’t seem to be preserved, even with an order key specified.

files:
    javascripts:
      joinTo:
        '/js/application.js': [
                                /app\/coffeescript\/vendor/,
                                /app\/coffeescript\/application/
                              ]
        '/js/pages.js': [
                          /app\/coffeescript\/vendor/,
                          /app\/coffeescript\/pages/
                        ]
      order:
        before: [
          /app\/coffeescript\/vendor/
        ]

Expected behavior

I would like the files in my vendor directory (jQuery, Bootstrap) be loaded before the app scripts. Just in case this helps, I also have:

  npm: enabled: false

  modules:
    wrapper: false
    definition: false

Actual behavior

What happens is that the order of concatenation is wrong:

app scripts are loaded first jquery and semantic are loaded after my app scripts thus throwing an error.

Environment

  1. Brunch: 2.7.4
  2. Node: v6.2.1
  3. NPM: 3.9.3
  4. Operating system: Mac OS X, latest

package.json contents

{
  "name": "brunch-app",
  "description": "Description",
  "author": "Your Name",
  "version": "0.1.0",
  "repository": {
    "type": "git",
    "url": ""
  },
  "scripts": {
    "start": "brunch watch --server",
    "build": "brunch build --production"
  },
  "dependencies": {},
  "devDependencies": {
    "brunch": "^2.0.0",
    "javascript-brunch": "^2.0.0",
    "css-brunch": "^2.0.0",
    "uglify-js-brunch": "^2.0.0",
    "clean-css-brunch": "^2.0.0",
    "auto-reload-brunch": "^2.0.0",
    "javascript-brunch": ">= 1.0 < 1.4",
    "coffee-script-brunch": ">= 1.0 < 1.4",
    "sass-brunch": "^2.7.0"
  }
}

brunch config contents

# See http://brunch.io for documentation.
module.exports =

  files:
    javascripts:
      joinTo:
        '/js/application.js': [
                                /app\/coffeescript\/vendor/,
                                /app\/coffeescript\/application/
                              ]
        '/js/pages.js': [
                          /app\/coffeescript\/vendor/,
                          /app\/coffeescript\/pages/
                        ]
      order:
        before: [
          /app\/coffeescript\/vendor/
        ]
    stylesheets:
      joinTo:
        '/css/application.css': [
                                  /app\/sass\/vendor/,
                                  /app\/sass\/application/
                                ]
        '/css/pages.css':  [
                              /app\/sass\/vendor/,
                              /app\/sass\/pages/
                           ]
      order:
        before: [
          /app\/sass\/vendor\/semantic/
        ]


  paths: public: '/priv/static'

  npm: enabled: false

  modules:
    wrapper: false
    definition: false

  sourceMaps: false

Other useful files, when present (log, bower.json etc.)

If there’s an unexpected error during brunch build/brunch watch, please attach the compilation log with the debug flag (-d) and stack traces enabled (export LOGGY_STACKS=true).

If something worked with previous versions of brunch, but stopped with a newer one, please include these details as well.

brunch:config Trying to load brunch-config +0ms
  brunch:plugins Loaded plugins: javascript-brunch, css-brunch, auto-reload-brunch, coffee-script-brunch, sass-brunch +330ms
  brunch:watch add package.json +20ms
  brunch:watch add brunch-config.coffee +1ms
  brunch:watch add test/test_helper.exs +4ms
  brunch:list Reading test/test_helper.exs +1ms
  brunch:watch add app/assets/README.md +2ms
  brunch:asset Init app/assets/README.md directory=app/assets/ destPath=priv/static/README.md rel=README.md +1ms
  brunch:watch add app/assets/index.html +1ms
  brunch:asset Init app/assets/index.html directory=app/assets/ destPath=priv/static/index.html rel=index.html +1ms
  brunch:watch add app/coffeescript/application.coffee +0ms
  brunch:list Reading app/coffeescript/application.coffee +0ms
  brunch:watch add app/coffeescript/pages.coffee +1ms
  brunch:list Reading app/coffeescript/pages.coffee +0ms
  brunch:watch add app/fonts/icons.eot +0ms
  brunch:list Reading app/fonts/icons.eot +0ms
  brunch:watch add app/fonts/icons.svg +1ms
  brunch:list Reading app/fonts/icons.svg +0ms
  brunch:watch add app/fonts/icons.ttf +0ms
  brunch:list Reading app/fonts/icons.ttf +0ms
  brunch:watch add app/fonts/icons.woff +0ms
  brunch:list Reading app/fonts/icons.woff +0ms
  brunch:watch add app/fonts/icons.woff2 +0ms
  brunch:list Reading app/fonts/icons.woff2 +0ms
  brunch:watch add app/images/flags.png +1ms
  brunch:list Reading app/images/flags.png +0ms
  brunch:watch add app/sass/application.sass +0ms
  brunch:list Reading app/sass/application.sass +1ms
  brunch:watch add app/sass/pages.sass +0ms
  brunch:list Reading app/sass/pages.sass +1ms
  brunch:watch add test/controllers/entity_controller_test.exs +1ms
  brunch:list Reading test/controllers/entity_controller_test.exs +0ms
  brunch:watch add test/controllers/page_controller_test.exs +0ms
  brunch:list Reading test/controllers/page_controller_test.exs +0ms
  brunch:watch add test/models/page_test.exs +2ms
  brunch:list Reading test/models/page_test.exs +0ms
  brunch:watch add test/models/entity_test.exs +0ms
  brunch:list Reading test/models/entity_test.exs +1ms
  brunch:watch add test/support/channel_case.ex +0ms
  brunch:list Reading test/support/channel_case.ex +0ms
  brunch:watch add test/support/conn_case.ex +0ms
  brunch:list Reading test/support/conn_case.ex +0ms
  brunch:watch add test/support/model_case.ex +0ms
  brunch:list Reading test/support/model_case.ex +0ms
  brunch:watch add test/views/error_view_test.exs +1ms
  brunch:list Reading test/views/error_view_test.exs +0ms
  brunch:watch add test/views/layout_view_test.exs +0ms
  brunch:list Reading test/views/layout_view_test.exs +0ms
  brunch:watch add test/views/page_view_test.exs +0ms
  brunch:list Reading test/views/page_view_test.exs +0ms
  brunch:watch add app/coffeescript/vendor/jquery-3.1.1.min.js +9ms
  brunch:list Reading app/coffeescript/vendor/jquery-3.1.1.min.js +0ms
  brunch:watch add app/coffeescript/vendor/semantic.min.js +0ms
  brunch:list Reading app/coffeescript/vendor/semantic.min.js +0ms
  brunch:watch add app/sass/vendor/semantic.min.css +1ms
  brunch:list Reading app/sass/vendor/semantic.min.css +0ms
  brunch:asset Copied app/assets/README.md +3ms
  brunch:asset Copied app/assets/index.html +1ms
  brunch:file Init app/coffeescript/application.coffee: isntModule=false isWrapped=true +2ms
  brunch:pipeline Compiling app/coffeescript/application.coffee @ CoffeeScriptCompiler +2ms
  brunch:list Compiled app/coffeescript/application.coffee +7ms
  brunch:file Init app/coffeescript/pages.coffee: isntModule=false isWrapped=true +0ms
  brunch:pipeline Compiling app/coffeescript/pages.coffee @ CoffeeScriptCompiler +1ms
  brunch:list Compiled app/coffeescript/pages.coffee +13ms
  brunch:file Init app/sass/application.sass: isntModule=false isWrapped=false +8ms
  brunch:pipeline Compiling app/sass/application.sass @ SassCompiler +0ms
  brunch:file Init app/sass/pages.sass: isntModule=false isWrapped=false +4ms
  brunch:pipeline Compiling app/sass/pages.sass @ SassCompiler +1ms
  brunch:watch add app/sass/components/common/header.sass +3ms
  brunch:list Reading app/sass/components/common/header.sass +0ms
  brunch:watch add app/sass/components/common/sidebar.sass +1ms
  brunch:list Reading app/sass/components/common/sidebar.sass +0ms
  brunch:file Init app/coffeescript/vendor/jquery-3.1.1.min.js: isntModule=true isWrapped=true +1ms
  brunch:pipeline Compiling app/coffeescript/vendor/jquery-3.1.1.min.js @ JavaScriptCompiler +0ms
  brunch:pipeline Compiling app/coffeescript/vendor/jquery-3.1.1.min.js @ AutoReloader +1ms
  brunch:list Compiled app/coffeescript/vendor/jquery-3.1.1.min.js +0ms
  brunch:file Init app/coffeescript/vendor/semantic.min.js: isntModule=true isWrapped=true +1ms
  brunch:pipeline Compiling app/coffeescript/vendor/semantic.min.js @ JavaScriptCompiler +1ms
  brunch:pipeline Compiling app/coffeescript/vendor/semantic.min.js @ AutoReloader +0ms
  brunch:list Compiled app/coffeescript/vendor/semantic.min.js +1ms
  brunch:file Init app/sass/vendor/semantic.min.css: isntModule=true isWrapped=false +10ms
  brunch:pipeline Compiling app/sass/vendor/semantic.min.css @ CSSCompiler +1ms
  brunch:list Compiled app/sass/vendor/semantic.min.css +1ms
  brunch:file Init app/sass/components/common/header.sass: isntModule=false isWrapped=false +25ms
  brunch:pipeline Compiling app/sass/components/common/header.sass @ SassCompiler +1ms
  brunch:file Init app/sass/components/common/sidebar.sass: isntModule=false isWrapped=false +1ms
  brunch:pipeline Compiling app/sass/components/common/sidebar.sass @ SassCompiler +1ms
  brunch:pipeline Dependencies app/sass/application.sass @ SassCompiler +2s
  brunch:list Compiled app/sass/components/common/header.sass +17ms
  brunch:pipeline Dependencies app/sass/pages.sass @ SassCompiler +0ms
  brunch:list Compiled app/sass/application.sass +1ms
  brunch:pipeline Dependencies app/sass/components/common/sidebar.sass @ SassCompiler +0ms
  brunch:list Compiled app/sass/components/common/sidebar.sass +1ms
  brunch:list Compiled app/sass/pages.sass +20ms
30 Dec 13:29:07 - error: Compiling of app/sass/components/common/header.sass failed. WARNING on line 1:
This selector doesn't have any properties and will not be rendered.
 
30 Dec 13:29:07 - warn: app/sass/components/common/sidebar.sass compiled, but not written. Check your stylesheets.joinTo config
  brunch:write Writing 4/4 files +80ms
  brunch:generate Concatenating [app/coffeescript/vendor/jquery-3.1.1.min.js, app/coffeescript/vendor/semantic.min.js, app/coffeescript/application.coffee] => priv/static/js/application.js +9ms
  brunch:generate Concatenating [app/coffeescript/vendor/jquery-3.1.1.min.js, app/coffeescript/vendor/semantic.min.js, app/coffeescript/pages.coffee] => priv/static/js/pages.js +9ms
  brunch:generate Concatenating [app/sass/vendor/semantic.min.css, app/sass/application.sass] => priv/static/css/application.css +2ms
  brunch:generate Concatenating [app/sass/vendor/semantic.min.css, app/sass/pages.sass] => priv/static/css/pages.css +7ms
  brunch:generate Writing priv/static/js/application.js +6ms
  brunch:generate Writing priv/static/js/pages.js +1ms
  brunch:generate Writing priv/static/css/application.css +0ms
  brunch:generate Writing priv/static/css/pages.css +0ms

P.S I come from a rails background, so, if I missed something basic, sorry 👍

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
dsignrcommented, Jan 18, 2017

@denysdovhan The first time I built it (after modifying my settings as per recommendation), it still didn’t order them as expected, but, after a couple of runs, it now works fine! Gonna close this issue for now and will report back if things go south. Thanks a ton for your excellent support @denysdovhan!

0reactions
dsignrcommented, Feb 3, 2017

I think this issue is relevant to this as well: https://github.com/brunch/brunch/issues/1121. I got hit by 1121 yesterday. After finally debugging, it seems my other machine was running NPM version 3.9.3 and my current machine was running 4.1.2. Downgrading to 3.9.3 resolved a lot of headaches, but, I will report back soon. This is my way of telling you I’m working on it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserve order of array elements after join
The problem with your query is the join condition id = ANY(ancestors) . Not only does it not preserve original order, it also...
Read more >
Preserve the order of items in array when doing JOIN in ...
Use unnest() WITH ORDINALITY and the ordinality in an aggregate: SELECT p.id AS pid, array_agg(e.code ORDER BY ordinality) AS code FROM ...
Read more >
File Based Load Order API · Issue #20 · Nexus-Mods/vortex-api
The extension developer needs to define how to convert/deserialize the mod list file into a correctly ordered array of load order entry objects ......
Read more >
5. Working with Arrays and Loops - JavaScript Cookbook [Book]
To access stored values in reverse order (last item added is accessed first), create a LIFO (last-in, first-out) stack. Use the JavaScript Array...
Read more >
Work with arrays | BigQuery - Google Cloud
To flatten an entire column of ARRAY s while preserving the values of the other columns in each row, use a correlated cross...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found