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

yarn fails due to import issue #1771

Open
asdofindia opened this issue Aug 10, 2023 · 2 comments
Open

yarn fails due to import issue #1771

asdofindia opened this issue Aug 10, 2023 · 2 comments
Labels
needs-investigation S-Major Severely degrades major functionality or product features, with no satisfactory workaround T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems.

Comments

@asdofindia
Copy link

$ yarn
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
$ yarn run build
yarn run v1.22.19
$ yarn run build:app && yarn run build:widget
$ tsc --project ./tsconfig.json
src/models/MatrixAction.ts:19:1 - error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.

19 import ircFormatting = require("../irc/formatting");
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in src/models/MatrixAction.ts:19

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I fixed this by changing that line

$ git diff src/
diff --git a/src/models/MatrixAction.ts b/src/models/MatrixAction.ts
index e213aeb4..fbdc38b4 100644
--- a/src/models/MatrixAction.ts
+++ b/src/models/MatrixAction.ts
@@ -16,7 +16,7 @@ limitations under the License.
 
 import { IrcAction } from "./IrcAction";
 
-import ircFormatting = require("../irc/formatting");
+import * as ircFormatting from "../irc/formatting";
 import { ContentRepo, Intent } from "matrix-appservice-bridge";
 import escapeStringRegexp from "escape-string-regexp";
 import logging from "../logging";
@Half-Shot Half-Shot added T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems. S-Major Severely degrades major functionality or product features, with no satisfactory workaround labels Aug 14, 2023
@Half-Shot
Copy link
Contributor

Is this on latest develop? You have a:

warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.

warning which implies you either ran npm, or are on a older version of the bridge.

The import itself looks sloppy, but we're not targetting modules (rather, commonjs) so I think there might be something up with your environment.

@asdofindia
Copy link
Author

I was on 1.0.1 tag, but this line is there in develop also
https://github.com/matrix-org/matrix-appservice-irc/blob/develop/src/models/MatrixAction.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation S-Major Severely degrades major functionality or product features, with no satisfactory workaround T-Defect Bugs, crashes, hangs, vulnerabilities, or other reported problems.
Projects
None yet
Development

No branches or pull requests

2 participants