Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions packages/firebase/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ const plugins = [

const external = Object.keys(pkg.dependencies || {});

const uglifyOptions = {
mangle: {
properties: {
keep_quoted: true,
regex: /_$|^_/
}
},
compress: {
passes: 3,
unsafe: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it mean it could break things in some case?

Copy link
Contributor Author

@jsayol jsayol Nov 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compress.unsafe option applies these 4 transformations:

  • new Array(1, 2, 3) or Array(1, 2, 3)[ 1, 2, 3 ]
  • new Object(){}
  • String(exp) or exp.toString()"" + exp
  • new Object/RegExp/Function/Error/Array (...) → the new is discarded

These should actually be safe in most cases. That being said, I just did a build without that option and it seems like it only provides a very marginal reduction in size, about an extra 0.2% on average.

I don't think it's worth it, so I'll remove it.

Edit: I also removed the compress.warnings option, since it turns out the default is already false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks great, thank you!

warnings: false,
}
};

/**
* Global UMD Build
*/
Expand Down Expand Up @@ -81,7 +95,7 @@ const appBuilds = [
format: 'umd',
name: GLOBAL_NAME
},
plugins: [...plugins, uglify()]
plugins: [...plugins, uglify(uglifyOptions)]
}
];

Expand Down Expand Up @@ -138,7 +152,7 @@ const componentBuilds = components
);
}`
},
plugins: [...plugins, uglify()],
plugins: [...plugins, uglify(component !== 'auth' ? uglifyOptions : {})],
external: ['@firebase/app']
}
];
Expand Down Expand Up @@ -168,7 +182,7 @@ const completeBuilds = [
format: 'umd',
name: GLOBAL_NAME
},
plugins: [...plugins, uglify()]
plugins: [...plugins, uglify(uglifyOptions)]
},
/**
* App Node.js Builds
Expand Down