jalla 1.0.0-36 → 1.0.0-39

Sign up to get free protection for your applications and to get access to all the features.
package/lib/build.js CHANGED
@@ -26,7 +26,11 @@ function build (state, emit) {
26
26
  Promise.all(assets.map(async function (asset) {
27
27
  var file = path.resolve(state.dist, 'public', asset.file)
28
28
  emit('progress', asset.id, 0)
29
- await createDir(path.dirname(file), { recursive: true })
29
+ try {
30
+ await createDir(path.dirname(file), { recursive: true })
31
+ } catch (err) {
32
+ // Ignore failed `mkdir` and try writing file anyway
33
+ }
30
34
  return writeFile(file, asset.buffer)
31
35
  })),
32
36
  writeFile(path.resolve(state.dist, 'stat.json'), stat)
package/lib/document.js CHANGED
@@ -4,9 +4,9 @@ var documentify = require('documentify')
4
4
  var { Readable } = require('stream')
5
5
  var hyperstream = require('hstream')
6
6
  var caniuse = require('caniuse-api')
7
+ var purgecss = require('purgecss')
7
8
  var through = require('through2')
8
9
  var resolve = require('resolve')
9
- var dropcss = require('dropcss')
10
10
  var jsesc = require('jsesc')
11
11
  var path = require('path')
12
12
 
@@ -176,17 +176,17 @@ function prependCriticalCSS (getStyles) {
176
176
  var self = this
177
177
 
178
178
  getStyles().then(function (css) {
179
- try {
180
- var critical = dropcss({ html: html, css: css.toString() })
181
- } catch (err) {
182
- // fail silently and skip inline styles
183
- self.push(html)
184
- return cb()
185
- }
186
-
179
+ css = css.toString().replace(/\/\*#\s*sourceMappingURL=.+?\s*\*\//g, '')
180
+ return new purgecss.PurgeCSS().purge({
181
+ content: [{ raw: html, extension: 'html' }],
182
+ css: [{ raw: css }]
183
+ }).then(function (result) {
184
+ return result.reduce((acc, { css }) => acc + css, '')
185
+ })
186
+ }).then(function (css) {
187
187
  var prepend = hyperstream({
188
188
  head: {
189
- _prependHtml: `<style>${critical.css}</style>`
189
+ _prependHtml: `<style>${css}</style>`
190
190
  }
191
191
  })
192
192
  var stream = new Readable()
@@ -196,7 +196,11 @@ function prependCriticalCSS (getStyles) {
196
196
  stream.pipe(prepend).pipe(through(write, end))
197
197
  stream.push(html)
198
198
  stream.push(null)
199
- }, cb)
199
+ }).catch(function () {
200
+ // fail silently and skip inline styles
201
+ self.push(html)
202
+ return cb()
203
+ })
200
204
 
201
205
  // collect the resulting html with inlined CSS
202
206
  // (str, str, fn) -> void
package/lib/script.js CHANGED
@@ -11,8 +11,8 @@ var concat = require('concat-stream')
11
11
  var browserify = require('browserify')
12
12
  var splitRequire = require('split-require')
13
13
  var sourcemap = require('convert-source-map')
14
+ var envify = require('@goto-bus-stop/envify')
14
15
  var babelPresetEnv = require('@babel/preset-env')
15
- var envify = require('tinyify/private_modules/envify/custom')
16
16
  var inject = require('./inject')
17
17
 
18
18
  module.exports = script
@@ -57,7 +57,7 @@ function script (state, emit) {
57
57
  return !file.includes('source-map-support') && include(file)
58
58
  }
59
59
  }), { global: true })
60
- b.transform(tfilter(envify(env), { filter: include }))
60
+ b.transform(tfilter(envify, { filter: include }), env)
61
61
  } else {
62
62
  // compile dynamic imports but nothing else to preserve template literals
63
63
  b.transform(tfilter(babelify, { filter: include }), {
@@ -7,7 +7,7 @@ var watchify = require('watchify')
7
7
  var concat = require('concat-stream')
8
8
  var browserify = require('browserify')
9
9
  var sourcemap = require('convert-source-map')
10
- var envify = require('tinyify/private_modules/envify/custom')
10
+ var envify = require('@goto-bus-stop/envify')
11
11
  var inject = require('./inject')
12
12
 
13
13
  module.exports = serviceWorker
@@ -29,7 +29,7 @@ function serviceWorker (state, emit) {
29
29
  b.on('reset', capture)
30
30
 
31
31
  // run envify regardless due to tinyify loosing the reference to env
32
- b.transform(tfilter(envify(env), { filter: include }))
32
+ b.transform(tfilter(envify, { filter: include }), env)
33
33
  b.transform(tfilter(brfs, { filter: include }))
34
34
 
35
35
  if (state.env === 'development') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jalla",
3
- "version": "1.0.0-36",
3
+ "version": "1.0.0-39",
4
4
  "description": "A web compiler and server in one",
5
5
  "main": "index.js",
6
6
  "bin": "bin.js",
@@ -41,57 +41,58 @@
41
41
  "dependencies": {
42
42
  "@babel/core": "^7.8.7",
43
43
  "@babel/preset-env": "^7.8.7",
44
+ "@goto-bus-stop/envify": "^5.0.0",
44
45
  "autoprefixer": "^9.7.4",
45
46
  "babel-plugin-dynamic-import-split-require": "^2.0.0",
46
47
  "babelify": "^10.0.0",
47
48
  "brfs": "^2.0.2",
48
- "browserify": "^16.5.0",
49
- "browserslist": "^4.9.1",
49
+ "browserify": "^17.0.0",
50
+ "browserslist": "^4.16.6",
50
51
  "caniuse-api": "^3.0.0",
51
- "chalk": "^3.0.0",
52
+ "chalk": "^4.1.1",
52
53
  "chokidar": "^3.3.1",
53
54
  "clear-module": "^4.1.1",
54
55
  "concat-stream": "^2.0.0",
55
56
  "convert-source-map": "^1.7.0",
56
57
  "dedent": "^0.7.0",
57
58
  "documentify": "^3.2.2",
58
- "dropcss": "^1.0.16",
59
59
  "envify": "^4.1.0",
60
- "exorcist": "^1.0.1",
60
+ "exorcist": "^2.0.0",
61
61
  "get-port": "^5.1.1",
62
- "hstream": "^2.0.0",
62
+ "hstream": "^3.1.1",
63
63
  "is-interactive": "^1.0.0",
64
- "jsesc": "^2.5.2",
64
+ "jsesc": "^3.0.2",
65
65
  "koa": "^2.11.0",
66
- "koa-conditional-get": "^2.0.0",
67
- "koa-etag": "^3.0.0",
66
+ "koa-conditional-get": "^3.0.0",
67
+ "koa-etag": "^4.0.0",
68
68
  "koa-static": "^5.0.0",
69
69
  "mime": "^2.4.3",
70
- "minify-stream": "^1.2.1",
70
+ "minify-stream": "^2.1.0",
71
71
  "minimatch": "^3.0.4",
72
72
  "minimist": "^1.2.4",
73
73
  "nanobus": "^4.4.0",
74
74
  "nanohtml": "^1.9.1",
75
75
  "ora": "^4.0.3",
76
76
  "pirates": "^4.0.0",
77
- "postcss": "^7.0.27",
78
- "postcss-csso": "^4.0.0",
79
- "postcss-import": "^12.0.1",
80
- "postcss-load-config": "^2.1.0",
81
- "postcss-url": "^8.0.0",
77
+ "postcss": "^8.3.5",
78
+ "postcss-csso": "^5.0.1",
79
+ "postcss-import": "^14.0.2",
80
+ "postcss-load-config": "^3.1.0",
81
+ "postcss-url": "^10.1.3",
82
82
  "postcss-watcher": "^2.0.0",
83
83
  "posthtml-minifier": "^0.1.0",
84
84
  "posthtmlify": "^0.2.0",
85
85
  "pretty-bytes": "^5.2.0",
86
+ "purgecss": "^4.1.3",
86
87
  "read-pkg-up": "^7.0.1",
87
88
  "regenerator-runtime": "^0.13.5",
88
89
  "resolve": "^1.15.1",
89
90
  "source-map-support": "^0.5.16",
90
91
  "split-require": "^3.1.2",
91
92
  "tfilter": "^1.0.1",
92
- "through2": "^3.0.1",
93
- "tinyify": "^2.5.2",
93
+ "through2": "^4.0.2",
94
+ "tinyify": "^3.0.0",
94
95
  "transform-ast": "^2.4.4",
95
- "watchify": "^3.11.1"
96
+ "watchify": "^4.0.0"
96
97
  }
97
98
  }