mswjs / interceptors

Low-level network interception library.
https://npm.im/@mswjs/interceptors
MIT License
523 stars 118 forks source link

Simplify the npm package files #572

Open tkrotoff opened 2 months ago

tkrotoff commented 2 months ago

The generated npm package contains files that are randomly named like chunk-GUY7XK43.mjs. Please make the npm package files human friendly.

This makes the source code difficult to debug (in the context of an application that uses @mswjs/interceptors via node_modules).

I had a hard time finding a performance issue with JSDOM because of this: https://github.com/tkrotoff/jsdom-slow-URL-parsing

image
kettanaito commented 2 months ago

Hi, @tkrotoff. Thanks for raising this.

What chunk format would you consider more friendly?

Note, these are automatically generated by tsup. We can change the chunk name pattern but they will always be named somewhat randomly (right now it's based off the chunk's hash). The chunks are also correctly split since you want granular modules to have granular imports in ESM.

If you can tell me more about the issue you've experienced, the way you tried to debug, and the way that actually worked, that would help me in making the right decision here. Thanks.

tkrotoff commented 1 month ago

What chunk format would you consider more friendly?

No chunks

tsup

I've never used tsup nor needed it for my libraries, maybe it's not a great tool, maybe you don't need it.

For example, you don't need to ship the .map files (source maps): you don't need to minify the code and Node.js knows recent ES features so the original code and the bundled code are almost identical. You also don't need to ship the original TypeScript source code.

the way you tried to debug

You have a performance issue (https://github.com/tkrotoff/jsdom-slow-URL-parsing). You put console.log, console.time, IDE breakpoints in your code + in node_modules to understand what's going on. Having multiple files (in node_modules) named randomly with indirections makes it hard and error-prone.