Git Product home page Git Product logo

Comments (7)

hjdhjd avatar hjdhjd commented on June 5, 2024 2

I don't think there is a PR needed here - the issue is with the compilation options the user is using, not the code itself.

Try using:

tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "lib": [
      "DOM",
      "ES2022"
    ],
    "module": "ES2022",
    "moduleResolution":"node",
    "outDir": "dist",
    "rootDir": "src",
    "sourceMap": true,
    "strict": true,
    "target": "ES2022"
  },
  "include": [
    "src"
  ]
}

Ensure package.json has "type": "module" in there as well.

@robertsLando I can confirm that everything is working as it should be with the existing release.

from aedes.

robertsLando avatar robertsLando commented on June 5, 2024

Does it works with 0.50.0? May be a regression introduced by #918 .

cc @hjdhjd

from aedes.

benbai123 avatar benbai123 commented on June 5, 2024

nope, tried 0.49.0 and 0.50.0, same error

from aedes.

robertsLando avatar robertsLando commented on June 5, 2024

Could you submit a PR to fix the issue?

from aedes.

benbai123 avatar benbai123 commented on June 5, 2024

confirmed, need "type": "module" and 2 key compiler options.

  • 2 key compiler options
{
  // ...
  "module": "ES2022",
  "moduleResolution":"node",
}

btw, the compiler options I used before are copied from NestJS

from aedes.

benbai123 avatar benbai123 commented on June 5, 2024

tried run Aedes with NestJS, failed as expected.

workaround for NestJS :

import * as Aedes from 'aedes'
import { createServer } from 'net'

const port = 1883

const aedes = Aedes.createBroker()
const server = createServer(aedes.handle)

server.listen(port, function () {
  console.log('server started and listening on port ', port)
})

found another ts compiler option "esModuleInterop": true working with NestJS, but probably will break some other packages like jwks-rsa raw-body

from aedes.

robertsLando avatar robertsLando commented on June 5, 2024

Ensure package.json has "type": "module" in there as well.

@hjdhjd So it only works with ESM now? Does it always require type module??

from aedes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.