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

Move type:module declaration into package.json. #4355

Merged
merged 3 commits into from
Aug 20, 2024

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Aug 20, 2024

matrix-js-sdk is built into ECMAScript modules, and we should declare it as such. See https://nodejs.org/api/packages.html#type. Failure to do so causes problems for javascript projects attempting to build against matrix-js-sdk: see #4347.

Previously, we did this as part of the package.json switcheroo, but that is unnecessarily fragile.

matrix-react-sdk, element-web, etc are unaffected by this, because they use the typescript files directly, by importing matrix-js-sdk/src/....

Before we can make the switch, we need to rename a couple of commonjs scripts.

@richvdh richvdh added Task T-Task Tasks for the team like planning and removed Task labels Aug 20, 2024
Slightly surprisingly, the symlink is enough to make `node
switch_package_to_release.js` work.
Again, declare this as commonjs
matrix-js-sdk is built into ECMAScript modules, and we should declare it as
such. See https://nodejs.org/api/packages.html#type. Failure to do so causes
problems for javascript projects attempting to build against matrix-js-sdk: see #4347.

Previously, we did this as part of the package.json switcheroo, but that is
unnecessarily fragile.

matrix-react-sdk, element-web, etc are unaffected by this, because they use the
typescript files directly, by importing `matrix-js-sdk/src/...`.
Copy link
Member Author

Choose a reason for hiding this comment

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

github fails to show this, but this is a symlink

@richvdh richvdh added this pull request to the merge queue Aug 20, 2024
Merged via the queue into develop with commit b8e8b14 Aug 20, 2024
30 checks passed
@richvdh richvdh deleted the rav/kill_package_switcheroo/module_type branch August 20, 2024 16:40
richvdh added a commit that referenced this pull request Aug 20, 2024
Fix tests failing as a result of
#4355. This wasn't detected in
CI because the slowReporter is only enabled when building against develop.
github-merge-queue bot pushed a commit that referenced this pull request Aug 20, 2024
Fix tests failing as a result of
#4355. This wasn't detected in
CI because the slowReporter is only enabled when building against develop.
RiotRobot pushed a commit that referenced this pull request Aug 21, 2024
Fix tests failing as a result of
#4355. This wasn't detected in
CI because the slowReporter is only enabled when building against develop.

(cherry picked from commit d413f50)
@dbkr dbkr added the backport staging Label to automatically backport PR to staging branch label Aug 21, 2024
@RiotRobot
Copy link
Contributor

The backport to staging failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-staging staging
# Navigate to the new working tree
cd .worktrees/backport-staging
# Create a new branch
git switch --create backport-4355-to-staging
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b8e8b143751d61b710ff6df33ec69f09cccf3adf
# Push it to GitHub
git push --set-upstream origin backport-4355-to-staging
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-staging

Then, create a pull request where the base branch is staging and the compare/head branch is backport-4355-to-staging.

dbkr pushed a commit that referenced this pull request Aug 21, 2024
* Rename `switch_package_to_release.js` to `.cjs`

Slightly surprisingly, the symlink is enough to make `node
switch_package_to_release.js` work.

* Rename .eslintrc.js to .cjs

Again, declare this as commonjs

* Move `type:module` declaration into package.json.

matrix-js-sdk is built into ECMAScript modules, and we should declare it as
such. See https://nodejs.org/api/packages.html#type. Failure to do so causes
problems for javascript projects attempting to build against matrix-js-sdk: see #4347.

Previously, we did this as part of the package.json switcheroo, but that is
unnecessarily fragile.

matrix-react-sdk, element-web, etc are unaffected by this, because they use the
typescript files directly, by importing `matrix-js-sdk/src/...`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport staging Label to automatically backport PR to staging branch T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants