Git Product home page Git Product logo

rollup-plugin-gzip's People

Contributors

dependabot[bot] avatar dilyanpalauzov avatar iamserverless avatar kryops avatar mazerty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rollup-plugin-gzip's Issues

UnhandledPromiseRejectionWarning

I use nodejs 13.11.0 with --module option enabled by default (package.json contains {'type': 'module'} and thus all .js files are handled as es6 module), rollup 2.1.0 and rollup-plugin-gzip 2.3.0.

The output is:

(node:18047) UnhandledPromiseRejectionWarning: [rollup-plugin-gzip] Error compressing additional file dest/minified.css
(node:18047) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,
 use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:18047) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The .js file is compressed.

The css file, produced by the same input file, coming from rollup-plugin-css-porter is generated, but not compressed.

Compress extracted css

I use postcss plugin (or sass plugin sometimes) with extract option enabled to get separate css file.

When I add this css file using additional option, it doesn't works as expected:

gzip({
            algorithm: 'zopfli',
            options: {
                level: 9,
                numiterations: 10
            },
            additional: [
                join(distdir, `client_${version}.min.css`)
            ],
        }),
kayo@debi:$ rollup -c
rollup-plugin-gzip: Error reading file dist/client_0.0.3.min.css
created dist/client_0.0.3.min.js in 3.4s
kayo@debi:$ ls -al dist/client_0.0.3.min.css
-rw-r--r-- 1 kayo kayo dist/client_0.0.3.min.css

It seems that compression runs before file actually extracted.

Support Vite

It would be nice if this plugin was built in a way that it would work also with Vite.

https://github.com/keithamus/rollup-plugin-brotli works with Vite and the relevant difference seems to be that rollup-plugin-brotli gathers the files in generateBundle and then compresses the files in writeBundle. Vite does its own internal processing in the generateBundle phase so if you use this plugin today with Vite, it seems to work fine but actually you are compressing invalid versions of the files (they still contain placeholders like ´__VITE__PRELOAD__`)

This has earlier been discussed in Vite's issue tracker also vitejs/vite#1960

Remove compatibility hacks for Rollup >=2.0.0

Rollup 2.0.0 removed some old APIs, which might make it possible to improve our hacks around the additionalFilesDelay option.

We should investigate disabling the delay by default for Rollup >= 2.0.0

Can't npm install on windows

Due to a dependency on node-zopfli, this package is not currently installable on Windows 10, node 8.11

This is after I ran the following in an Administrator Powershell (before doing that, I was getting a cannot find Python error, also thrown by node-zopfli) :

npm install -g --production node-gyp windows-build-tools

The errors:

> [email protected] install C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v2.0.2-node-v57-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  zopfli-binding.cc
  zopflipng.cc
  zopflipng_lib.cc
  lodepng.cpp
..\zopfli\src\zopflipng\lodepng\lodepng.cpp(781): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) [C:\Users\radclifd\src\dean\an
tares\node_modules\node-zopfli\build\zopfli.vcxproj]
..\zopfli\src\zopflipng\lodepng\lodepng.cpp(3460): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) [C:\Users\radclifd\src\dean\a
ntares\node_modules\node-zopfli\build\zopfli.vcxproj]
  lodepng_util.cpp
  win_delay_load_hook.cc
..\zopfli\src\zopflipng\lodepng\lodepng_util.cpp(138): warning C4244: '=': conversion from '__int64' to 'long', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\no
de-zopfli\build\zopfli.vcxproj]
..\zopfli\src\zopflipng\lodepng\lodepng_util.cpp(142): warning C4244: '=': conversion from '__int64' to 'long', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\no
de-zopfli\build\zopfli.vcxproj]
..\zopfli\src\zopflipng\lodepng\lodepng_util.cpp(143): warning C4244: '=': conversion from '__int64' to 'long', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\no
de-zopfli\build\zopfli.vcxproj]
..\zopfli\src\zopflipng\lodepng\lodepng_util.cpp(147): warning C4244: '=': conversion from '__int64' to 'long', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\no
de-zopfli\build\zopfli.vcxproj]
..\src\zopfli-binding.cc(137): warning C4996: 'Nan::Callback::Call': was declared deprecated [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\zopfli.vcxproj]
  C:\Users\radclifd\src\dean\antares\node_modules\nan\nan.h(1618): note: see declaration of 'Nan::Callback::Call'
  blocksplitter.c
  cache.c
  deflate.c
  gzip_container.c
..\zopfli\src\zopfli\cache.c(36): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'std::size_t' [C:\Users\r
adclifd\src\dean\antares\node_modules\node-zopfli\build\zopfli.vcxproj]
  ..\zopfli\src\zopfli\cache.c(36): note: consider using '%zu' in the format string
