Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@ampproject/rollup-plugin-closure-compiler
Advanced tools
Leverage Closure Compiler to minify and optimize JavaScript with Rollup.
Generally Closure Compiler will produce superior minification than other projects, but historically has been more difficult to use. The goal of this plugin is to reduce this friction.
npm install @ampproject/rollup-plugin-closure-compiler --save-dev
Invoke Closure Compiler from your Rollup configuration.
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife',
},
plugins: [
compiler(),
],
}
If you would like to provide additional flags and options to Closure Compiler, pass them via key-value pairs.
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife',
},
plugins: [
compiler({
formatting: 'PRETTY_PRINT'
}),
],
}
This plugin supports code splitting with Rollup's experimentalCodeSplitting
feature. Enable code splitting in your Rollup configuration and each output bundle will be minified by Closure Compiler.
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'main.js',
output: {
dir: 'public/module',
format: 'es',
},
experimentalCodeSplitting: true,
plugins: [
compiler(),
],
}
This plugin will modify the enable the assume_function_wrapper
output option for Closure Compiler when es
format is specifed to Rollup. Note: This is overrideable via passed flags and options.
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'es',
},
plugins: [
compiler(),
],
}
If your Rollup configuration outputs an IIFE format bundle with a specified name, this plugin will add an extern to ensure the name does not get mangled. Note: This is overrideable via passed flags and options.
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife',
name: 'MyAwesomeThing'
},
plugins: [
compiler(),
],
}
If your source uses reserved words for identifiers or declarations, you can supply the list of words you would like to ensure are mangled before compilation, and renewed if they are used in an import or export statement.
// rollup.config.js
import compiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'es',
},
plugins: [
compiler({}, {
mangleReservedWords: ['Plugin', 'Storage'],
}),
],
}
The AMP Project accepts responsible security disclosures through the Google Application Security program.
The AMP Project strives for a positive and growing project community that provides a safe environment for everyone. All members, committers and volunteers in the community are required to act according to the code of conduct.
rollup-plugin-closure-compiler is licensed under the Apache License, Version 2.0.
FAQs
Rollup + Google Closure Compiler
The npm package @ampproject/rollup-plugin-closure-compiler receives a total of 1,517 weekly downloads. As such, @ampproject/rollup-plugin-closure-compiler popularity was classified as popular.
We found that @ampproject/rollup-plugin-closure-compiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 16 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.