- Notifications
You must be signed in to change notification settings - Fork81
Description
Everything worked fine before v11.1; since@sheerlox introduces theimport-from-esm#537, and it's behavior became unreliable.
To reproduce
This error occurs in both cases.
Case 1
Clone my repo and run the test
git clone https://github.com/1aron/techor.gitcd techorpnpm ipnpm buildcd packages/semantic-release-configpnpmtest
> semantic-release-config-techor@test /Users/aron/techor/packages/semantic-release-config> jest FAIL tests/rules.test.ts ● Parse with"conventional-changelog-techor" by default Cannot find module'conventional-changelog-techor' 11|'Feat(Scope2): Second feature' 12| )> 13| const releaseType = await analyzeCommits(| ^ 14| { preset:'techor', releaseRules }, 15| { cwd:process.cwd(), commits, logger: console } 16| ) at importFrom (../../node_modules/.pnpm/import-from-esm@1.3.3/node_modules/import-from-esm/index.js:100:17) at async _default (../../node_modules/.pnpm/@semantic-release+commit-analyzer@11.1.0_semantic-release@23.0.0/node_modules/@semantic-release/commit-analyzer/lib/load-parser-config.js:25:63) at async analyzeCommits (../../node_modules/.pnpm/@semantic-release+commit-analyzer@11.1.0_semantic-release@23.0.0/node_modules/@semantic-release/commit-analyzer/index.js:31:18) at async Object.<anonymous> (tests/rules.test.ts:13:25)
The reproductions above are all in the same monorepo, I think this is not entirely a bug caused by the monorepo, but caused byimport-from being changed toimport-from-esm.
conventional-changelog-techor is thepackages/conventional-changelog-config in the monorepo. This error is not caused by its own error, even if you useconventional-changelog-angular instead and specifypreset 'angular'.
The current version has not been changed to asynchronous function configuration, but this is not relevant.
Case 2
It's about my contribution#588. Perform the following steps on latest master branch:
npm i conventional-changelog-techor@2.5.24 -D
Add the newtest/presets.test.js
importtestfrom"ava";import{stub}from"sinon";import{analyzeCommits}from"../index.js";constcwd=process.cwd();test.beforeEach((t)=>{constlog=stub();t.context.log=log;t.context.logger={ log};});test('Accept "preset" option',async(t)=>{constcommits=[{hash:"123",message:"Fix: First fix (fixes #123)"},{hash:"456",message:"Update: Second feature (fixes #456)"},];constreleaseType=awaitanalyzeCommits({preset:"techor"},{ cwd, commits,logger:t.context.logger});t.is(releaseType,null);});
npmtest> Cannot find module'conventional-changelog-techor'
If I remove the"exports": { ... }" section from "node_modules/conventional-changelog-techor/package.json", it will work.
So this is a problem withimport-from-esm itself, regardless of whether it is a monorepo or not.
When I changeimport-from-esm back toimport-from everything still works. This means that the changes in v11.1 did not include tests for the new functionality (#537), and these tests would have failed before v11.1. Changes add a lot of uncertainty.
Suggestion
Reverts: