proposal-signals / signal-polyfill

Implementation tracking the current state of https://github.com/tc39/proposal-signals
Apache License 2.0
185 stars 13 forks source link

Use prepare script allowing usage from git npm dependency #18

Open divdavem opened 3 months ago

divdavem commented 3 months ago

This PR replaces the prepack script with the prepare script, so that it is easy for any depending package to try any branch of any fork of the signal-polyfill repository with the git url or the github url syntax in the package.json file. For example:

{
  "dependencies": {
    "signal-polyfill": "divdavem/signal-polyfill#prepareScript"
  }
}

As mentioned in npm documentation:

NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.

Without this change, the build process is not run automatically by npm and the installed package is not directly usable when referred through a git or github url dependency in package.json.

Note that, even though, according to the npm documentation prepack is supposed to be called as well in this case (Runs BEFORE a tarball is packed (on "npm pack", "npm publish", and when installing a git dependency).), in practice, I did not find the dist folder when trying with the prepack script instead of prepare.

NullVoxPopuli commented 2 months ago

Can we have both scripts?

Folks with ignore-scripts=true would not have prepare ran, yeah?

divdavem commented 2 months ago

@NullVoxPopuli Thank you for your comment.

Can we have both scripts?

prepare and prepack are both called before publishing to npm, so I don't see any benefit to have both.

Folks with ignore-scripts=true would not have prepare ran, yeah?

People with ignore-scripts=true would see no change from the current setup with prepack. As prepare is run before publishing to npm, the package published to npm would not have any difference.

There is a difference when installing the package with a git npm dependency (to use it directly from this github repository). In that case, prepare causes the devDependencies to be installed before the prepare script is run. But that would probably not happen for people with ignore-scripts=true (but it would not work either with prepack).