-
Notifications
You must be signed in to change notification settings - Fork 216
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
Document how to compile with requirejs optimizer when using async plugin #45
Comments
I use the async plugin on many projects. never had issues with the optimization, the async plugin should not be executed during build, see: requirejs-plugins/src/async.js Lines 33 to 35 in 82f149f
|
I have the same problem... using the optimization, the dev console say:
|
Have you found any sensible resolution? Facing the same problem... |
@alizbazar, I couldn't use the async plugin successfully after the optimizer process... |
Also having the same issue after the optimizer. Trying to find a solution. |
@millermedeiros maybe I'm using the async plugin totally wrong in my project, but I'm doing a JSON call to an API and pulling in the data to a template. Should I be doing something different if this isn't meant for a build? |
Ok so - found my issue was using Almond. Stopped using it and it worked with the build. Kind of a bummer, but it works now. |
i have same issue but is not a requirejs-plugins problem if u use shim config check this requirejs/r.js#623 after add option (wrapShim: true) at build.js 'ReferenceError: google is not defined' problem solved ps. if u not use deps property at shim config 'shim': { |
Create a simple module ( Example // lazy.js
define(function () {
var h = document.getElementsByTagName('head')[0];
function addScript(src, cb) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = src;
if (cb) {
s.onload = cb;
}
h.insertBefore(s, h.lastChild);
}
return addScript;
}); Now load google maps API // map.js
define(['lib/lazy'], function (lazy) {
lazy((document.location.protocol === 'https:' ? 'https' : 'http') + '://www.google.com/jsapi', function () {
google.load('maps', 3, {other_params: 'key=your-google-key', callback: initialize});
});
function initialize() {
var ll = new google.maps.LatLng(29.9752502, 31.0675272);
var mapCanvas = document.getElementById('map-canvas');
var mapOptions = {
zoom: 17,
center: ll,
mapTypeControl: false,
panControl: false,
scrollwheel: false,
zoomControl: true
};
var map = new google.maps.Map(mapCanvas, mapOptions);
var marker = new google.maps.Marker({
position: ll,
map: map,
title: 'Sphinx'
});
var infowindow = new google.maps.InfoWindow({
content: [
'<div>',
'<h3>Sphinx</h3>',
'<p>Great Sphinx of Giza</p>',
'</div>'
].join('')
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
});
}
}); |
Hi,
When using the async plugin to load google maps it become impossible to build and minify the project with the requirejs optimizer.
I've found a partial solution but it is missing something to be complete:
http://techblog.realestate.com.au/loading-google-maps-with-requirejs/
The text was updated successfully, but these errors were encountered: