inline-critical
Advanced tools
Comparing version 10.0.1 to 11.0.0
35
cli.js
@@ -38,11 +38,11 @@ #!/usr/bin/env node | ||
type: 'string', | ||
alias: 'c', | ||
shortFlag: 'c', | ||
}, | ||
html: { | ||
type: 'string', | ||
alias: 'h', | ||
shortFlag: 'h', | ||
}, | ||
ignore: { | ||
type: 'string', | ||
alias: 'i', | ||
shortFlag: 'i', | ||
isMultiple: true, | ||
@@ -52,3 +52,3 @@ }, | ||
type: 'boolean', | ||
alias: 'm', | ||
shortFlag: 'm', | ||
default: true, | ||
@@ -58,15 +58,15 @@ }, | ||
type: 'boolean', | ||
alias: 'e', | ||
shortFlag: 'e', | ||
}, | ||
base: { | ||
type: 'string', | ||
alias: 'b', | ||
shortFlag: 'b', | ||
}, | ||
selector: { | ||
type: 'string', | ||
alias: 's', | ||
shortFlag: 's', | ||
}, | ||
preload: { | ||
type: 'boolean', | ||
alias: 'p', | ||
shortFlag: 'p', | ||
default: false, | ||
@@ -95,3 +95,3 @@ }, | ||
case 'css': | ||
case 'html': | ||
case 'html': { | ||
try { | ||
@@ -102,6 +102,10 @@ result[key] = read(value); | ||
break; | ||
case 'base': | ||
} | ||
case 'base': { | ||
result.basePath = value; | ||
break; | ||
case 'ignore': | ||
} | ||
case 'ignore': { | ||
result.ignore = (value || []).map((ignore) => { | ||
@@ -119,5 +123,8 @@ // Check regex | ||
break; | ||
default: | ||
} | ||
default: { | ||
result[key] = value; | ||
break; | ||
} | ||
} | ||
@@ -182,3 +189,2 @@ | ||
// Get stdin | ||
stdin().then(run); | ||
setTimeout(() => { | ||
@@ -191,1 +197,4 @@ if (ok) { | ||
}, 100); | ||
const input = await stdin(); | ||
run(input); |
14
index.js
@@ -20,3 +20,2 @@ /** | ||
import slash from 'slash'; | ||
import Dom from './src/dom.js'; | ||
@@ -112,4 +111,3 @@ import {removeDuplicateStyles} from './src/css.js'; | ||
// Add link tags before old links | ||
// eslint-disable-next-line array-callback-return | ||
o.replaceStylesheets.map((href) => { | ||
o.replaceStylesheets.forEach((href) => { | ||
const link = document.createElement('link'); | ||
@@ -149,4 +147,3 @@ | ||
// Remove old links | ||
// eslint-disable-next-line array-callback-return | ||
removable.map((link) => { | ||
removable.forEach((link) => { | ||
if (link.parentElement.tagName === 'NOSCRIPT') { | ||
@@ -160,4 +157,3 @@ document.remove(link.parentElement); | ||
// Modify links and add clones to noscript block | ||
// eslint-disable-next-line array-callback-return | ||
links.map((link) => { | ||
links.forEach((link) => { | ||
const href = link.getAttribute('href'); | ||
@@ -168,2 +164,6 @@ const media = link.getAttribute('media'); | ||
if (['print', 'speech'].includes(media)) { | ||
return; | ||
} | ||
if (o.extract) { | ||
@@ -170,0 +170,0 @@ const file = resolve(join(o.basePath || process.cwd, href)); |
{ | ||
"name": "inline-critical", | ||
"version": "10.0.1", | ||
"version": "11.0.0", | ||
"description": "Inline critical-path css and load the existing stylesheets asynchronously", | ||
@@ -41,3 +41,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"clean-css": "^5.3.1", | ||
"clean-css": "^5.3.2", | ||
"css": "^3.0.0", | ||
@@ -48,3 +48,3 @@ "detect-indent": "^7.0.1", | ||
"indent-string": "^5.0.0", | ||
"jsdom": "^20.0.0", | ||
"jsdom": "^22.1.0", | ||
"lodash.defaults": "^4.2.0", | ||
@@ -54,19 +54,18 @@ "lodash.escaperegexp": "^4.1.2", | ||
"lodash.isstring": "^4.0.1", | ||
"meow": "^10.1.3", | ||
"meow": "^12.1.1", | ||
"normalize-newline": "^4.1.0", | ||
"picocolors": "^1.0.0", | ||
"postcss": "^8.4.16", | ||
"postcss": "^8.4.31", | ||
"postcss-discard": "^2.0.0", | ||
"reaver": "^2.0.0", | ||
"slash": "^5.0.0", | ||
"uglify-js": "^3.17.1" | ||
"slash": "^5.1.0", | ||
"uglify-js": "^3.17.4" | ||
}, | ||
"devDependencies": { | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.23.1", | ||
"execa": "^6.1.0", | ||
"fs-extra": "^10.1.0", | ||
"jest": "^29.0.3", | ||
"read-pkg-up": "^9.1.0", | ||
"xo": "^0.52.3" | ||
"eslint": "^8.51.0", | ||
"fs-extra": "^11.1.1", | ||
"jest": "^29.7.0", | ||
"read-pkg-up": "^10.1.0", | ||
"xo": "^0.56.0" | ||
}, | ||
@@ -100,4 +99,4 @@ "xo": { | ||
"engines": { | ||
"node": ">=14.16" | ||
"node": ">=16.10" | ||
} | ||
} |
@@ -11,3 +11,3 @@ import {readFileSync} from 'node:fs'; | ||
const escapeRegExp = (string) => (string || '').replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'); | ||
const escapeRegExp = (string) => (string || '').replaceAll(/[\\^$.*+?()[\]{}|]/g, '\\$&'); | ||
@@ -43,3 +43,3 @@ /** | ||
const result = []; | ||
html.replace(new RegExp(`<${tag}(?:\\s[^>]+)?>`, 'ig'), (match, offset, string) => { | ||
html.replaceAll(new RegExp(`<${tag}(?:\\s[^>]+)?>`, 'ig'), (match, offset, string) => { | ||
if (match.includes('/>')) { | ||
@@ -120,7 +120,7 @@ result.push(string.slice(offset, offset + match.length)); | ||
if (head.length > 0) { | ||
result = result.replace(/^([\s\t]*)(<\/\s*head>)/gim, `$1$1${head.join('\n$1$1')}\n$1$2`); | ||
result = result.replaceAll(/^([\s\t]*)(<\/\s*head>)/gim, `$1$1${head.join('\n$1$1')}\n$1$2`); | ||
} | ||
if (body.length > 0) { | ||
result = result.replace(/^([\s\t]*)(<\/\s*body>)/gim, `$1$1${body.join('\n$1$1')}\n$1$2`); | ||
result = result.replaceAll(/^([\s\t]*)(<\/\s*body>)/gim, `$1$1${body.join('\n$1$1')}\n$1$2`); | ||
} | ||
@@ -127,0 +127,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26746
6
589
+ Addedcssstyle@3.0.0(transitive)
+ Addeddata-urls@4.0.0(transitive)
+ Addedjsdom@22.1.0(transitive)
+ Addedmeow@12.1.1(transitive)
+ Addedrrweb-cssom@0.6.0(transitive)
+ Addedtr46@4.1.1(transitive)
+ Addedwhatwg-url@12.0.1(transitive)
- Removed@babel/code-frame@7.24.7(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/highlight@7.24.7(transitive)
- Removed@types/minimist@1.2.5(transitive)
- Removed@types/normalize-package-data@2.4.4(transitive)
- Removedacorn@8.12.1(transitive)
- Removedacorn-globals@7.0.1(transitive)
- Removedacorn-walk@8.3.4(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedarrify@1.0.1(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedcamelcase-keys@7.0.2(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcssom@0.3.80.5.0(transitive)
- Removedcssstyle@2.3.0(transitive)
- Removeddata-urls@3.0.2(transitive)
- Removeddecamelize@1.2.05.0.1(transitive)
- Removeddecamelize-keys@1.1.1(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedescodegen@2.1.0(transitive)
- Removedesprima@4.0.1(transitive)
- Removedestraverse@5.3.0(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfind-up@5.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedhard-rejection@2.1.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@4.1.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjsdom@20.0.3(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedlocate-path@6.0.0(transitive)
- Removedlru-cache@6.0.0(transitive)
- Removedmap-obj@1.0.14.3.0(transitive)
- Removedmeow@10.1.5(transitive)
- Removedmin-indent@1.0.1(transitive)
- Removedminimist-options@4.1.0(transitive)
- Removednormalize-package-data@3.0.3(transitive)
- Removedp-limit@3.1.0(transitive)
- Removedp-locate@5.0.0(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedquick-lru@5.1.1(transitive)
- Removedread-pkg@6.0.0(transitive)
- Removedread-pkg-up@8.0.0(transitive)
- Removedredent@4.0.0(transitive)
- Removedsemver@7.6.3(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstrip-indent@4.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtr46@3.0.0(transitive)
- Removedtrim-newlines@4.1.1(transitive)
- Removedtype-fest@1.4.0(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwhatwg-url@11.0.0(transitive)
- Removedyallist@4.0.0(transitive)
- Removedyargs-parser@20.2.9(transitive)
- Removedyocto-queue@0.1.0(transitive)
Updatedclean-css@^5.3.2
Updatedjsdom@^22.1.0
Updatedmeow@^12.1.1
Updatedpostcss@^8.4.31
Updatedslash@^5.1.0
Updateduglify-js@^3.17.4