Skip to content

feat(mama): implement moduleType getter along with inspectModuleType fn#397

Merged
fraxken merged 1 commit into
masterfrom
mama-module-scan
May 26, 2025
Merged

feat(mama): implement moduleType getter along with inspectModuleType fn#397
fraxken merged 1 commit into
masterfrom
mama-module-scan

Conversation

@fraxken
Copy link
Copy Markdown
Member

@fraxken fraxken commented May 26, 2025

close #383

@fraxken fraxken requested a review from PierreDemailly May 26, 2025 20:50
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2025

🦋 Changeset detected

Latest commit: 6d68b9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nodesecure/mama Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fraxken fraxken force-pushed the mama-module-scan branch from acb0d7d to 6d68b9b Compare May 26, 2025 20:56
@PierreDemailly PierreDemailly requested a review from Copilot May 26, 2025 20:58
@fraxken fraxken merged commit 3ee9a2e into master May 26, 2025
5 checks passed
@fraxken fraxken deleted the mama-module-scan branch May 26, 2025 20:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances module type detection by introducing a new getter in ManifestManager and a corresponding inspectModuleType utility function, along with comprehensive tests and updated documentation.

  • Adds a new inspectModuleType utility to determine module types (dts, faux, dual, esm, cjs) based on various package.json properties.
  • Implements a new moduleType getter in ManifestManager and provides tests to validate its behavior.
  • Updates public exports and documentation to include the new moduleType functionality.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
workspaces/mama/test/inspectModuleType.spec.ts Adds tests covering various scenarios for inspectModuleType.
workspaces/mama/test/ManifestManager.spec.ts Introduces a test for the moduleType getter in ManifestManager.
workspaces/mama/src/utils/inspectModuleType.ts Implements the inspectModuleType function with recursive flag setting.
workspaces/mama/src/utils/index.ts Re-exports inspectModuleType and associated types.
workspaces/mama/src/index.ts Updates module exports to include inspectModuleType and its type.
workspaces/mama/src/ManifestManager.class.ts Adds the moduleType getter using inspectModuleType.
workspaces/mama/README.md Adds a documentation section for moduleType.
.changeset/crazy-drinks-sleep.md Provides a changeset note for the module type detection implementation.

}

// Explicit `commonjs` set, with a explicit `import` or `.mjs` too.
if (esm && type === "commonjs") {
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditions on lines 39-46 check flags (esm and cjs) that may not be initialized yet, which could lead to unexpected behavior. Consider reviewing or reordering these conditions to ensure that they correctly reflect the intended logic.

Copilot uses AI. Check for mistakes.
.some((script) => kUnsafeNPMScripts.has(script.toLowerCase()));
}

get moduleType() {
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding an explicit return type annotation for the moduleType getter to improve readability and type clarity.

Suggested change
get moduleType() {
get moduleType(): ReturnType<typeof inspectModuleType> {

Copilot uses AI. Check for mistakes.
Comment thread workspaces/mama/README.md

Return the type of the module

```ts
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The documentation for moduleType is brief; consider expanding it to list the possible return values ('dts', 'faux', 'dual', 'esm', 'cjs') and provide a short explanation for each.

Copilot uses AI. Check for mistakes.
@github-actions github-actions Bot mentioned this pull request May 26, 2025
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

Successfully merging this pull request may close these issues.

ManifestManager (mama): Implement module type analyze

3 participants