0x80 / isolate-package

Isolate a monorepo package with its internal dependencies to form a self-contained directory with a pruned lockfile
MIT License
121 stars 13 forks source link

Option to preserve package.json scripts #17

Closed tbuckley closed 1 year ago

tbuckley commented 1 year ago

My project has a shared database package that uses Prisma. Prisma generates a client for interacting with your database based on your schema, and the generated files are put into node_modules/@prisma/client. The prisma generate command needs to be run on the target platform. Most guidance is to run this command using a postinstall script within package.json (example).

However, isolate-package omits out scripts from the generated package.json files here, so this approach currently won't work.

Is it possible to add an option to preserve (specific) scripts?

For now I'm working around this with a script that appends the postinstall script to the generated package.json after running isolate.

Thank you for creating this project!

0x80 commented 1 year ago

I do not remember the motivation for omitting the scripts. Seems like an odd choice with no real benefits. Since you have a use-case for the scripts as part of the isolated output I think we should just preserve them always.

It was a quick fix so I released 1.3.2 with this change. I haven't actually tested it, but I'm pretty confident it'll work 🤞 😄