GithubHelp home page GithubHelp logo

cloudflare / collapsify Goto Github PK

View Code? Open in Web Editor NEW
213.0 35.0 51.0 1.24 MB

Collapsify inlines all the resources of a page into a single document

Home Page: https://github.com/cloudflare/collapsify

License: MIT License

JavaScript 59.03% TypeScript 40.97%

collapsify's People

Contributors

dknecht avatar dotjs avatar greenkeeperio-bot avatar holymiracle avatar inikulin avatar nvartolomei avatar rreverser avatar sgoo avatar terinjokes 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  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  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

collapsify's Issues

Hello

It looks like this is your first time opening an issue in this project!

Browserslist: caniuse-lite is outdated.

Seeing the following warning when running this command :

./cli.js --verbose=2 URL

DBUG[0001] [collapsify:http] Fetching ... 
Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`
DBUG[0044] [collapsify:http] Fetching ...

Cannot be npm installed in Node 12 and Node 13

Bit rot seems to be setting in ๐Ÿ˜ข

This project cannot be npm installed with Node 12/lts nor node 13.

Here are a few test cases

๐Ÿ works: Dockefile.10

FROM node:10-buster-slim

RUN apt update && apt install -y build-essential python
RUN mkdir /testcase&& cd /testcase && npm init -y && npm install --save-dev collapsify

succeeds with:

... snip ...
 ---> 41d0e2ee15adk
Successfully built 41d0e2ee15ad

๐Ÿ”ด fails: Dockefile.12

FROM node:12-buster-slim

RUN apt update && apt install -y build-essential python
RUN mkdir /testcase&& cd /testcase && npm init -y && npm install --save-dev collapsify
../src/fds-unix.cc: In function 'Nan::NAN_METHOD_RETURN_TYPE nonblock(Nan::NAN_METHOD_ARGS_TYPE)':
../src/fds-unix.cc:10:33: error: no matching function for call to 'v8::Value::Uint32Value()'
   int fd = info[0]->Uint32Value();
                                 ^
In file included from /root/.cache/node-gyp/12.16.1/include/node/node.h:63,
                 from ../../nan/nan.h:54,
                 from ../src/fds-unix.cc:1:
/root/.cache/node-gyp/12.16.1/include/node/v8.h:2707:41: note: candidate: 'v8::Maybe<unsigned int> v8::Value::Uint32Value(v8::Local<v8::Context>) const'
   V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(
                                         ^~~~~~~~~~~

๐Ÿ”ด fails: Dockefile.13

FROM node:13-buster-slim

RUN apt update && apt install -y build-essential python
RUN mkdir /testcase&& cd /testcase && npm init -y && npm install --save-dev collapsify

fails with:

../src/fds-unix.cc: In function 'Nan::NAN_METHOD_RETURN_TYPE nonblock(Nan::NAN_METHOD_ARGS_TYPE)':
../src/fds-unix.cc:10:33: error: no matching function for call to 'v8::Value::Uint32Value()'
   int fd = info[0]->Uint32Value();
                                 ^
In file included from /root/.cache/node-gyp/13.8.0/include/node/node.h:63,
                 from ../../nan/nan.h:54,
                 from ../src/fds-unix.cc:1:
/root/.cache/node-gyp/13.8.0/include/node/v8.h:2776:41: note: candidate: 'v8::Maybe<unsigned int> v8::Value::Uint32Value(v8::Local<v8::Context>) const'
   V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value(

Save them to a tmp dir and execute them with docker build Dockefile.XX .

Releases / Tags out of sync?

I can see in the package.json (etc) for this repo and in npm that the latest version of this package is 0.7.0 but the this version does not have an associated tag pushed or release published to Github, nor is there a changelog. Has something fallen out of sync here? Having this meta information available in the Github repo would help a lot with making the decision on when / if we should update our dependencies.

Support for defined excludes for inlining

As an Enterprise customer we ran across an issue with our particular use case today - you may wish for a Cloudflare Error Page (run via collapsify) to not inline a particular image, CSS file, or script on some error pages.

It'd be awesome if it was possible to wrap exclude tags around content you wish to prevent from being inlined.

<!-- {INLINE-DISABLE} -->
<link rel="stylesheet" href="/path/to/style.css">
<img src="/path/to/img.png">
<!-- {INLINE-ENABLE} -->

Code sample in readme doesn't run in current versions of node

The example code in the readme does not run in current versions of node. If I copy the code exactly as written into a file called collapse.js and then run node collapse.js, I get the following output:

internal/modules/cjs/loader.js:1102
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/cody/code/collapse/node_modules/collapsify/built/collapsify.js
require() of ES modules is not supported.
require() of /Users/cody/code/collapse/node_modules/collapsify/built/collapsify.js from /Users/cody/code/collapse/collapse.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename collapsify.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/cody/code/collapse/node_modules/collapsify/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/cody/code/collapse/collapse.js:2:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {
  code: 'ERR_REQUIRE_ESM'
}

If I try changing the first line to import collapsify from 'collapsify'; I get:

(node:32431) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/cody/code/collapse/collapse.js:1
import collapsify from 'collapsify';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

If I create a basic module and then try to run it, I get:

internal/modules/cjs/loader.js:929
  const err = new Error(`Cannot find module '${request}'`);
              ^

Error: Cannot find module '/Users/cody/code/collapse/node_modules/nanoid/non-secure/index.cjs'
    at createEsmNotFoundErr (internal/modules/cjs/loader.js:929:15)
    at finalizeEsmResolution (internal/modules/cjs/loader.js:922:15)
    at resolveExports (internal/modules/cjs/loader.js:450:14)
    at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/Users/cody/code/collapse/node_modules/postcss/lib/input.js:6:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/cody/code/collapse/node_modules/nanoid/package.json'
}

License missing

Cool project!

Would love to try it out but would prefer to know what license it is under before deep-diving.. :)

Usage with filesystem instead of URL?

e.g. instead of using:

collapsify -V 2 -o test.html "http://localhost:52015/demo.html" -x ''

it'd be handy if I could use:

collapsify -V 2 -o test.html "file://demo.html" -x ''

I know I can spin up a temp web server.. But it's a bit of a pain. ๐Ÿ˜…

Support HTML Imports

HTML Imports are an emerging standard that enable authors to import document fragments similarly to how CSS is imported today. It would be cool if Collapsify supported inlining HTML Imports in a sane way. For reference, another project that already makes some attempts to do this is Vulcanize.

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.