GlobalDependencies for non-AMD scripts don't work
Category
- [ ] Question
- [ ] Typo
- [x] Bug
- [ ] Enhancement / Suggestion
- [ ] Additional article idea
Expected or Desired Behavior
If you're loading two non-AMD scripts and one depends on another, you should be able to define the order in which they are being loaded using the globalDependencies property in the config.json file.
Observed Behavior
It seems like the globalDependencies property is not taken into account when loading non-AMD scripts defined in the externals section of config.json.
Steps to Reproduce
In config.json add to externals:
"jquery": {
"path": "https://code.jquery.com/jquery-2.1.1.min.js",
"globalName": "jQuery"
},
"simpleWeather": {
"path": "https://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.1.0/jquery.simpleWeather.min.js",
"globalName": "jQuery",
"globalDependencies": [ "jquery" ]
}
In web part code add:
import * as $ from 'jquery';
require('simpleWeather');
After adding the web part to the page you will get an error:
jquery.simpleWeather.min.js:2 Uncaught ReferenceError: jQuery is not defined(…)
This works as expected in the previous drops but seems to be broken in drop 5. The working code using an older drop can be found at https://github.com/waldekmastykarz/spfx-weather-webpart. If you update it to drop 5 you should see the error described above.
@nickpape-msft might help to understand what is going on.
This is still broken in drop 6.
This bug was fixed on January 2017 on the runtime code. No need to change the manifests at all. Now the dependencies resolution is working as expected.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues