mozilla / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
176 stars 278 forks source link

Use a custom Filer that doesn't have things Bramble doesn't use #241

Closed humphd closed 9 years ago

humphd commented 9 years ago

Filer isn't small, and there's no point in us including bits of it we don't use in Bramble. I'd like to see us figure out the set of things we need from fs and shell and do a custom version for Bramble. This can either be done upstream or we can just fork it (Filer is pretty much done at this point).

humphd commented 9 years ago

Here's what we use:

impls/filer/FilerFileSystem.js:        fs.stat(path, function(err, stats) {
impls/filer/FilerFileSystem.js:        fs.exists(path, function(exists) {
impls/filer/FilerFileSystem.js:        fs.readdir(path, function (err, contents) {
impls/filer/FilerFileSystem.js:        fs.mkdir(path, mode, function (err) {
impls/filer/FilerFileSystem.js:        fs.rename(oldPath, newPath, _wrap(updateBlobURL));
impls/filer/FilerFileSystem.js:        fs.readFile(path, encoding, function (_err, _data) {
impls/filer/FilerFileSystem.js:        fs.writeFile(path, data, encoding, function (err) {
impls/filer/FilerFileSystem.js:        fs.readFile(path, encoding, function (_err, _data) {
impls/filer/FilerFileSystem.js:        fs.stat(path, function(err, stats) {
impls/filer/FilerFileSystem.js:        watchers[path] = fs.watch(path, {recursive: true}, function(event, filename) {

That's stat, exists, readdir, mkdir, rename, readFile, writeFile, and watch. At the moment, we don't use anything in the Shell; however, when I do the zip/unzip stuff, I'll need some things, so we shouldn't remove the Shell totally--as long as Filer still has it, I can extend it when I need to use that stuff.

Probably the best way to approach this problem is to use dead-code removal with the Closure compiler in a build step. It lets you define a set of function/variable names to keep, and kills off anything else that doesn't have a caller.

humphd commented 9 years ago

https://developers.google.com/closure/compiler/docs/api-tutorial3 shows how to do this.

humphd commented 9 years ago

I don't think this is worth doing. I did an experiment with aggressive dead code removal, and even then it only saved 15K or 20K. Closing.