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) {
|
SpacebarsCompiler._beautify = function (code) {
|
||||||
if (Package.minifiers && Package.minifiers.UglifyJSMinify) {
|
if (Package.minifiers) {
|
||||||
var result = UglifyJSMinify(code,
|
var result = Package.minifiers.UglifyJSMinify(
|
||||||
{ fromString: true,
|
code,
|
||||||
mangle: false,
|
{ fromString: true,
|
||||||
compress: false,
|
mangle: false,
|
||||||
output: { beautify: true,
|
compress: false,
|
||||||
indent_level: 2,
|
output: { beautify: true,
|
||||||
width: 80 } });
|
indent_level: 2,
|
||||||
|
width: 80 } });
|
||||||
var output = result.code;
|
var output = result.code;
|
||||||
// Uglify interprets our expression as a statement and may add a semicolon.
|
// Uglify interprets our expression as a statement and may add a semicolon.
|
||||||
// Strip trailing semicolon.
|
// Strip trailing semicolon.
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ Package.onUse(function (api) {
|
|||||||
api.use('blaze-tools');
|
api.use('blaze-tools');
|
||||||
|
|
||||||
api.use('underscore');
|
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',
|
api.addFiles(['templatetag.js',
|
||||||
'optimizer.js',
|
'optimizer.js',
|
||||||
'codegen.js',
|
'codegen.js',
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ Package.describe({
|
|||||||
|
|
||||||
Package.registerBuildPlugin({
|
Package.registerBuildPlugin({
|
||||||
name: "compileTemplates",
|
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: [
|
sources: [
|
||||||
'plugin/html_scanner.js',
|
'plugin/html_scanner.js',
|
||||||
'plugin/compile-templates.js'
|
'plugin/compile-templates.js'
|
||||||
|
|||||||
Reference in New Issue
Block a user