#1198 generating config.js invalid when called multiple times in one grunt call

Closed
opened 8 years ago by nero · 0 comments

Originally at 2015-08-13T11:23:53Z by Herbert Vojčík closed at 2015-08-14T11:15:09Z

As shown in amber-smalltalk/grunt-init-amber#40, amber init ends with

Running "amdconfig:app" (amdconfig) task

Running "amberc:all" (amberc) task
Reading: src/Myprog.st
Reading: src/Myprog-Tests.st

Running "amdconfig:app" (amdconfig) task

Running "requirejs:devel" (requirejs) task
{ [Error: Error: paths fallback not supported in optimizer. Please provide a build config path override for jquery
at /home/blake/amber/node_modules/requirejs/bin/r.js:29521:23
]
originalError: [Error: paths fallback not supported in optimizer. Please provide a build config path override for jquery] }
grunt exec error:
1

Root cause for this is that config.js as generated by https://github.com/herby/amd-config-builder and augmented by external/amber-dev/lib/config.js, ends up generated incorrectly, excerpt:

  "paths": {
    "typeahead": "bower_components/typeahead.js/bower_components/typeahead.js/dist/typeahead.jquery",
    "helios/showdown": "bower_components/showdown/bower_components/showdown/src/showdown",
    "requireJS": "node_modules/requirejs/node_modules/requirejs/require",
    "require-css": "bower_components/require-css/bower_components/require-css",
    "jquery": [
      "bower_components/jquery/bower_components/jquery/dist/jquery",
      "bower_components/jquery/bower_components/jquery/jquery",
      "bower_components/jquery/bower_components/jquery/dist/jquery",
      "bower_components/jquery/bower_components/jquery/jquery"
    ],

The paths prefixes appear twice. This renders flattening "jquery" part unfeasible (as none of the files specified actually exist), and that leads to requirejs error above (as it needs single path, not the array; if paths were generated correctly, array will be replaced by first existing file as it is done when it is working correctly).

If you run grunt devel from cli, it works correctly, though. It only fails from inside amber init.

EDIT: Found out, amber init has nothing to do with it; you can reproduce the problem from cli itself by running grunt default devel yourself (or try grunt devel default). You will see that first generation is ok (the subsequent task works fine), but the second is wrong (the task fails). So the problem is running amdconfig:app task more time in single grunt command.

Still not knowing why. Smells of preserving some global state somewhere. Hopefully not in node's fs.

Originally at 2015-08-13T11:23:53Z by Herbert Vojčík closed at 2015-08-14T11:15:09Z As shown in amber-smalltalk/grunt-init-amber#40, `amber init` ends with ``` Running "amdconfig:app" (amdconfig) task Running "amberc:all" (amberc) task Reading: src/Myprog.st Reading: src/Myprog-Tests.st Running "amdconfig:app" (amdconfig) task Running "requirejs:devel" (requirejs) task { [Error: Error: paths fallback not supported in optimizer. Please provide a build config path override for jquery at /home/blake/amber/node_modules/requirejs/bin/r.js:29521:23 ] originalError: [Error: paths fallback not supported in optimizer. Please provide a build config path override for jquery] } grunt exec error: 1 ``` Root cause for this is that `config.js` as generated by https://github.com/herby/amd-config-builder and augmented by `external/amber-dev/lib/config.js`, ends up generated incorrectly, excerpt: ``` "paths": { "typeahead": "bower_components/typeahead.js/bower_components/typeahead.js/dist/typeahead.jquery", "helios/showdown": "bower_components/showdown/bower_components/showdown/src/showdown", "requireJS": "node_modules/requirejs/node_modules/requirejs/require", "require-css": "bower_components/require-css/bower_components/require-css", "jquery": [ "bower_components/jquery/bower_components/jquery/dist/jquery", "bower_components/jquery/bower_components/jquery/jquery", "bower_components/jquery/bower_components/jquery/dist/jquery", "bower_components/jquery/bower_components/jquery/jquery" ], ``` The paths prefixes appear twice. This renders flattening "jquery" part unfeasible (as none of the files specified actually exist), and that leads to requirejs error above (as it needs single path, not the array; if paths were generated correctly, array will be replaced by first existing file as it is done when it is working correctly). If you run `grunt devel` from cli, it works correctly, though. It only fails from inside `amber init`. EDIT: Found out, `amber init` has nothing to do with it; you can reproduce the problem from cli itself by running `grunt default devel` yourself (or try `grunt devel default`). You will see that first generation is ok (the subsequent task works fine), but the second is wrong (the task fails). So the problem is running `amdconfig:app` task more time in single grunt command. Still not knowing why. Smells of preserving some global state somewhere. Hopefully not in node's `fs`.
Sign in to join this conversation.
No Label
No Milestone
No assignee
1 Participants
Loading...
Cancel
Save
There is no content yet.