-
-
Notifications
You must be signed in to change notification settings - Fork 592
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
Cannot use import statement outside a module (ES, CommonJS) #4347
Comments
Thanks for the report. This is actually the same thing as #4284: my "fix" in #4285 just didn't work. If you open I think the problem is that there are actually two scripts that modify Anyway, TL;DR: let's update |
I found that the Release Process workflow does not seem to trigger the Static Analysis, which in turn is the only trigger of
As for the two scripts, they seem to do the same thing. The |
In short, because there are a bunch of other scripts in the git repository that aren't ES modules, and adding it breaks them. But yes, fixing those scripts and adding the declaration to |
Hopefully this is fixed by #4350. We'll see after the next RC |
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/...`.
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/...`.
* 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/...`.
I see the PR caused the workflow to fail. Then richvdh tried to add it directly? Right now, it is in code on git, but not on npm. |
We're still working on this. We'll cut another RC tomorrow. |
* 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/...`.
sorry, forgot to update: matrix-js-sdk v34.4.0-rc.1 was published yesterday, and this problem appears to be solved. @BLCK-B's repro example now hits #4287, but that is a separate problem. |
im hitting this problem (#4287 ) in v34 , i started developing just downgrading it to v32. Is there any solution available soon?. |
This should be fine in v34.4. If not, open a new issue explaining in more detail what your problem is, and giving reproduction steps. |
Also downgraded to v32. It's not solved. |
Please. |
I tried to import matrix-js-sdk both in CommonJs and ES projects.
The reported fixes, type module and .mjs, do not work.
To reproduce:
https://github.com/BLCK-B/MatrixSDKissue
Node.js v20.16.0
It reportedly does not work in tsnode either (Ho Ching):
Likely related:
#4284
#3145
The text was updated successfully, but these errors were encountered: