From 624f6b2e02009b9e9859b10a5a675cb9c564109d Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 2 Jun 2021 19:59:34 -0400 Subject: [PATCH 1/2] Switch to tsup for bundling Signed-off-by: Andrew Welch --- config/base.json | 18 --- config/cjs.json | 7 -- config/esm.json | 7 -- config/types.json | 8 -- dist/cjs/index.js | 71 ----------- dist/esm/index.js | 66 ---------- dist/index.js | 61 +++++++++ dist/index.js.map | 7 ++ dist/index.mjs | 61 +++++++++ dist/index.mjs.map | 7 ++ package-lock.json | 279 ++++++++++++++++++++++++++++++++++++----- package.json | 13 +- rollup.types.config.js | 13 -- 13 files changed, 392 insertions(+), 226 deletions(-) delete mode 100644 config/base.json delete mode 100644 config/cjs.json delete mode 100644 config/esm.json delete mode 100644 config/types.json delete mode 100644 dist/cjs/index.js delete mode 100644 dist/esm/index.js create mode 100644 dist/index.js create mode 100644 dist/index.js.map create mode 100644 dist/index.mjs create mode 100644 dist/index.mjs.map delete mode 100644 rollup.types.config.js diff --git a/config/base.json b/config/base.json deleted file mode 100644 index 92c8123..0000000 --- a/config/base.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "moduleResolution": "node", - "sourceMap": false, - "strict": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "newLine": "lf", - "esModuleInterop": true - }, - "include": [ - "../src" - ], - "exclude": [ - "../src/__tests__" - ] -} diff --git a/config/cjs.json b/config/cjs.json deleted file mode 100644 index b063b2b..0000000 --- a/config/cjs.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./base", - "compilerOptions": { - "module": "commonjs", - "outDir": "../dist/cjs" - } -} diff --git a/config/esm.json b/config/esm.json deleted file mode 100644 index 386e579..0000000 --- a/config/esm.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "./base", - "compilerOptions": { - "module": "es6", - "outDir": "../dist/esm" - } -} diff --git a/config/types.json b/config/types.json deleted file mode 100644 index 1286cde..0000000 --- a/config/types.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./base", - "compilerOptions": { - "declaration": true, - "emitDeclarationOnly": true, - "outDir": "../dist" - } -} diff --git a/dist/cjs/index.js b/dist/cjs/index.js deleted file mode 100644 index 992a083..0000000 --- a/dist/cjs/index.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const path_1 = __importDefault(require("path")); -const critical = require('critical'); -const criticalSuffix = '_critical.min.css'; -/** - * Default `criticalConfig` passed in to `critical` - */ -const defaultCriticalConfig = { - inline: false, - minify: true, - extract: false, - width: 1200, - height: 1200, - penthouse: { - blockJSRequests: false - } -}; -/** - * [Vite.js](https://vitejs.dev/) & [Rollup](https://rollupjs.org/) plugin for generating critical CSS - * that uses the [critical](https://github.com/addyosmani/critical) generator under the hood. - * - * @param {CriticalPluginConfig} pluginConfig - the plugin configuration object - * @param {Function} callback - callback upon completion of the critical CSS generation - * @constructor - */ -function PluginCritical(pluginConfig, callback) { - return { - name: 'critical', - async writeBundle(outputOptions, bundle) { - const css = []; - // Find all of the generated CSS assets - for (const chunk of Object.values(bundle)) { - if (chunk.type === 'asset' && chunk.fileName.endsWith('.css')) { - const cssFile = path_1.default.join(outputOptions.dir || '', chunk.fileName); - css.push(cssFile); - } - } - // If we have no CSS, skip bundle - if (!css.length) { - return; - } - // Iterate through the pages - for (const page of pluginConfig.criticalPages) { - const criticalBase = pluginConfig.criticalBase; - const criticalSrc = pluginConfig.criticalUrl + page.uri; - const criticalDest = page.template + criticalSuffix; - // Merge in our options - const options = Object.assign({ css }, defaultCriticalConfig, { - base: criticalBase, - src: criticalSrc, - target: criticalDest, - }, pluginConfig.criticalConfig); - // Generate the Critical CSS - console.log(`Generating critical CSS from ${criticalSrc} to ${criticalDest}`); - await critical.generate(options, (err) => { - if (err) { - console.error(err); - } - if (callback) { - callback(err); - } - }); - } - } - }; -} -exports.default = PluginCritical; diff --git a/dist/esm/index.js b/dist/esm/index.js deleted file mode 100644 index c4c9d59..0000000 --- a/dist/esm/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import path from 'path'; -const critical = require('critical'); -const criticalSuffix = '_critical.min.css'; -/** - * Default `criticalConfig` passed in to `critical` - */ -const defaultCriticalConfig = { - inline: false, - minify: true, - extract: false, - width: 1200, - height: 1200, - penthouse: { - blockJSRequests: false - } -}; -/** - * [Vite.js](https://vitejs.dev/) & [Rollup](https://rollupjs.org/) plugin for generating critical CSS - * that uses the [critical](https://github.com/addyosmani/critical) generator under the hood. - * - * @param {CriticalPluginConfig} pluginConfig - the plugin configuration object - * @param {Function} callback - callback upon completion of the critical CSS generation - * @constructor - */ -function PluginCritical(pluginConfig, callback) { - return { - name: 'critical', - async writeBundle(outputOptions, bundle) { - const css = []; - // Find all of the generated CSS assets - for (const chunk of Object.values(bundle)) { - if (chunk.type === 'asset' && chunk.fileName.endsWith('.css')) { - const cssFile = path.join(outputOptions.dir || '', chunk.fileName); - css.push(cssFile); - } - } - // If we have no CSS, skip bundle - if (!css.length) { - return; - } - // Iterate through the pages - for (const page of pluginConfig.criticalPages) { - const criticalBase = pluginConfig.criticalBase; - const criticalSrc = pluginConfig.criticalUrl + page.uri; - const criticalDest = page.template + criticalSuffix; - // Merge in our options - const options = Object.assign({ css }, defaultCriticalConfig, { - base: criticalBase, - src: criticalSrc, - target: criticalDest, - }, pluginConfig.criticalConfig); - // Generate the Critical CSS - console.log(`Generating critical CSS from ${criticalSrc} to ${criticalDest}`); - await critical.generate(options, (err) => { - if (err) { - console.error(err); - } - if (callback) { - callback(err); - } - }); - } - } - }; -} -export default PluginCritical; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..f07cbf6 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,61 @@ +"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __require = (x) => { + if (typeof require !== "undefined") + return require(x); + throw new Error('Dynamic require of "' + x + '" is not supported'); +}; + +// src/index.ts +var _path = require('path'); var _path2 = _interopRequireDefault(_path); +var critical = __require("critical"); +var criticalSuffix = "_critical.min.css"; +var defaultCriticalConfig = { + inline: false, + minify: true, + extract: false, + width: 1200, + height: 1200, + penthouse: { + blockJSRequests: false + } +}; +function PluginCritical(pluginConfig, callback) { + return { + name: "critical", + async writeBundle(outputOptions, bundle) { + const css = []; + for (const chunk of Object.values(bundle)) { + if (chunk.type === "asset" && chunk.fileName.endsWith(".css")) { + const cssFile = _path2.default.join(outputOptions.dir || "", chunk.fileName); + css.push(cssFile); + } + } + if (!css.length) { + return; + } + for (const page of pluginConfig.criticalPages) { + const criticalBase = pluginConfig.criticalBase; + const criticalSrc = pluginConfig.criticalUrl + page.uri; + const criticalDest = page.template + criticalSuffix; + const options = Object.assign({css}, defaultCriticalConfig, { + base: criticalBase, + src: criticalSrc, + target: criticalDest + }, pluginConfig.criticalConfig); + console.log(`Generating critical CSS from ${criticalSrc} to ${criticalDest}`); + await critical.generate(options, (err) => { + if (err) { + console.error(err); + } + if (callback) { + callback(err); + } + }); + } + } + }; +} +var src_default = PluginCritical; + + +exports.default = src_default; +//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map new file mode 100644 index 0000000..3c508ff --- /dev/null +++ b/dist/index.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../src/index.ts"], + "sourcesContent": ["import {Plugin} from 'rollup';\nimport path from 'path';\nimport { CriticalConfig } from './@types/critical';\nimport { CriticalPluginConfig } from './@types/rollup-plugin-critical';\nconst critical = require('critical');\n\nconst criticalSuffix = '_critical.min.css';\n\n/**\n * Default `criticalConfig` passed in to `critical`\n */\nconst defaultCriticalConfig: Partial = {\n inline: false,\n minify: true,\n extract: false,\n width: 1200,\n height: 1200,\n penthouse: {\n blockJSRequests: false\n }\n};\n\n/**\n * [Vite.js](https://vitejs.dev/) & [Rollup](https://rollupjs.org/) plugin for generating critical CSS\n * that uses the [critical](https://github.com/addyosmani/critical) generator under the hood.\n *\n * @param {CriticalPluginConfig} pluginConfig - the plugin configuration object\n * @param {Function} callback - callback upon completion of the critical CSS generation\n * @constructor\n */\nfunction PluginCritical(pluginConfig: CriticalPluginConfig, callback?: Function): Plugin {\n return {\n name: 'critical',\n async writeBundle(outputOptions, bundle) {\n const css: Array = [];\n // Find all of the generated CSS assets\n for (const chunk of Object.values(bundle)) {\n if (chunk.type === 'asset' && chunk.fileName.endsWith('.css')) {\n const cssFile = path.join(outputOptions.dir || '', chunk.fileName);\n css.push(cssFile);\n }\n }\n // If we have no CSS, skip bundle\n if (!css.length) {\n return;\n }\n // Iterate through the pages\n for (const page of pluginConfig.criticalPages) {\n const criticalBase = pluginConfig.criticalBase;\n const criticalSrc = pluginConfig.criticalUrl + page.uri;\n const criticalDest = page.template + criticalSuffix;\n // Merge in our options\n const options = Object.assign(\n { css },\n defaultCriticalConfig,\n {\n base: criticalBase,\n src: criticalSrc,\n target: criticalDest,\n },\n pluginConfig.criticalConfig\n );\n // Generate the Critical CSS\n console.log(`Generating critical CSS from ${criticalSrc} to ${criticalDest}`);\n await critical.generate(options, (err: string) => {\n if (err) {\n console.error(err);\n }\n if (callback) {\n callback(err);\n }\n });\n }\n }\n }\n}\n\nexport default PluginCritical;\n"], + "mappings": ";;;;;;;AACA;AAGA,IAAM,WAAW,UAAQ;AAEzB,IAAM,iBAAiB;AAKvB,IAAM,wBAAiD;AAAA,EACrD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,IACT,iBAAiB;AAAA;AAAA;AAYrB,wBAAwB,cAAoC,UAA6B;AACvF,SAAO;AAAA,IACL,MAAM;AAAA,UACA,YAAY,eAAe,QAAQ;AACvC,YAAM,MAAqB;AAE3B,iBAAW,SAAS,OAAO,OAAO,SAAS;AACzC,YAAI,MAAM,SAAS,WAAW,MAAM,SAAS,SAAS,SAAS;AAC7D,gBAAM,UAAU,KAAK,KAAK,cAAc,OAAO,IAAI,MAAM;AACzD,cAAI,KAAK;AAAA;AAAA;AAIb,UAAI,CAAC,IAAI,QAAQ;AACf;AAAA;AAGF,iBAAW,QAAQ,aAAa,eAAe;AAC7C,cAAM,eAAe,aAAa;AAClC,cAAM,cAAc,aAAa,cAAc,KAAK;AACpD,cAAM,eAAe,KAAK,WAAW;AAErC,cAAM,UAAU,OAAO,OACnB,CAAE,MACF,uBACA;AAAA,UACE,MAAM;AAAA,UACN,KAAK;AAAA,UACL,QAAQ;AAAA,WAEV,aAAa;AAGjB,gBAAQ,IAAI,gCAAgC,kBAAkB;AAC9D,cAAM,SAAS,SAAS,SAAS,CAAC,QAAgB;AAChD,cAAI,KAAK;AACP,oBAAQ,MAAM;AAAA;AAEhB,cAAI,UAAU;AACZ,qBAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrB,IAAO,cAAQ;", + "names": [] +} diff --git a/dist/index.mjs b/dist/index.mjs new file mode 100644 index 0000000..1f56f5e --- /dev/null +++ b/dist/index.mjs @@ -0,0 +1,61 @@ +var __require = (x) => { + if (typeof require !== "undefined") + return require(x); + throw new Error('Dynamic require of "' + x + '" is not supported'); +}; + +// src/index.ts +import path from "path"; +var critical = __require("critical"); +var criticalSuffix = "_critical.min.css"; +var defaultCriticalConfig = { + inline: false, + minify: true, + extract: false, + width: 1200, + height: 1200, + penthouse: { + blockJSRequests: false + } +}; +function PluginCritical(pluginConfig, callback) { + return { + name: "critical", + async writeBundle(outputOptions, bundle) { + const css = []; + for (const chunk of Object.values(bundle)) { + if (chunk.type === "asset" && chunk.fileName.endsWith(".css")) { + const cssFile = path.join(outputOptions.dir || "", chunk.fileName); + css.push(cssFile); + } + } + if (!css.length) { + return; + } + for (const page of pluginConfig.criticalPages) { + const criticalBase = pluginConfig.criticalBase; + const criticalSrc = pluginConfig.criticalUrl + page.uri; + const criticalDest = page.template + criticalSuffix; + const options = Object.assign({css}, defaultCriticalConfig, { + base: criticalBase, + src: criticalSrc, + target: criticalDest + }, pluginConfig.criticalConfig); + console.log(`Generating critical CSS from ${criticalSrc} to ${criticalDest}`); + await critical.generate(options, (err) => { + if (err) { + console.error(err); + } + if (callback) { + callback(err); + } + }); + } + } + }; +} +var src_default = PluginCritical; +export { + src_default as default +}; +//# sourceMappingURL=index.mjs.map diff --git a/dist/index.mjs.map b/dist/index.mjs.map new file mode 100644 index 0000000..3c508ff --- /dev/null +++ b/dist/index.mjs.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../src/index.ts"], + "sourcesContent": ["import {Plugin} from 'rollup';\nimport path from 'path';\nimport { CriticalConfig } from './@types/critical';\nimport { CriticalPluginConfig } from './@types/rollup-plugin-critical';\nconst critical = require('critical');\n\nconst criticalSuffix = '_critical.min.css';\n\n/**\n * Default `criticalConfig` passed in to `critical`\n */\nconst defaultCriticalConfig: Partial = {\n inline: false,\n minify: true,\n extract: false,\n width: 1200,\n height: 1200,\n penthouse: {\n blockJSRequests: false\n }\n};\n\n/**\n * [Vite.js](https://vitejs.dev/) & [Rollup](https://rollupjs.org/) plugin for generating critical CSS\n * that uses the [critical](https://github.com/addyosmani/critical) generator under the hood.\n *\n * @param {CriticalPluginConfig} pluginConfig - the plugin configuration object\n * @param {Function} callback - callback upon completion of the critical CSS generation\n * @constructor\n */\nfunction PluginCritical(pluginConfig: CriticalPluginConfig, callback?: Function): Plugin {\n return {\n name: 'critical',\n async writeBundle(outputOptions, bundle) {\n const css: Array = [];\n // Find all of the generated CSS assets\n for (const chunk of Object.values(bundle)) {\n if (chunk.type === 'asset' && chunk.fileName.endsWith('.css')) {\n const cssFile = path.join(outputOptions.dir || '', chunk.fileName);\n css.push(cssFile);\n }\n }\n // If we have no CSS, skip bundle\n if (!css.length) {\n return;\n }\n // Iterate through the pages\n for (const page of pluginConfig.criticalPages) {\n const criticalBase = pluginConfig.criticalBase;\n const criticalSrc = pluginConfig.criticalUrl + page.uri;\n const criticalDest = page.template + criticalSuffix;\n // Merge in our options\n const options = Object.assign(\n { css },\n defaultCriticalConfig,\n {\n base: criticalBase,\n src: criticalSrc,\n target: criticalDest,\n },\n pluginConfig.criticalConfig\n );\n // Generate the Critical CSS\n console.log(`Generating critical CSS from ${criticalSrc} to ${criticalDest}`);\n await critical.generate(options, (err: string) => {\n if (err) {\n console.error(err);\n }\n if (callback) {\n callback(err);\n }\n });\n }\n }\n }\n}\n\nexport default PluginCritical;\n"], + "mappings": ";;;;;;;AACA;AAGA,IAAM,WAAW,UAAQ;AAEzB,IAAM,iBAAiB;AAKvB,IAAM,wBAAiD;AAAA,EACrD,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,WAAW;AAAA,IACT,iBAAiB;AAAA;AAAA;AAYrB,wBAAwB,cAAoC,UAA6B;AACvF,SAAO;AAAA,IACL,MAAM;AAAA,UACA,YAAY,eAAe,QAAQ;AACvC,YAAM,MAAqB;AAE3B,iBAAW,SAAS,OAAO,OAAO,SAAS;AACzC,YAAI,MAAM,SAAS,WAAW,MAAM,SAAS,SAAS,SAAS;AAC7D,gBAAM,UAAU,KAAK,KAAK,cAAc,OAAO,IAAI,MAAM;AACzD,cAAI,KAAK;AAAA;AAAA;AAIb,UAAI,CAAC,IAAI,QAAQ;AACf;AAAA;AAGF,iBAAW,QAAQ,aAAa,eAAe;AAC7C,cAAM,eAAe,aAAa;AAClC,cAAM,cAAc,aAAa,cAAc,KAAK;AACpD,cAAM,eAAe,KAAK,WAAW;AAErC,cAAM,UAAU,OAAO,OACnB,CAAE,MACF,uBACA;AAAA,UACE,MAAM;AAAA,UACN,KAAK;AAAA,UACL,QAAQ;AAAA,WAEV,aAAa;AAGjB,gBAAQ,IAAI,gCAAgC,kBAAkB;AAC9D,cAAM,SAAS,SAAS,SAAS,CAAC,QAAgB;AAChD,cAAI,KAAK;AACP,oBAAQ,MAAM;AAAA;AAEhB,cAAI,UAAU;AACZ,qBAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQrB,IAAO,cAAQ;", + "names": [] +} diff --git a/package-lock.json b/package-lock.json index 03b8405..5881038 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1110,9 +1110,9 @@ "integrity": "sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==" }, "@types/node": { - "version": "14.17.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.1.tgz", - "integrity": "sha512-/tpUyFD7meeooTRwl3sYlihx2BrJE7q9XF71EguPFIySj9B7qgnRtHsHTho+0AUm4m1SvWGm6uSncrR94q6Vtw==", + "version": "14.17.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.2.tgz", + "integrity": "sha512-sld7b/xmFum66AAKuz/rp/CUO8+98fMpyQ3SBfzzBNGMd/1iHBTAg9oyAvcYlAj46bpc74r91jSw2iFdnx29nw==", "dev": true }, "@types/normalize-package-data": { @@ -1120,6 +1120,12 @@ "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==" }, + "@types/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", + "dev": true + }, "@types/prettier": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.2.3.tgz", @@ -1259,6 +1265,12 @@ "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=" }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=", + "dev": true + }, "anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -1485,6 +1497,12 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true + }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -1553,6 +1571,12 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, + "cac": { + "version": "6.7.3", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.3.tgz", + "integrity": "sha512-ECVqVZh74qgSuZG9YOt2OJPI3wGcf+EwwuF/XIOYqZBD0KZYLtgPWqFPxmDPQ6joxI1nOlvVgRV6VT53Ooyocg==", + "dev": true + }, "cacheable-lookup": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", @@ -1653,6 +1677,22 @@ "lodash.some": "^4.4.0" } }, + "chokidar": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.1.tgz", + "integrity": "sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==", + "dev": true, + "requires": { + "anymatch": "~3.1.1", + "braces": "~3.0.2", + "fsevents": "~2.3.1", + "glob-parent": "~5.1.0", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.5.0" + } + }, "ci-info": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.2.0.tgz", @@ -1845,6 +1885,12 @@ "delayed-stream": "~1.0.0" } }, + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true + }, "common-tags": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz", @@ -1917,6 +1963,19 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cosmiconfig": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.0.0.tgz", + "integrity": "sha512-pondGvTuVYDk++upghXJabWzL6Kxu6f26ljFw64Swq9v6sQPUL3EUlVDV56diOjpCayKihL6hVe8exIACU4XcA==", + "dev": true, + "requires": { + "@types/parse-json": "^4.0.0", + "import-fresh": "^3.2.1", + "parse-json": "^5.0.0", + "path-type": "^4.0.0", + "yaml": "^1.10.0" + } + }, "critical": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/critical/-/critical-3.1.0.tgz", @@ -2350,6 +2409,12 @@ "is-symbol": "^1.0.2" } }, + "esbuild": { + "version": "0.11.23", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.23.tgz", + "integrity": "sha512-iaiZZ9vUF5wJV8ob1tl+5aJTrwDczlvGP0JoMmnpC2B0ppiMCu8n8gmy5ZTGl5bcG081XBVn+U+jP+mPFm5T5Q==", + "dev": true + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -2835,6 +2900,42 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==" }, + "import-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-cwd/-/import-cwd-3.0.0.tgz", + "integrity": "sha512-4pnzH16plW+hgvRECbDWpQl3cqtvSofHWh44met7ESfZ8UZOWWddm8hEyDTqREJ9RbYHY8gi8DqmaelApoOGMg==", + "dev": true, + "requires": { + "import-from": "^3.0.0" + } + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "dependencies": { + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + } + } + }, + "import-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-from/-/import-from-3.0.0.tgz", + "integrity": "sha512-CiuXOFFSzkU5x/CR0+z7T91Iht4CXgfCxVOFRhh2Zyhg5wOpWvvDLQUsWl+gcN+QscYBjez8hDCt85O7RLDttQ==", + "dev": true, + "requires": { + "resolve-from": "^5.0.0" + } + }, "import-local": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.2.tgz", @@ -3001,6 +3102,15 @@ "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.2.tgz", "integrity": "sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA==" }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "requires": { + "binary-extensions": "^2.0.0" + } + }, "is-boolean-object": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.1.tgz", @@ -4447,6 +4557,12 @@ "@sideway/pinpoint": "^2.0.0" } }, + "joycon": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.0.1.tgz", + "integrity": "sha512-SJcJNBg32dGgxhPtM0wQqxqV0ax9k/9TaUskGDSJkSFSQOEWWvQ3zzWdGQRIUry2j1zA5+ReH13t0Mf3StuVZA==", + "dev": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4664,15 +4780,6 @@ "yallist": "^4.0.0" } }, - "magic-string": { - "version": "0.25.7", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", - "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", - "dev": true, - "requires": { - "sourcemap-codec": "^1.4.4" - } - }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -4822,6 +4929,17 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "requires": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "nanoid": { "version": "3.1.23", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", @@ -4899,6 +5017,12 @@ "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==" }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-inspect": { "version": "1.10.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", @@ -5027,6 +5151,15 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -5269,6 +5402,16 @@ } } }, + "postcss-load-config": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.0.1.tgz", + "integrity": "sha512-/pDHe30UYZUD11IeG8GWx9lNtu1ToyTsZHnyy45B4Mrwr/Kb6NgYl7k753+05CJNKnjbwh4975amoPJ+TEjHNQ==", + "dev": true, + "requires": { + "cosmiconfig": "^7.0.0", + "import-cwd": "^3.0.0" + } + }, "postcss-url": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/postcss-url/-/postcss-url-10.1.3.tgz", @@ -5507,6 +5650,15 @@ "util-deprecate": "^1.0.1" } }, + "readdirp": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.5.0.tgz", + "integrity": "sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, "reaver": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/reaver/-/reaver-2.0.0.tgz", @@ -5599,16 +5751,6 @@ "fsevents": "~2.3.1" } }, - "rollup-plugin-dts": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-3.0.2.tgz", - "integrity": "sha512-hswlsdWu/x7k5pXzaLP6OvKRKcx8Bzprksz9i9mUe72zvt8LvqAb/AZpzs6FkLgmyRaN8B6rUQOVtzA3yEt9Yw==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "magic-string": "^0.25.7" - } - }, "run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -5709,12 +5851,6 @@ "source-map": "^0.6.0" } }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, "spdx-correct": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", @@ -5846,6 +5982,36 @@ "min-indent": "^1.0.0" } }, + "sucrase": { + "version": "3.18.1", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.18.1.tgz", + "integrity": "sha512-TRyO38wwOPhLLlM8QLOG3TgMj0FKk+arlTrS9pRAanF8cAcHvgRPKIYWGO25mPSp/Rj87zMMTjFfkqIZGI6ZdA==", + "dev": true, + "requires": { + "commander": "^4.0.0", + "glob": "7.1.6", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -6019,6 +6185,24 @@ "minimatch": "^3.0.4" } }, + "thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "requires": { + "any-promise": "^1.0.0" + } + }, + "thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", + "dev": true, + "requires": { + "thenify": ">= 3.1.0 < 4" + } + }, "throat": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/throat/-/throat-6.0.1.tgz", @@ -6071,11 +6255,23 @@ "punycode": "^2.1.1" } }, + "tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true + }, "trim-newlines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==" }, + "ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true + }, "ts-jest": { "version": "27.0.2", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-27.0.2.tgz", @@ -6102,6 +6298,27 @@ } } }, + "tsup": { + "version": "4.11.2", + "resolved": "https://registry.npmjs.org/tsup/-/tsup-4.11.2.tgz", + "integrity": "sha512-cp+gy0TGzFm/3PkPNeiZ2Fvi4MKI8jj6Xq6gVpSQ+Og+6GPqfws2K4zYo11OJoccuk2LnlJIJt8xwnoYCVGpSA==", + "dev": true, + "requires": { + "cac": "^6.7.2", + "chalk": "^4.1.0", + "chokidar": "^3.5.1", + "debug": "^4.3.1", + "esbuild": "^0.11.12", + "execa": "^5.0.0", + "globby": "^11.0.3", + "joycon": "^3.0.1", + "postcss-load-config": "^3.0.1", + "resolve-from": "^5.0.0", + "rollup": "^2.45.2", + "sucrase": "^3.18.1", + "tree-kill": "^1.2.2" + } + }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", @@ -6380,6 +6597,12 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index 209d279..e19cdab 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "bugs": { "url": "https://github.com/nystudio107/rollup-plugin-critical/issues" }, - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", + "main": "dist/index.js", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "files": [ "dist", @@ -27,10 +27,7 @@ "README.md" ], "scripts": { - "build": "npm run build:cjs && npm run build:esm && npm run build:types", - "build:cjs": "tsc -p config/cjs.json", - "build:esm": "tsc -p config/esm.json", - "build:types": "rollup --config ./rollup.types.config.js", + "build": "tsup src/index.ts --sourcemap --dts --format cjs,esm", "check": "tsc -p config/base.json --noEmit", "lint": "eslint -p .", "test": "jest --passWithNoTests --coverage" @@ -40,11 +37,11 @@ }, "devDependencies": { "@types/jest": "^26.0.23", - "@types/node": "^14.6.0", + "@types/node": "^14.17.2", "jest": "^27.0.3", "rollup": "^2.50.5", - "rollup-plugin-dts": "^3.0.2", "ts-jest": "^27.0.2", + "tsup": "^4.10.1", "typescript": "latest" }, "peerDependencies": { diff --git a/rollup.types.config.js b/rollup.types.config.js deleted file mode 100644 index e22e9f3..0000000 --- a/rollup.types.config.js +++ /dev/null @@ -1,13 +0,0 @@ -import dts from 'rollup-plugin-dts'; - -/** - * @type [import('rollup').RollupOptions] - */ -export default { - input: './src/index.ts', - plugins: [dts()], - output: { - file: './dist/index.d.ts', - format: 'es', - }, -} From b3f7dad1fe563d4ba3a889127ff53b11199fad7e Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 2 Jun 2021 20:00:29 -0400 Subject: [PATCH 2/2] Version 1.0.7 Signed-off-by: Andrew Welch --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64eb8f3..b140548 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 1.0.7 - 2021-06-02 +### Changed +* Switched to `tsup` for bundling + ## 1.0.6 - 2021-06-01 ### Fixed * Fixed build of `dist/index.d.ts` to have the correct default export by sourcing `index.ts` diff --git a/package.json b/package.json index e19cdab..70355f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup-plugin-critical", - "version": "1.0.6", + "version": "1.0.7", "description": "Rollup plugin to generate critical CSS.", "author": "nystudio107", "license": "MIT",