Closed vz-tl closed 1 year ago
removing
"exports": {
".": {
"require": "./src/index.js"
}
}
from the installed node module package.json would solve the issue, but this isn't really an option.
narrowing down a bit more: using require
syntax works, but this doesn't fit for my project.
So, updating the "exports" section in package.json to the following makes it work, when using import {...} from ...
:
"exports": {
".": {
"require": "./src/index.js",
"import": "./src/index.js"
}
it would be great if using import syntax could also be properly supported.
Hello @vz-tl, as you can see all the examples in docs are using the import syntax, so it works well, can you link your tsconfig or the way you are compiling / using your typescript?
This is an Angular Universal project, where your module is being imported in the express server part. The project is compiled via regular Angular server build target, based on webpack.
Below related tsconfig.server.json output using tsc --showConfig
:
{
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"target": "es2016",
"module": "es2020",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom",
"es2018.asynciterable"
],
"moduleResolution": "node",
"downlevelIteration": true,
"sourceMap": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"allowJs": true,
"paths": {
// removed for brevity
},
"types": [
"node"
],
"outDir": "./out-tsc/server"
},
"files": [
"./src/main.server.ts",
"./server.ts",
// rest removed for brevity
],
"include": [
// removed for brevity
],
"exclude": [
"jest.config.ts"
]
}
@vz-tl Published 3.2.0 that should expose a CJS and an ESM build can you try with this new version?
@Tirke , works perfectly! Thx a lot!
I'm trying to use
node-cache-manager-ioredis
but struggling on importing from the package, as described in the readme:gives me the following error:
The project is pretty much standard:
Any advice?