forked from parcel-bundler/parcel
-
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.
Fixes parcel-bundler#10014 Signed-off-by: solonovamax <[email protected]>
- Loading branch information
1 parent
393f497
commit 6e4bc19
Showing
6 changed files
with
231 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@parcel/compressor-zstd", | ||
"version": "2.13.3", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/parcel" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/parcel-bundler/parcel.git" | ||
}, | ||
"main": "lib/ZstdCompressor.js", | ||
"source": "src/ZstdCompressor.js", | ||
"engines": { | ||
"node": ">= 16.0.0", | ||
"parcel": "^2.13.3" | ||
}, | ||
"dependencies": { | ||
"@mongodb-js/zstd": "^2.0.0", | ||
"@parcel/plugin": "2.13.3" | ||
} | ||
} |
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,26 @@ | ||
// @flow | ||
import {Compressor} from '@parcel/plugin'; | ||
import {compress} from '@mongodb-js/zstd'; | ||
import {Transform} from 'stream'; | ||
|
||
export default (new Compressor({ | ||
compress({options, stream}) { | ||
if (options.mode !== 'production') { | ||
return null; | ||
} | ||
|
||
return { | ||
stream: stream.pipe( | ||
new Transform({ | ||
transform(chunk, encoding, cb) { | ||
compress(chunk, 19).then( | ||
compressed => cb(null, compressed), | ||
error => cb(error, null), | ||
); | ||
}, | ||
}), | ||
), | ||
type: 'zst', | ||
}; | ||
}, | ||
}): Compressor); |
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
2 changes: 1 addition & 1 deletion
2
packages/core/integration-tests/test/integration/compressors/.parcelrc
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,6 +1,6 @@ | ||
{ | ||
"extends": ["@parcel/config-default"], | ||
"compressors": { | ||
"*": ["...", "@parcel/compressor-gzip", "@parcel/compressor-brotli"] | ||
"*": ["...", "@parcel/compressor-gzip", "@parcel/compressor-brotli", "@parcel/compressor-zstd"] | ||
} | ||
} |
Oops, something went wrong.