Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exports are not resolved correctly #92

Closed
1aron opened this issue Jan 26, 2024 · 1 comment
Closed

exports are not resolved correctly #92

1aron opened this issue Jan 26, 2024 · 1 comment

Comments

@1aron
Copy link

1aron commented Jan 26, 2024

As in Case 2 in semantic-release/commit-analyzer#589, import-from-esm does not seem to resolve exports in package.json correctly.

Case 2

It's about my contribution semantic-release/commit-analyzer#588. Perform the following steps on latest master branch:

npm i conventional-changelog-techor@2.5.24 -D

Add the new test/presets.test.js

import test from "ava";
import { stub } from "sinon";
import { analyzeCommits } from "../index.js";

const cwd = process.cwd();

test.beforeEach((t) => {
  const log = stub();
  t.context.log = log;
  t.context.logger = { log };
});

test('Accept "preset" option', async (t) => {
  const commits = [
    { hash: "123", message: "Fix: First fix (fixes #123)" },
    { hash: "456", message: "Update: Second feature (fixes #456)" },
  ];
  const releaseType = await analyzeCommits({ preset: "techor" }, { cwd, commits, logger: t.context.logger });

  t.is(releaseType, null);
});
npm test
> 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 with import-from-esm itself, regardless of whether it is a monorepo or not.

When I change import-from-esm back to import-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.

@sheerlox
Copy link
Owner

import-from-esm does support export maps and has a comprehensive test suite about them (see import-from-esm's tests/e2e.test.js and @insurgent/export-map-test's package.json).

Maybe the issue was caused by an incorrect export map, or more probably by the fact your package was dual-mode (CJS + ESM), which is not explicitly supported by import-from-esm as we haven't encountered any need for it yet.

I see you've removed both the export map and the dual-mode configuration from your package, and I'm guessing this solved your issue. If you're still encountering an issue, please feel free to reopen with more details about what the issue could be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants