module-federation / practical-module-federation

76 stars 23 forks source link

Chapter 2 - deleting yarn.lock breaks the packages #18

Open citypaul opened 3 years ago

citypaul commented 3 years ago

I've tested this and it does seem to the case at the moment that if you follow the advice in chapter 2, "First, stop both of the development servers and remove the node_modules directories and yarn.lock files.", deleting the yarn.lock files and doing a yarn at the time of writing breaks the packages.

The error I get when doing this is: TypeError: Cannot read property 'Compilation' of undefined.

If I bring back the original yarn.lock, everything works as expected.

citypaul commented 3 years ago

Note - the above occurs when using the npx command, eg: npx degit git@github.com:jherr/wp5-starter-react.git#main home. If you remove the yarn.lock here and do a yarn, you should probably see the issue.

However, the code in chapter2/ inside this repo has different dependencies to the starter code, and inside this repo you can currently delete yarn.lock and yarn still works. The difference in dependencies between the starter pack and your repo here probably wants looking at, because the difference setup creates different results and can be confusing.

shaohaolin commented 3 years ago

One way to solve this is by copying the yarn.lock file created using npx degit git@github.com:jherr/wp5-starter-react.git#main home and paste it at the root level folder.