conventional-changelog/conventional-changelog

When the release of features `CommonJS` to `ESM` of packages?

silversonicaxel opened this issue · 5 comments

Currently I am using https://github.com/release-it/conventional-changelog, package based on https://github.com/conventional-changelog/conventional-changelog.

Right now there is an issue release-it/conventional-changelog#70 with this following configuration, using the conventional-changelog-angular package:

plugins:
  '@release-it/conventional-changelog':
    preset:
      name: angular

This is happening because of the following code of conventional-changelog-preset-loader package (ALREADY RELEASED) receives a pending promise instead of a function:

file: https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-preset-loader/index.js
line:

if (typeof createPreset !== 'function') {

    if (typeof createPreset !== 'function') {
      throw Error(`The "${preset}" preset does not export a function. Maybe you are using an old version of the preset. Please upgrade.`)
    }

Due to the fact that in the previous (CURRENTLY LATEST RELEASE) file of conventional-changelog-angular package:

diffs: 8d0ffbe#diff-acf5b7cb6bc405bab489c4f7fe85e470ee06ef2774434a4ee9332d21eb92c88d

'use strict'
const conventionalChangelog = require('./conventional-changelog')
const parserOpts = require('./parser-opts')
const recommendedBumpOpts = require('./conventional-recommended-bump')
const writerOpts = require('./writer-opts')

module.exports = Promise.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts])
  .then(([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]) => ({
    conventionalChangelog,
    parserOpts,
    recommendedBumpOpts,
    writerOpts
  }))

the code was returning a promise, but in the new main file (NOT YET RELEASED) of conventional-changelog-angular package the problem is fixed.

file: https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-angular/index.js

'use strict'

const { createParserOpts } = require('./parserOpts')
const { createWriterOpts } = require('./writerOpts')
const { createConventionalChangelogOpts } = require('./conventionalChangelog')
const { createConventionalRecommendedBumpOpts } = require('./conventionalRecommendedBump')

async function createPreset () {
  const parserOpts = createParserOpts()
  const writerOpts = await createWriterOpts()
  const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts)
  const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts)

  return {
    parserOpts,
    writerOpts,
    recommendedBumpOpts,
    conventionalChangelog
  }
}

module.exports = createPreset

So, when will be done a release of the new CommonJS to ESM packages?

PR welcome!

@silversonicaxel Hi

(CURRENTLY LATEST RELEASE) file of conventional-changelog-angular package:

Currently latest release of conventional-changelog-angular have correct export of factory function:

https://unpkg.com/browse/conventional-changelog-angular@7.0.0/index.js

Feeling is that problem comes from this file, where there is an old depencency of conventional-changelog-angular: https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/parse/package.json

This is the package-lock.json of my project:

    "node_modules/@commitlint/parse": {
      "version": "17.7.0",
      "resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-17.7.0.tgz",
      "integrity": "sha512-dIvFNUMCUHqq5Abv80mIEjLVfw8QNuA4DS7OWip4pcK/3h5wggmjVnlwGCDvDChkw2TjK1K6O+tAEV78oxjxag==",
      "dev": true,
      "dependencies": {
        "@commitlint/types": "^17.4.4",
        "conventional-changelog-angular": "^6.0.0",
        "conventional-commits-parser": "^4.0.0"
      },
      "engines": {
        "node": ">=v14"
      }
    },

I guess until this is not upgraded, the issue will be there in projects containing multiple packages, like my case

    "@commitlint/cli": "^17.8.0",
    "@commitlint/config-conventional": "^17.8.0",
    "@commitlint/cz-commitlint": "^17.8.0",
    "@commitlint/types": "^17.4.4",

@silversonicaxel You should create issue in conventional-changelog/commitlint about that.