node-releases icon indicating copy to clipboard operation
node-releases copied to clipboard

Add a JavaScript module for easier access to data

Open nschonni opened this issue 5 years ago • 3 comments

While looking to implement this for nodejs/i18n, I found myself looking at what Browserlist was doing, and re-implementing it. EX:

const schedule = require(node-releases).schedule // expose the release-schedule.json object
const nodejs = require(node-releases).nodejs// expose the release-schedule.json object

Other useful functions would be to have the functions to just return active releases

nschonni avatar Mar 17 '20 16:03 nschonni

I think that if we want to add JS module, we can do better and pre-generate a flat CJS/ESM modules without the need to require and parse JSON.

chicoxyzzy avatar Mar 18 '20 10:03 chicoxyzzy

I did a placeholder example over in https://github.com/chicoxyzzy/node-releases/pull/21 Did you have an idea on how the generation approach would work?

nschonni avatar Mar 20 '20 03:03 nschonni

fyi, there is also the possibility of using import type assertion cjs is obsolete

import { schedule } from 'node-release/data.json' assert { type: 'json' }

or for the just of simplicity export a esm file

jimmywarting avatar Apr 05 '23 14:04 jimmywarting