feat(strict mode): turn on ECMAScript 5 strict mode

- add 'use strict'; statement to the prefix file
- configure closure compiler to use the ES5 strict mode
- strip all file-specific strict mode flags after concatination

Closes #223
This commit is contained in:
Igor Minar 2011-05-19 00:19:21 -07:00
parent 4c6d26a38f
commit b98c23274b
2 changed files with 5 additions and 1 deletions

View file

@ -188,12 +188,15 @@ task :compile => [:init, :compile_scenario, :compile_jstd_scenario_adapter, :gen
File.open(path_to('angular.js'), 'w') do |f|
concat = 'cat ' + deps.flatten.join(' ')
f.write(%x{#{concat}})
f.write(%x{#{concat}}.
gsub(/^\s*['"]use strict['"];?\s*$/, ''). # remove all file-specific strict mode flags
gsub(/'USE STRICT'/, "'use strict'")) # rename the placeholder in angular.prefix
f.write(gen_css('css/angular.css', true))
end
%x(java -jar lib/closure-compiler/compiler.jar \
--compilation_level SIMPLE_OPTIMIZATIONS \
--language_in ECMASCRIPT5_STRICT \
--js #{path_to('angular.js')} \
--js_output_file #{path_to('angular.min.js')})
end

View file

@ -21,4 +21,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
'USE STRICT';
(function(window, document, undefined){