From d899e473a9a929fe9a60ddb1bae4c2ec2bcf1815 Mon Sep 17 00:00:00 2001 From: Phil Olson Date: Fri, 1 Dec 2023 13:28:16 -0600 Subject: [PATCH 1/4] support cjs note: esbuild doesn't have a config like most tooling. They suggest instead to use their api. See https://github.com/evanw/esbuild/issues/952#issuecomment-796548330 --- .gitignore | 3 +++ build.js | 20 ++++++++++++++++++++ package.json | 10 ++++++++++ 3 files changed, 33 insertions(+) create mode 100644 build.js diff --git a/.gitignore b/.gitignore index 95855fb..8b34578 100755 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ pnpm-lock.yaml output.json deno.lock + +bundle.cjs +bundle.cjs.map diff --git a/build.js b/build.js new file mode 100644 index 0000000..4829ac8 --- /dev/null +++ b/build.js @@ -0,0 +1,20 @@ +import { build } from 'esbuild' +import fs from 'fs' + +const { dependencies } = JSON.parse(fs.readFileSync('./package.json', 'utf8')) +// we need esbuild to process esm dependencies while leaving cjs compatible ones +// out of the bundle +const esmDependencies = new Set(['bellajs']) +const externalDeps = Object.keys(dependencies) + .filter(dep => !esmDependencies.has(dep)) + +build({ + entryPoints: ['./src/main.js'], + bundle: true, + platform: 'node', + target: 'node16', + outfile: 'bundle.cjs', + minify: true, + sourcemap: true, + external: externalDeps, +}) diff --git a/package.json b/package.json index a16826e..ab979dd 100755 --- a/package.json +++ b/package.json @@ -10,6 +10,14 @@ "author": "@extractus", "main": "./src/main.js", "type": "module", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./src/main.js", + "require": "./bundle.cjs", + "default": "./src/main.js" + } + }, "imports": { "cross-fetch": "./src/deno/cross-fetch.js" }, @@ -23,6 +31,7 @@ "scripts": { "lint": "eslint .", "lint:fix": "eslint --fix .", + "build": "node build", "pretest": "npm run lint", "test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true", "eval": "node eval", @@ -35,6 +44,7 @@ "html-entities": "^2.4.0" }, "devDependencies": { + "esbuild": "^0.19.8", "eslint": "^8.53.0", "https-proxy-agent": "^7.0.2", "jest": "^29.7.0", From 18d9787228671001ce288653e5a6ce81556bc11a Mon Sep 17 00:00:00 2001 From: Phil Olson Date: Fri, 1 Dec 2023 13:34:56 -0600 Subject: [PATCH 2/4] deprecate cjs and add warning similar to vite --- README.md | 7 +++++++ build.js | 2 +- src/cjs-entry.js | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/cjs-entry.js diff --git a/README.md b/README.md index 7b4e668..442e816 100755 --- a/README.md +++ b/README.md @@ -48,6 +48,13 @@ import { extract } from 'https://esm.sh/@extractus/feed-extractor' Please check [the examples](https://github.com/extractus/feed-extractor/tree/main/examples) for reference. +## CJS Deprecated + +CJS is deprecated for this package. When calling `require('@extractus/feed-extractor')` a deprecation warning is now logged. You should update your code to use the ESM export. + +- You can ignore this warning via the environment variable `FEED_EXTRACTOR_CJS_IGNORE_WARNING=true` +- To see where the warning is coming from you can set the environment variable `FEED_EXTRACTOR_CJS_TRACE_WARNING=true` + ## APIs diff --git a/build.js b/build.js index 4829ac8..b917202 100644 --- a/build.js +++ b/build.js @@ -9,7 +9,7 @@ const externalDeps = Object.keys(dependencies) .filter(dep => !esmDependencies.has(dep)) build({ - entryPoints: ['./src/main.js'], + entryPoints: ['./src/cjs-entry.js'], bundle: true, platform: 'node', target: 'node16', diff --git a/src/cjs-entry.js b/src/cjs-entry.js new file mode 100644 index 0000000..e4bba06 --- /dev/null +++ b/src/cjs-entry.js @@ -0,0 +1,14 @@ +function warnCjsUsage () { + if (process.env.FEED_EXTRACTOR_CJS_IGNORE_WARNING?.toLowerCase() === 'true') return + const yellow = (str) => `\u001b[33m${str}\u001b[39m` + const log = process.env.FEED_EXTRACTOR_CJS_TRACE_WARNING?.toLowerCase() === 'true' ? console.trace : console.warn + log( + yellow( + 'The CJS build of @extractus/feed-extractor is deprecated. See https://github.com/extractus/feed-extractor#cjs-deprecated for details.' + ) + ) +} + +warnCjsUsage() + +export * from './main' From fa94d810a96848c6e5b724c6dd367989f575aca2 Mon Sep 17 00:00:00 2001 From: Phil Olson Date: Fri, 1 Dec 2023 18:34:49 -0600 Subject: [PATCH 3/4] add prepublishOnly script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ab979dd..fc229b2 100755 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "lint": "eslint .", "lint:fix": "eslint --fix .", "build": "node build", + "prepublishOnly": "npm run build", "pretest": "npm run lint", "test": "NODE_ENV=test NODE_OPTIONS=--experimental-vm-modules jest --verbose --coverage=true", "eval": "node eval", From 156bae3f1cf4eff333e8af71a3bf1b32502ffe1a Mon Sep 17 00:00:00 2001 From: Dong Nguyen Date: Sat, 2 Dec 2023 14:11:23 +0700 Subject: [PATCH 4/4] v7.0.8 - Merge pr #119 by @olsonpm (issue #118) - Add link to GitHub Action Wrapper by @chriscarrollsmith (issue #114) - Update dependencies, CI settings & examples --- .github/workflows/ci-test.yml | 10 +++++----- .github/workflows/codeql-analysis.yml | 2 +- README.md | 8 ++++++++ examples/bun-feed-reader/package.json | 4 ++-- examples/deno-feed-reader/index.ts | 2 +- examples/tsnode-feed-reader/package.json | 3 ++- examples/tsnode-feed-reader/tsconfig.json | 2 +- package.json | 6 +++--- 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 4d1ae3a..c365bc0 100755 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -8,17 +8,17 @@ on: [push, pull_request] jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: matrix: - node_version: [16.x, 18.x, 20.x] + node_version: [18.x, 20.x, 21.x] steps: - uses: actions/checkout@v3 - name: setup Node.js v${{ matrix.node_version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node_version }} @@ -31,8 +31,8 @@ jobs: npm run build --if-present npm run test - - name: sync to coveralls - uses: coverallsapp/github-action@v1.1.2 + - name: Report Coveralls + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2124bd6..a77d776 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -38,7 +38,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/README.md b/README.md index 442e816..9e51a30 100755 --- a/README.md +++ b/README.md @@ -48,6 +48,14 @@ import { extract } from 'https://esm.sh/@extractus/feed-extractor' Please check [the examples](https://github.com/extractus/feed-extractor/tree/main/examples) for reference. + +## Automate RSS feed extraction with GitHub Actions + +[RSS Feed Fetch Action](https://github.com/Promptly-Technologies-LLC/rss-fetch-action) is a GitHub Action designed to automate the fetching of RSS feeds. +It fetches an RSS feed from a given URL and saves it to a specified file in your GitHub repository. +This action is particularly useful for populating content on GitHub Pages websites or other static site generators. + + ## CJS Deprecated CJS is deprecated for this package. When calling `require('@extractus/feed-extractor')` a deprecation warning is now logged. You should update your code to use the ESM export. diff --git a/examples/bun-feed-reader/package.json b/examples/bun-feed-reader/package.json index a080532..69a8bc2 100644 --- a/examples/bun-feed-reader/package.json +++ b/examples/bun-feed-reader/package.json @@ -5,10 +5,10 @@ "start": "bun run index.ts" }, "devDependencies": { - "bun-types": "^0.6.13" + "bun-types": "^1.0.14" }, "dependencies": { "@extractus/feed-extractor": "latest", - "hono": "^3.2.7" + "hono": "^3.10.2" } } diff --git a/examples/deno-feed-reader/index.ts b/examples/deno-feed-reader/index.ts index 0163087..1307ab0 100644 --- a/examples/deno-feed-reader/index.ts +++ b/examples/deno-feed-reader/index.ts @@ -1,6 +1,6 @@ import { serve } from 'https://deno.land/std/http/server.ts' -import { Hono } from 'https://deno.land/x/hono@v3.2.7/mod.ts' +import { Hono } from 'https://deno.land/x/hono@v3.10.2/mod.ts' import { extract } from 'npm:@extractus/feed-extractor' diff --git a/examples/tsnode-feed-reader/package.json b/examples/tsnode-feed-reader/package.json index 1fcefa1..696676d 100644 --- a/examples/tsnode-feed-reader/package.json +++ b/examples/tsnode-feed-reader/package.json @@ -1,13 +1,14 @@ { "name": "tsnode-feed-reader", "version": "1.0.0", + "type": "module", "main": "index.ts", "scripts": { "prestart": "npx tsc", "start": "node dist/index.js" }, "devDependencies": { - "typescript": "^5.1.6" + "typescript": "^5.3.2" }, "dependencies": { "@extractus/feed-extractor": "latest", diff --git a/examples/tsnode-feed-reader/tsconfig.json b/examples/tsnode-feed-reader/tsconfig.json index d58a717..d592c17 100644 --- a/examples/tsnode-feed-reader/tsconfig.json +++ b/examples/tsnode-feed-reader/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "commonjs", + "module": "es6", "esModuleInterop": true, "target": "es6", "moduleResolution": "node", diff --git a/package.json b/package.json index fc229b2..95f6588 100755 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "7.0.7", + "version": "7.0.8", "name": "@extractus/feed-extractor", "description": "To read and normalize RSS/ATOM/JSON feed data", "homepage": "https://extractor-demos.pages.dev", @@ -46,10 +46,10 @@ }, "devDependencies": { "esbuild": "^0.19.8", - "eslint": "^8.53.0", + "eslint": "^8.55.0", "https-proxy-agent": "^7.0.2", "jest": "^29.7.0", - "nock": "^13.3.8" + "nock": "^13.4.0" }, "keywords": [ "extractor",