..\zopfli\src\zopfli\deflate.c(538): warning C4244: '=': conversion from 'std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\bu
ild\zopfli.vcxproj]
..\zopfli\src\zopfli\deflate.c(540): warning C4244: '=': conversion from 'std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\bu
ild\zopfli.vcxproj]
..\zopfli\src\zopfli\deflate.c(550): warning C4244: '=': conversion from 'std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\bu
ild\zopfli.vcxproj]
..\zopfli\src\zopfli\deflate.c(552): warning C4244: '=': conversion from 'std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\bu
ild\zopfli.vcxproj]
..\zopfli\src\zopfli\deflate.c(598): warning C4244: 'return': conversion from 'std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopf
li\build\zopfli.vcxproj]
  hash.c
  katajainen.c
  lz77.c
  squeeze.c
..\zopfli\src\zopfli\lz77.c(492): warning C4244: '=': conversion from '__int64' to 'unsigned short', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\b
uild\zopfli.vcxproj]
  tree.c
  util.c
..\zopfli\src\zopfli\squeeze.c(243): warning C4305: '=': truncation from 'double' to 'float' [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\zopfli.vcxproj]
..\zopfli\src\zopfli\squeeze.c(264): warning C4244: '=': conversion from 'double' to 'float', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\zo
pfli.vcxproj]
..\zopfli\src\zopfli\squeeze.c(281): warning C4244: '=': conversion from 'double' to 'float', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\zo
pfli.vcxproj]
..\zopfli\src\zopfli\squeeze.c(299): warning C4244: '=': conversion from 'double' to 'float', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\zo
pfli.vcxproj]
  zlib_container.c
..\zopfli\src\zopfli\tree.c(79): warning C4244: 'function': conversion from 'std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli
\build\zopfli.vcxproj]
..\zopfli\src\zopfli\tree.c(85): warning C4244: 'function': conversion from 'const std::size_t' to 'double', possible loss of data [C:\Users\radclifd\src\dean\antares\node_modules\node-
zopfli\build\zopfli.vcxproj]
  zopfli_lib.c
     Creating library C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\Release\zopfli.lib and object C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\R
  elease\zopfli.exp
  Generating code
  Finished generating code
  zopfli.vcxproj -> C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\Release\\zopfli.node
  zopfli.vcxproj -> C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\Release\zopfli.pdb (Full PDB)
  Copying C:\Users\radclifd\src\dean\antares\node_modules\node-zopfli\build\Release\/zopfli.node to C:/Users/radclifd/src/dean/antares/node_modules/node-zopfli/lib/binding/node-v57-win3
  2-x64\zopfli.node
          1 file(s) copied.
npm WARN [email protected] requires a peer of rxjs-compat@^6.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

Offer .gz and .br compression simultaneously

I want to compress a file with gz and with brotli, so that browsers with brotli support get the .br file and the others get the .gz file.

Please provide an example with the shortest possible syntax that provides both brotli and .gz output from the same input.

sourcemap: "hidden" not supported contrary to docs

According to the documentation regarding the output.sourcemap option (https://rollupjs.org/configuration-options/#output-sourcemap),

If true, a separate sourcemap file will be created. If "inline", the sourcemap will be appended to the resulting output file as a data URI. "hidden" works like true except that the corresponding sourcemap comments in the bundled files are suppressed.

However, if the sourcemap: "hidden" option is used, it still generates a sourceMappingUrl in the gzipped javascript file.
Foe example, in vite configuration:

import gzipPlugin from "rollup-plugin-gzip";

export default defineConfig({
  resolve: { .. },
  plugins: [
    gzipPlugin(),
  ],
  build: {
    rollupOptions: {
      output: {
        sourcemap: "hidden" // prevent sourceMappingUrl in output and gzipped output files ????
      }
    }
  },
  server: { ... }
  ...
});

The URL is not "suppressed"

if (outputOptions.sourcemap && outputFile.map) {

sourcemap: "inline" is the only considered option:

outputOptions.sourcemap === 'inline'
.
The hidden option is unusable.

gzipPlugin is not a function

Hello,
Hope you doing well?

Whenever i try to build my project it fails with this error "gzipPlugin is not a function", it works only when i modify rollup-plugin-gzip/dis/index.js from exports.default = gzipPlugin to module.exports = gzipPlugin.

The problem am having is i use gitlabs pipeline to build my project and once npm installs the packages again the error continues.

Please help !!!!

Substitutig node-zopfi-es with @gfx/zopfli

Here is an example using zopfi but from @gfx/zopfli instead of node-zopfi-es. The advantage of the former is that it does not depend on node-gyp and the disadvantage of the latter is that it takes very, very long on every yarn update.

import { gzipAsync } from '@gfx/zopfli';

 gzipPlugin({
  customCompression: content => gzipAsync(Buffer.from(content), {numiterations: 15}),
  })

Default Filter should include wasm files

Usually wasm files can benefit quite a lot from compression. Yeah, it is super easy to change the regex to suit your needs, but wouldn't it make more sense for wasm to be compressed by default?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.