Skip to content

Conversation

@pan-kot
Copy link
Member

@pan-kot pan-kot commented Jan 27, 2026

Required for: cloudscape-design/collection-hooks#130

Requires:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pan-kot pan-kot changed the title chore: Add .js estensions for esm resolutions chore: Add .js estensions for esm resolution Jan 27, 2026
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.05%. Comparing base (012284d) to head (e14d016).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #190   +/-   ##
=======================================
  Coverage   99.05%   99.05%           
=======================================
  Files          42       42           
  Lines        1165     1165           
  Branches      317      316    -1     
=======================================
  Hits         1154     1154           
  Misses         10       10           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pan-kot pan-kot force-pushed the esm-friendly branch 3 times, most recently from 2d8526a to a951be2 Compare January 28, 2026 08:31
@pan-kot pan-kot changed the title chore: Add .js estensions for esm resolution chore: Use type: "module" and build to cjs/mjs Jan 28, 2026
],
"no-warning-comments": "warn"
"no-warning-comments": "warn",
"import/extensions": ["error", "ignorePackages"]
Copy link
Member Author

Choose a reason for hiding this comment

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

We need ".js" extensions so that mjs imports are resolved correctly. Without that, the downstream builds fail. The same issue exists in the collection-hooks. As a follow-up change, I plan to apply the same changes to the collection-hooks eslint config.

@pan-kot pan-kot force-pushed the esm-friendly branch 5 times, most recently from 5ce65ae to 1cc1b31 Compare January 28, 2026 09:13
},
"sideEffects": false,
"types": "./mjs/index.d.ts",
"typesVersions": {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed to fix downstream packages that import from /dom or /internal. That will not be needed should we update the packages to use moduleResolution: "nodenext".

@pan-kot pan-kot marked this pull request as ready for review January 29, 2026 05:57
@pan-kot pan-kot requested a review from a team as a code owner January 29, 2026 05:57
@pan-kot pan-kot removed the request for review from a team January 29, 2026 05:57
packageCjs.type = 'commonjs';

writeFileSync(libPkgPath, JSON.stringify(packageCjs, null, 2) + '\n');
writeFileSync(esmPkgPath, JSON.stringify({ type: 'module' }, null, 2) + '\n');
Copy link
Member

Choose a reason for hiding this comment

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

Is this writing just {type: module} as the entire file content?

Copy link
Member

Choose a reason for hiding this comment

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

What are these two additional package.json files actually for?

Copy link
Member Author

Choose a reason for hiding this comment

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

We only publish the /lib folder - that's why the /lib/package.json is needed - it describes the package. However, as the /lib includes cjs exports, we have to change the type from "module" to "commonjs" after copying it.

In /lib/mjs we have ejs exports, therefore type "module" is needed again. There is no need to copy the entire package.json though - it will extend from the one in the package's root.

@pan-kot pan-kot requested a review from jperals January 29, 2026 11:34
@pan-kot pan-kot added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 9ceede1 Jan 29, 2026
79 of 80 checks passed
@pan-kot pan-kot deleted the esm-friendly branch January 29, 2026 15:16
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.

2 participants