microsoft / microsoft/tsyringe
Named exports for Node.js
Open
@Xapphire13 is already working on this.
Since Dec 20, 2020.
accepting PRs
awaiting triage
enhancement
- Dominant language
- TypeScript
- Stars
- 6k
- Forks
- 184
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
Problem
I'm using tsyringe in Node.js >= 12 with the ESM module loader enabled. I would like to use named exports of tsyringe but I'm not able to do so:
import { container } from 'tsyringe';
^^^^^^^^^
SyntaxError: The requested module 'tsyringe' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'tsyringe';
const { container } = pkg;
My tsconfig.json looks like:
{
"compilerOptions": {
"outDir": "lib",
"incremental": true,
"target": "ES2019",
"module": "ESNext",
"strict": true,
"noImplicitAny": false,
"alwaysStrict": true,
"moduleResolution": "Node",
"baseUrl": "src",
"types": [ "node", "global", "mocha" ],
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"sourceMap": true,
"importHelpers": true
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Description
Having a release published as ES 6 module ("type": "module") would help.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.