check-side-effects
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -48,9 +48,10 @@ "use strict"; | ||
function checkSideEffects(_a) { | ||
var cwd = _a.cwd, esModules = _a.esModules, output = _a.output, _b = _a.pureGetters, pureGetters = _b === void 0 ? false : _b, _c = _a.globalDefs, globalDefs = _c === void 0 ? {} : _c, _d = _a.sideEffectFreeModules, sideEffectFreeModules = _d === void 0 ? [''] : _d, // empty string assumes all modules are side effect free. | ||
_e = _a.resolveExternals, // empty string assumes all modules are side effect free. | ||
resolveExternals = _e === void 0 ? false : _e, _f = _a.printDependencies, printDependencies = _f === void 0 ? false : _f, _g = _a.useBuildOptimizer, useBuildOptimizer = _g === void 0 ? true : _g, _h = _a.useMinifier, useMinifier = _h === void 0 ? true : _h, _j = _a.warnings, warnings = _j === void 0 ? false : _j; | ||
var _b = _a.cwd, cwd = _b === void 0 ? process.cwd() : _b, esModules = _a.esModules, // string or string array | ||
output = _a.output, _c = _a.propertyReadSideEffects, propertyReadSideEffects = _c === void 0 ? true : _c, _d = _a.globalDefs, globalDefs = _d === void 0 ? {} : _d, _e = _a.sideEffectFreeModules, sideEffectFreeModules = _e === void 0 ? [''] : _e, // empty string assumes all modules are side effect free. | ||
_f = _a.resolveExternals, // empty string assumes all modules are side effect free. | ||
resolveExternals = _f === void 0 ? false : _f, _g = _a.printDependencies, printDependencies = _g === void 0 ? false : _g, _h = _a.useBuildOptimizer, useBuildOptimizer = _h === void 0 ? true : _h, _j = _a.useMinifier, useMinifier = _j === void 0 ? true : _j, _k = _a.warnings, warnings = _k === void 0 ? false : _k; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var resolvedEsModules, outputFilePath, missingModules, tmpInputFilename, terserConfig, buildOptimizerConfig, inputOptions, outputOptions, bundle, output_1; | ||
return __generator(this, function (_k) { | ||
switch (_k.label) { | ||
return __generator(this, function (_l) { | ||
switch (_l.label) { | ||
case 0: | ||
@@ -86,3 +87,5 @@ resolvedEsModules = esModules.map(function (m) { return path_1.resolve(cwd, m).replace(/\\/g, '/'); }); | ||
treeshake: { | ||
propertyReadSideEffects: pureGetters, | ||
// propertyReadSideEffects true assumes that getters might have side effects, | ||
// while false assumes that getters never have side effects. | ||
propertyReadSideEffects: propertyReadSideEffects, | ||
pureExternalModules: false, | ||
@@ -102,3 +105,3 @@ annotations: true, | ||
case 1: | ||
bundle = _k.sent(); | ||
bundle = _l.sent(); | ||
// `bundle.watchFiles` is an array of files the bundle depends on. | ||
@@ -113,3 +116,3 @@ if (printDependencies) { | ||
// Write the bundle to disk. | ||
_k.sent(); | ||
_l.sent(); | ||
// Delete the temporary input file. | ||
@@ -124,3 +127,3 @@ fs_1.unlinkSync(tmpInputFilename); | ||
case 4: | ||
output_1 = (_k.sent()).output; | ||
output_1 = (_l.sent()).output; | ||
// Delete the temporary input file. | ||
@@ -127,0 +130,0 @@ fs_1.unlinkSync(tmpInputFilename); |
@@ -65,3 +65,3 @@ "use strict"; | ||
'help', | ||
'pureGetters', | ||
'propertyReadSideEffects', | ||
'resolveExternals', | ||
@@ -76,3 +76,3 @@ 'printDependencies', | ||
alias: { | ||
'pureGetters': 'pure-getters', | ||
'propertyReadSideEffects': 'property-read-side-effects', | ||
'resolveExternals': 'resolve-externals', | ||
@@ -84,3 +84,3 @@ 'printDependencies': 'print-dependencies', | ||
default: { | ||
'pureGetters': false, | ||
'propertyReadSideEffects': true, | ||
'resolveExternals': false, | ||
@@ -171,3 +171,3 @@ 'printDependencies': false, | ||
output: options.output, | ||
pureGetters: options.pureGetters, | ||
propertyReadSideEffects: options.propertyReadSideEffects, | ||
resolveExternals: options.resolveExternals, | ||
@@ -174,0 +174,0 @@ printDependencies: options.printDependencies, |
{ | ||
"name": "check-side-effects", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "Check if a ES module has side effects.", | ||
@@ -22,4 +22,4 @@ "repository": "https://github.com/filipesilva/check-side-effects", | ||
"minimist": "~1.2.0", | ||
"rollup": "~1.6.0", | ||
"rollup-plugin-node-resolve": "~4.0.1", | ||
"rollup": "~1.11.3", | ||
"rollup-plugin-node-resolve": "~4.2.3", | ||
"rollup-plugin-terser": "~4.0.4", | ||
@@ -26,0 +26,0 @@ "tslib": "~1.9.3", |
@@ -17,5 +17,5 @@ # Check side effects | ||
A more subtle side effect is property access, like `const obj = {}; obj.prop;`. `obj` isn't really used, and it's not even exported. But because something might be happening on the property getter, it's retained in the final bundle. | ||
A more subtle side effect is property read, like `const obj = {}; obj.prop;`. `obj` isn't really used, and it's not even exported. But because something might be happening on the property read, it's retained in the final bundle. | ||
It's incommon to have size effects on getters and for that reason some tools offer a configuration option to assume property getters have no side effects. | ||
It's incommon to have size effects on property read and for that reason some tools offer a configuration option to assume property reads have no side effects. | ||
@@ -70,12 +70,12 @@ These examples are trivial but on complex pieces of software you will likely find non-trivial variations of the same theme. | ||
``` | ||
--help Show the help message. | ||
--cwd Override working directory to run the process in. | ||
--output Output the bundle to this path. Useful to trace the sourcemaps. | ||
--pure-getters Assume there are no side effects from getters. [Default: true] | ||
--resolve-externals Resolve external dependencies. [Default: false] | ||
--print-dependencies Print all the module dependencies. [Default: false] | ||
--use-build-optimizer Run Build Optimizer over all modules. [Default: true] | ||
--use-minifier Run minifier over the final bundle to remove comments. [Default: true] | ||
--warnings Show all warnings. [Default: false] | ||
--test Read a series of tests from a JSON file. [Default: false] | ||
--help Show the help message. | ||
--cwd Override working directory to run the process in. | ||
--output Output the bundle to this path. Useful to trace the sourcemaps. | ||
--property-read-side-effects Assume there are side effects from property reads. [Default: true] | ||
--resolve-externals Resolve external dependencies. [Default: false] | ||
--print-dependencies Print all the module dependencies. [Default: false] | ||
--use-build-optimizer Run Build Optimizer over all modules. [Default: true] | ||
--use-minifier Run minifier over the final bundle to remove comments. [Default: true] | ||
--warnings Show all warnings. [Default: false] | ||
--test Read a series of tests from a JSON file. [Default: false] | ||
``` | ||
@@ -114,7 +114,9 @@ | ||
const cwd = process.cwd | ||
const opts = { | ||
cwd = process.cwd(), | ||
esModules = ['./path/to/library/module.js'], | ||
output = undefined, | ||
pureGetters = true, | ||
esModules, // string or string array | ||
output, | ||
propertyReadSideEffects = true, | ||
globalDefs = {}, | ||
@@ -155,4 +157,6 @@ sideEffectFreeModules = [''], // empty string assumes all modules are side effect free. | ||
To build, run `npm run build`. To test, run `npm run test`. | ||
To build, run `npm run build`. | ||
To test, run `npm run test`. If you need to update the test snapshots, run `cd test && npm test -- --update`. | ||
To release, run `npm run release <release-type>` where `<release-type>` is one of `patch`, `minor` or `major`. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40122
408
159
+ Added@types/resolve@0.0.8(transitive)
+ Addedrollup@1.11.3(transitive)
+ Addedrollup-plugin-node-resolve@4.2.4(transitive)
- Removedrollup@1.6.1(transitive)
- Removedrollup-plugin-node-resolve@4.0.1(transitive)
Updatedrollup@~1.11.3