Skip to content

[Feature Request] ESM support #969

@ymc9

Description

@ymc9

Reported by VT01 on discord.

import { ZenStackMiddleware } from '@zenstackhq/server/express';
Error:
SyntaxError: Named export 'ZenStackMiddleware' not found. The requested module '@zenstackhq/server/express' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@zenstackhq/server/express';
const { ZenStackMiddleware } = pkg;

Node.js v20.11.0

my tsconfig.json:

"compilerOptions": {
"target": "esnext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"noUncheckedIndexedAccess": true,
"lib": [
"ESNext"
],
}

package.json fields that probably causes the mistake (however I need it):
"type": "module"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions