mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Keep minifiers out of built programs
This breaks the path meteor-platform -> webapp -> boilerplate-generator -> spacebars-compiler -> minifiers which ended up shipping all of uglify with each built app, even though the code generated in boilerplate-generator is just eval'd without ever being shown to humans. Beautification still works on JS generated by templating (*.html), though.
This commit is contained in:
@@ -90,14 +90,15 @@ SpacebarsCompiler.codeGen = function (parseTree, options) {
|
||||
};
|
||||
|
||||
SpacebarsCompiler._beautify = function (code) {
|
||||
if (Package.minifiers && Package.minifiers.UglifyJSMinify) {
|
||||
var result = UglifyJSMinify(code,
|
||||
{ fromString: true,
|
||||
mangle: false,
|
||||
compress: false,
|
||||
output: { beautify: true,
|
||||
indent_level: 2,
|
||||
width: 80 } });
|
||||
if (Package.minifiers) {
|
||||
var result = Package.minifiers.UglifyJSMinify(
|
||||
code,
|
||||
{ fromString: true,
|
||||
mangle: false,
|
||||
compress: false,
|
||||
output: { beautify: true,
|
||||
indent_level: 2,
|
||||
width: 80 } });
|
||||
var output = result.code;
|
||||
// Uglify interprets our expression as a statement and may add a semicolon.
|
||||
// Strip trailing semicolon.
|
||||
|
||||
@@ -11,7 +11,10 @@ Package.onUse(function (api) {
|
||||
api.use('blaze-tools');
|
||||
|
||||
api.use('underscore');
|
||||
api.use('minifiers', ['server']);
|
||||
// The templating plugin will pull in minifiers, so that generated code will
|
||||
// be beautified. But it's a weak dependency so that eg boilerplate-generator
|
||||
// doesn't pull in minifiers.
|
||||
api.use('minifiers', ['server'], { weak: true });
|
||||
api.addFiles(['templatetag.js',
|
||||
'optimizer.js',
|
||||
'codegen.js',
|
||||
|
||||
@@ -10,7 +10,13 @@ Package.describe({
|
||||
|
||||
Package.registerBuildPlugin({
|
||||
name: "compileTemplates",
|
||||
use: ['spacebars-compiler'],
|
||||
// minifiers is a weak dependency of spacebars-compiler; adding it here
|
||||
// ensures that the output is minified. (Having it as a weak dependency means
|
||||
// that we don't ship uglify etc with built apps just because
|
||||
// boilerplate-generator uses spacebars-compiler.)
|
||||
// XXX maybe uglify should be applied by this plugin instead of via magic
|
||||
// weak dependency.
|
||||
use: ['minifiers', 'spacebars-compiler'],
|
||||
sources: [
|
||||
'plugin/html_scanner.js',
|
||||
'plugin/compile-templates.js'
|
||||
|
||||
Reference in New Issue
Block a user