-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
test/ | ||
test.sh | ||
.github/ | ||
limitation.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
# Diagnostics Channel Polyfill | ||
|
||
This package provides a polyfill for the `diagnostics_channel` core Node.js module. It aims to be compatible with every single version of Node.js. It also aims to remain simple, ideally one or two files, and with zero dependencies. | ||
This package provides a polyfill for the `diagnostics_channel` core Node.js module for use with older versions of Node.js. It aims to remain simple, with zero dependencies, and only taking up a few kilobytes of space. | ||
|
||
The package attempts to backport support for every single feature that is added at later dates in Node.js core, at least assuming these are backwards compatible. | ||
This package attempts to backport every feature and bugfix that is added to Node.js core. If a feature hasn't been backported then please open a Pull Request or create an issue. | ||
|
||
Whenever the currently running version of Node.js ships with `diagnostics_channel`, **dc-polyfill** will make sure to use the global registry of channels provided by the core module. However, for older versions of Node.js, **dc-polyfill** will instead use a global symbol to track the channels. This symbol will remain the same for all versions of **dc-polyfill** to avoid the issue where multiple versions of an npm library installed in a dependency hierarchy usually provide different singletons. | ||
|
||
Ideally, this package will forever remain backwards compatible, and there will never be a v2.x release. | ||
|
||
## Usage | ||
|
||
```sh | ||
npm install dc-polyfill | ||
``` | ||
|
||
```javascript | ||
const diagnostics_channel = require('dc-polyfill'); | ||
``` | ||
|
||
## Contributing | ||
|
||
When a Pull Request is created the code runs against many different versions of Node.js. Notably, versions right before a change and versions right after a change, the first version of a release line, and the last version of a release line. | ||
|
||
Currently this module tests Node.js >= v12. If you would like to use `dc-polyfill` for versions of Node.js older than this then feel free to submit a Pull Request or open an issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env node | ||
|
||
const { execSync } = require('child_process'); | ||
|
||
const pkg = require('./package.json'); | ||
pkg.dependencies = pkg.dependencies || {}; | ||
pkg.devDependencies = pkg.devDependencies || {}; | ||
|
||
let violations = 0; | ||
|
||
const limits = pkg.limits; | ||
|
||
if (!limits) { | ||
process.exit(0); | ||
} | ||
|
||
if (('packedSize' in limits) || ('unpackedSize' in limits)) { | ||
const { size, unpackedSize } = JSON.parse(execSync(`npm pack --dry-run --json`).toString())[0]; | ||
|
||
console.log(` Packed Size: ${size}\n Unpacked Size: ${unpackedSize}`); | ||
|
||
if ('packedSize' in limits && size > limits.packedSize) { | ||
violations++; | ||
console.error(`The packed size of ${size} exceeds the limit of ${limits.packedSize}!`); | ||
} | ||
|
||
if ('unpackedSize' in limits && unpackedSize > limits.unpackedSize) { | ||
violations++; | ||
console.error(`The unpacked size of ${unpackedSize} exceeds the limit of ${limits.unpackedSize}!`); | ||
} | ||
} | ||
|
||
const depCount = Object.keys(pkg.dependencies).length; | ||
console.log(` Dependencies: ${depCount}`); | ||
|
||
if ('maxDependencies' in limits) { | ||
if (depCount > limits.maxDependencies) { | ||
violations++; | ||
console.error(`The dependency count of ${depCount} exceeds the limit of ${limits.maxDependencies}!`); | ||
} | ||
} | ||
|
||
const devDepCount = Object.keys(pkg.devDependencies).length; | ||
console.log(`Dev Dependencies: ${devDepCount}`); | ||
|
||
if ('maxDevDependencies' in limits) { | ||
if (devDepCount > limits.maxDevDependencies) { | ||
violations++; | ||
console.error(`The dev dependency count of ${devDepCount} exceeds the limit of ${limits.maxDevDependencies}!`); | ||
} | ||
} | ||
|
||
if (violations > 0) { | ||
process.exit(1); | ||
} | ||
|
||
console.log('OK'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters