Skip to content

Commit b9f6405

Browse files
author
Mark George
committed
Fix command line utility
1 parent 1ed793b commit b9f6405

7 files changed

+198
-41
lines changed

bin/generate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const playwright = require("playwright");
2-
const { generateCriticalCSS, BrowserInterfacePlaywright } = require("../index");
3-
41
async function main() {
2+
const playwright = await import("playwright");
3+
const { generateCriticalCSS, BrowserInterfacePlaywright } = await import("../lib/index");
4+
55
const urls = process.argv.slice(2);
66

77
if (urls.length === 0) {

package-lock.json

+169-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"license": "GPL-2.0-or-later",
77
"type": "module",
88
"scripts": {
9+
"gen": "node --experimental-specifier-resolution=node bin/generate.js",
910
"build": "tsc --declaration && rollup -c",
1011
"prepare": "npm run build",
1112
"lint": "prettier --check src/**/* && eslint . && echo '✔ eslint and prettier ran successfully.'",
@@ -33,6 +34,7 @@
3334
"https-browserify": "^1.0.0",
3435
"jest": "^28.1.3",
3536
"jest-environment-puppeteer": "^6.1.1",
37+
"node-fetch": "^3.2.10",
3638
"os-browserify": "^0.3.0",
3739
"path-browserify": "^1.0.1",
3840
"playwright": "^1.25.1",
@@ -52,7 +54,6 @@
5254
"clean-css": "^5.3.1",
5355
"css-tree": "^2.2.1",
5456
"install": "^0.13.0",
55-
"node-fetch": "^2.6.7",
5657
"npm": "^8.18.0"
5758
}
5859
}

rollup.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ export default {
1313
format: 'iife',
1414
name: 'CriticalCSSGenerator',
1515
file: 'dist/bundle.full.js',
16+
globals: {
17+
'node-fetch': 'fetch',
18+
},
1619
},
1720
{
1821
sourcemap: true,
1922
format: 'iife',
2023
name: 'CriticalCSSGenerator',
2124
file: 'dist/bundle.js',
2225
plugins: [ terser() ],
26+
globals: {
27+
'node-fetch': 'fetch',
28+
},
2329
},
2430
],
25-
31+
external: [ 'node-fetch' ],
2632
plugins: [
2733
resolve( { browser: true, preferBuiltins: false } ),
2834
typescript( {

0 commit comments

Comments
 (0)