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

chore: makes sources type:module ready & publish as type:module #915

Merged
merged 2 commits into from
Feb 24, 2024

Conversation

sverweij
Copy link
Owner

@sverweij sverweij commented Feb 24, 2024

Description

  • renames every module (that is not a test fixture or mock) with a .js extension to .cjs
  • for packaging only ensure the package.json has a type: "module" entry
    (during development time we still need the flexiblity of a package.json without - so we can tests scenarios without node throwing a hissy fit)

Motivation and Context

dependency-cruiser has been ESM only since version 13. Until now it didn't advertise this in its package manifest. This is a non-standard way of doing ESM only modules. Then why didn't we do it the standard way? Well, glad you asked. Test fixtures and mocks are affected by the "type": "module" setting as well. As we have several tests that have .js files with commonjs in them, these got qualified as ESM - which jump-scares the nodejs ESM processor.

This PR circumvents this issue by

  • not specifying a "type" in the manifest, so during development the .js modules in mocks and fixtures can still safely contain commonjs.
  • when packaging adding the "type": "module" to the manifest.

For this to work properly the last remnants of files still called ".js" but actually having commonjs content in src and configs needed to be renamed to .cjs. For good measure we did the same for all other .js module that wasn't a mock or fixture.

How Has This Been Tested?

  • green ci
  • throwing the new version against a few repositories (manually)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation only change
  • Refactor (non-breaking change which fixes an issue without changing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • 📖

    • My change doesn't require a documentation update, or ...
    • it does and I have updated it
  • ⚖️

    • The contribution will be subject to The MIT license, and I'm OK with that.
    • The contribution is my own original work.
    • I am ok with the stuff in CONTRIBUTING.md.

@sverweij sverweij changed the title chore: makes sources type:module ready chore: makes sources type:module ready & publish as type:module Feb 24, 2024
Copy link

codeclimate bot commented Feb 24, 2024

Code Climate has analyzed commit 4fdb75a and detected 0 issues on this pull request.

View more on Code Climate.

@sverweij sverweij merged commit cabbf2e into main Feb 24, 2024
10 checks passed
@sverweij sverweij deleted the chore/makes-sources-type-module-ready branch February 24, 2024 20:45
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.

1 participant