Skip to content
Snippets Groups Projects
Unverified Commit 57212ea1 authored by Matthew Clarkson's avatar Matthew Clarkson
Browse files

fix: add ECMAscript module

_Ideally_, we would just want to export it as ECMAscript module.

For now, to support both, we can use a shared JSON file.

It would be nice to use the `import cfg from "./config.js" assert { "json" };` but
that is experimental.
parent 9b4ec84b
No related branches found
No related tags found
No related merge requests found
Pipeline #31860 passed with stages
in 1 minute and 13 seconds
// eslint-disable-next-line unicorn/prefer-module
module.exports = {
branches: [
'+([0-9])?(.{+([0-9]),x}).x',
'stable',
{
name: 'beta',
prerelease: true,
},
{
name: 'alpha',
prerelease: true,
},
],
};
const cfg = require('./config.json');
// eslint-disable-next-line unicorn/prefer-module
module.exports = cfg;
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"stable",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
]
}
// eslint-disable-next-line import/order
import {createRequire} from 'node:module';
const require = createRequire(import.meta.url);
const cfg = require('./config.json');
export default cfg;
......@@ -3,11 +3,14 @@
"version": "0.0.0",
"description": "A `semantic release` configuration for alpha, beta and stable release channels.",
"exports": {
"import": "./config.mjs",
"require": "./config.js"
},
"main": "config.js",
"modules": "config.mjs",
"files": [
"config.js"
"config.js",
"config.mjs"
],
"scripts": {
"lint": "xo",
......
import test from 'ava';
test('Can load the ECMAscript module', async t => {
const {default: {branches}} = await import('../config.mjs');
t.is(branches.length, 4);
});
  • Congregate Migrate @congregate_migrate

    mentioned in commit 492daa45

    By GITLAB_TOKEN on 2023-12-01T22:14:31

    · Imported

    mentioned in commit 492daa45

    By GITLAB_TOKEN on 2023-12-01T22:14:31

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment