scalajs-bundler
scalajs-bundler copied to clipboard
yarn.lock different in compile and test
Did anyone else notice that yarn.lock
changes after running test
or fastOptJS::webpack
?
I couldn't figure out what exactly is changing, but my guess is that we may need two different lock-files. One for compile and one for test.
@fdietze it will be different if you define npmDependencies in Test
. Two lock files will also mean two node-modules
, which can be a problem. The workaround for us is to commit the lock file for Test
and make sure to use frozen-lockfile
by default. It works out pretty well for us
@ngbinh I'm trying your approach right now. So basically I add this to my build.sbt
:
yarnExtraArgs in Compile := Seq("--frozen-lockfile")
Then I delete my lock-file, run the tests and commit the newly generated lockfile.
When adding a new dependency, I delete the lockfile and run the tests again. Are you doing the same?
Yes. We have a script to do exactly what you've described.
@ngbinh It's not really working for me...
How do you trigger the creation of a lockfile after deletion? The yarn docs say for --frozen-lockfile
:
Don’t generate a yarn.lock lockfile and fail if an update is needed.
This is what I see. When no lockfile exists and I run fastOptJS::webpack
, no lockfile is written.
On the other hand test
creates a lockfile. But it only contains the jsdom
dependency (and transitive dependencies). Running fastOptJS::webpack
afterwards fails because of --frozen-lockfile
.
Also, when having a lockfile generated by fastOptJS::webpack
, the tests fail with the --frozen-lockfile
error.
What am I doing wrong?
What we did is fully clean the scala.js bundler projects and then run npmUpdate
again. It is a bit slow but only happens once you change npmDependencies
.
Same package-lock.json
file is also used when scalajs-bundler installs jsdom
for requireJsdom := true
. In this case package-lock.json
will only contains jsdom
dependency, so most of locked dependencies for compile/test will be lost.
I think we should aggregate all dependencies needed for compile/test (incl. jsdom) and put into single package.json
and package-lock.json
file, if we follow JavaScript manner.