denoland / denoland/dnt

Nested `node_modules` generated under `esm`/`script` which breaks module resolution

Open
#306 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.3k
Forks
49
PR merge metrics
No merged PRs in 30d

Description

## Issue

`dnt` is outputting dependencies under `npm/esm/node_modules` and `npm/script/node_modules` in addition to the root `npm/node_modules`. The nested `node_modules` only contain an incomplete set of files from the [ya-svg-transform](https://www.npmjs.com/package/ya-svg-transform) package which is installed correctly in the root `node_modules` folder.

This results in the tests failing with the following error:
![image](https://github.com/denoland/dnt/assets/9361948/e9e1844c-0ad9-442b-b3ff-753e68e44145)

## Temporary Workaround

I found that deleting the extra `node_modules` directories resolved the issue so I added the following to my `postBuild` hook:
`build_npm.ts`
```
...
await build({
postBuild() {
...
// Delete unwanted node_modules outputs
// Deno.removeSync("npm/esm/node_modules", { recursive: true });
// Deno.removeSync("npm/script/node_modules", { recursive: true });
},
});

```

## Notes

Not sure why these extra files are being emitted but it seems to me it may be an issue with the [ts-morph](https://github.com/dsherret/ts-morph) package.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.