rfcs icon indicating copy to clipboard operation
rfcs copied to clipboard

Add importable scripts

Open cvanem opened this issue 6 years ago • 4 comments
trafficstars

Allow scripts to be imported from a file as an alternative to the standard object hash in the packages.json scripts field. Also define the basic structure of the imported file.

RFC Documentation: https://github.com/yarnpkg/website/pull/951 PR: https://github.com/yarnpkg/yarn/pull/7284

cvanem avatar May 17 '19 08:05 cvanem

Hey! Thanks for the suggestion 😃 I do have one big concern, however: this proposal makes it impossible to statically know what scripts are available. We would always have to execute the Javascript code to figure it out.

arcanis avatar May 17 '19 14:05 arcanis

@arcanis Yes, I suppose that is another drawback that should be added. Is this concern due to a performance hit or something else? The Javascript code would only be executed if a filename input is provided.

cvanem avatar May 17 '19 19:05 cvanem

@arcanis Hey just following up on this. Can you tell me how likely it is that this PR will be accepted anytime soon? The reason I am asking, is that we are currently evaluating some options for cleaning up our scripts. See https://github.com/mui-org/material-ui/issues/15497

If this is not going to be accepted, then I would like to resolve any issues so it can be accepted, or look at other options, such as using nps.

cvanem avatar Jun 01 '19 17:06 cvanem

This is one of the reasons I added support of package.yaml to pnpm (although I am still not sure that was a good idea). But a yaml file (or a json5 file), also satisfies your requirements.

You can write scripts like this:

scripts:
  # This is some comment
  test: >-
    pnpm recursive test
    --reporter append-only
    --workspace-concurrency 1
    --filter ./packages
    --filter ./privatePackages
build: pnpm recursive run tsc

zkochan avatar Jul 14 '19 12:07 zkochan