You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Move type:module
declaration into package.json. (#4355)
* 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 https://github.com/matrix-org/matrix-js-sdk/issues/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/...`.
This commit is contained in:
committed by
GitHub
parent
2544c14032
commit
b8e8b14375
@ -12,6 +12,3 @@ do
|
||||
jq ".$i = .matrix_lib_$i" package.json > package.json.new && mv package.json.new package.json && yarn prettier --write package.json
|
||||
fi
|
||||
done
|
||||
|
||||
# Ensure that "type": "module" is present
|
||||
jq '.type = "module"' package.json > package.json.new && mv package.json.new package.json && yarn prettier --write package.json
|
||||
|
18
scripts/switch_package_to_release.cjs
Executable file
18
scripts/switch_package_to_release.cjs
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fsProm = require("fs/promises");
|
||||
|
||||
const PKGJSON = "package.json";
|
||||
|
||||
async function main() {
|
||||
const pkgJson = JSON.parse(await fsProm.readFile(PKGJSON, "utf8"));
|
||||
for (const field of ["main", "typings"]) {
|
||||
if (pkgJson["matrix_lib_" + field] !== undefined) {
|
||||
pkgJson[field] = pkgJson["matrix_lib_" + field];
|
||||
}
|
||||
}
|
||||
|
||||
await fsProm.writeFile(PKGJSON, JSON.stringify(pkgJson, null, 2));
|
||||
}
|
||||
|
||||
main();
|
@ -1,22 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fsProm = require("fs/promises");
|
||||
|
||||
const PKGJSON = "package.json";
|
||||
|
||||
async function main() {
|
||||
const pkgJson = JSON.parse(await fsProm.readFile(PKGJSON, "utf8"));
|
||||
for (const field of ["main", "typings"]) {
|
||||
if (pkgJson["matrix_lib_" + field] !== undefined) {
|
||||
pkgJson[field] = pkgJson["matrix_lib_" + field];
|
||||
}
|
||||
}
|
||||
|
||||
// matrix-js-sdk is built into ECMAScript modules. Make sure we declare it as such.
|
||||
// See https://nodejs.org/api/packages.html#type.
|
||||
pkgJson["type"] = "module";
|
||||
|
||||
await fsProm.writeFile(PKGJSON, JSON.stringify(pkgJson, null, 2));
|
||||
}
|
||||
|
||||
main();
|
1
scripts/switch_package_to_release.js
Symbolic link
1
scripts/switch_package_to_release.js
Symbolic link
@ -0,0 +1 @@
|
||||
switch_package_to_release.cjs
|
Reference in New Issue
Block a user