-
Notifications
You must be signed in to change notification settings - Fork 114
Use Babili for minification #726
Comments
I had a quick look at what would happen if I replace function minify(output, fileName, mangle, uglifyOpts) {
var uglify = require('uglify-es');
let files = {};
files[fileName] = output.source;
var result = uglify.minify(files, {
sourceMap: {
content: output.sourceMap,
url: fileName + ".map"
}
});
output.source = result.code;
output.sourceMap = result.map;
return output;
} All the tests pass apart from these two: 106 passing (16s)
1 pending
2 failing
1) Test tree builds - Babel SFX tree build:
Error: Phantom test failed test/test-sfx.html failed.
at Error (native)
at ChildProcess.<anonymous> (C:\Users\tim\Documents\Repos\systemjs-builder\test\test-build.js:28:16)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
2) Test tree builds - TypeScript SFX tree build:
Error: Phantom test failed test/test-sfx.html failed.
at Error (native)
at ChildProcess.<anonymous> (C:\Users\tim\Documents\Repos\systemjs-builder\test\test-build.js:28:16)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) I tried these changes on v0.15.x as that's the version which |
@timfish amazing, thanks for giving this a go! It's been sitting here way to long just waiting to be picked up by someone... Yes the builder version 0.15 branch is for SystemJS 0.19. The code is exactly the same though, so if you wanted to try an initial PR against the 0.15 branch here, we can then merge it into the 0.16 branch as well when it's ready. For the build failures, it may be due to the fact that certain globals must not be altered for builds. A careful comparison of the output should help track that down here. I'd be happy to give that a go too, if there was a PR to work with as a reference. Not that carefully checking the source maps with multiple files is an important part of polishing this work for release, but having something to work with as a start would be great. |
One thing I did notice was that Ideally we'd keep I'm guessing if you'd want this on both 0.15 and 0.16 we'll keep the same configuration options for now? |
@timfish the builder project on the 0.15 branch still runs code through Traceur. This is removed in the 0.16 branch though I believe so minify should be the only dependency there. Let me know if there is anything I can do to help with the 0.20 SystemJS upgrade here as well if that is a goal. Yes |
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With uglify-es (the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / uglify-es, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping. As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
Currently, only ES5 javascript can be minified, due to the reliance on uglify-js. With terser (a maintained fork of the harmony branch of UglifyJS2) it is possible to support a broader range of javascript syntax. The API changed between uglify-js@2 and uglify-js@3 / terser, but the translation to the new API was fairly straightforward. It hews more closely to the original code than systemjs#815, and consequently I think it avoids regressing any features (for instance, the ability to include sourceContents in source maps or to control the comment stripping is retained). As browsers continue to support more features beyond ES5, and because babel recommends use of the 'env' preset, it will become increasingly likely that users' babel transpilation settings will cause errors when trying to minify with jspm and friends as long as it uses uglify-js. refs systemjs#815, systemjs#726
We can add a step to the compiler at https://github.com/systemjs/builder/blob/master/compilers/compiler.js, that returns
source, sourceMap, minifiedSource, minifiedSourceMap
by running another compile phase on the same AST after the initial unminified compile. We can then cache all four along with the load record and solve the problem of having granular caching of minification as well (#209).If anyone is interested in working on this contributions would be really really amazing.
The text was updated successfully, but these errors were encountered: