Yarn publish is publishing state of package PRIOR to the prepublish script

Viewed 594

In my package.json, I have the following script:

"scripts": {
  "build": "tsc",
  "prepublish": "yarn build"
},

I would expect that when I issue the command "yarn publish" it would run the prepublish script, which would itself cause the build script to run, which would run the typescript compiler, and when publish happened, the new javascript that is generated by the typescript compiler would part of the published package.

And looking at the output of the yarn publish command, this looks like what is happening:

C:\> yarn publish
yarn publish v1.0.2
[1/4] Bumping version...
info Current version: 0.0.2
question New version: 0.0.3
info New version: 0.0.3
[2/4] Logging in...
[3/4] Publishing...
$ tsc
success Published.
[4/4] Revoking token...
info Not revoking login token, specified via config file.
Done in 17.20s.

So it looks fine. And when I am done with this, the javascript in my local package directory is fine.

However, if I now install that package elsewhere with yarn install, the installed package has the javascript that was in place BEFORE the typescript compiler (tsc) was run. Almost as if what was packaged up for publication was the state of the world BEFORE the prepublish script. This seems both wrong and counter-intuitive.

Is this a bug or am I misunderstanding something fundamental?

0 Answers
Related