Bug: conflict between package names includes orgs
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
Difficult one to explain, I used tsup with a 2 packages `@nestjs/typeorm` and `typeorm`. Took me several hours to debug but it appears that the outputed commonjs is importing `typeorm` modules from `@nestjs/typeorm` because the vars it creates for each module here is both `typeorm`?
For example, it appears `require_typeorm()` is `typeorm` and `require_typeorm2()` is `@nestjs/typeorm`. That's ok but when I get to the code snippet in question, I'm importing from `typeorm` which is changed to `required_typeorm2()` resulting in my imported var to be undefined.
Hope this makes sense to someone? I'm guessing there's a mismatch and the packagename is changed somewhere perhaps to remove the org name? Only a guess, wouldn't know where to look.
I will be doing a work around for this which will be to external one of these packages and zip that package with my bundled file.
Using v6.3.3
tsupconf
```
import { defineConfig } from 'tsup'
import fs from 'fs'
const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
export default defineConfig({
entry: ['src/http.ts'],
target: 'node14',
clean: true,
// minify: config.NODE_ENV === 'production',
esbuildOptions: (opts) => {
opts.resolveExtensions = ['.ts', '.mjs', '.js']
},
noExternal: Object.keys(pkgJson.dependencies),
external: [
'@nestjs/microservices',
'@nestjs/websockets',
'cache-manager',
],
})
```
tsconfigs
```
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"noImplicitAny": false,
"moduleResolution": "node",
"skipLibCheck": true,
"resolveJsonModule": true,
"sourceMap": true,
"outDir": "./dist"
},
"include": ["./src/**/*"],
"exclude": [
"./dist",
"./node_modules",
"./src/tests/coverage",
"./src/**/*.spec.ts",
"./src/**/__mocks__"
]
}
```
Contributor guide
Assessment
This issue has not been assessed yet.